Create new app in temp dir
This commit is contained in:
+17
-6
@@ -27,27 +27,38 @@ const {
|
||||
|
||||
const createTestApp = require('./createTestApp');
|
||||
const createTestPlugin = require('./createTestPlugin');
|
||||
const generateTempDir = require('./generateTempDir.js');
|
||||
|
||||
Browser.localhost('localhost', 3000);
|
||||
|
||||
async function main() {
|
||||
process.env.CI = 'true';
|
||||
process.env.E2E = 'true';
|
||||
|
||||
const projectDir = resolvePath(__dirname, '..');
|
||||
process.chdir(projectDir);
|
||||
const rootDir = process.env.CI
|
||||
? resolvePath(process.env.GITHUB_WORKSPACE)
|
||||
: resolvePath(__dirname, '..');
|
||||
|
||||
await createTestApp();
|
||||
const tempDir = process.env.CI
|
||||
? resolvePath(__dirname)
|
||||
: await generateTempDir();
|
||||
|
||||
const appDir = resolvePath(projectDir, 'test-app');
|
||||
process.chdir(tempDir);
|
||||
await waitForExit(spawnPiped(['yarn', 'init --yes']));
|
||||
|
||||
const createAppCmd = `${rootDir}/packages/cli/bin/backstage-cli create-app`;
|
||||
await createTestApp(createAppCmd);
|
||||
|
||||
const appDir = resolvePath(tempDir, 'test-app');
|
||||
process.chdir(appDir);
|
||||
|
||||
await createTestPlugin();
|
||||
|
||||
print('Starting the app');
|
||||
const startApp = spawnPiped(['yarn', 'start']);
|
||||
|
||||
try {
|
||||
const browser = new Browser();
|
||||
|
||||
await createTestPlugin();
|
||||
await waitForPageWithText(browser, '/', 'Welcome to Backstage');
|
||||
await waitForPageWithText(
|
||||
browser,
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
const { spawnPiped, waitFor, waitForExit, print } = require('./helpers');
|
||||
|
||||
async function createTestApp() {
|
||||
async function createTestApp(cmd) {
|
||||
print('Creating a Backstage App');
|
||||
const createApp = spawnPiped(['yarn', 'create-app']);
|
||||
const createApp = spawnPiped(['node', cmd]);
|
||||
|
||||
try {
|
||||
let stdout = '';
|
||||
|
||||
@@ -29,8 +29,8 @@ async function createTestPlugin() {
|
||||
await waitFor(() => stdout.includes('Enter an ID for the plugin'));
|
||||
createPlugin.stdin.write('test-plugin\n');
|
||||
|
||||
await waitFor(() => stdout.includes('Enter the owner(s) of the plugin'));
|
||||
createPlugin.stdin.write('@someuser\n');
|
||||
// await waitFor(() => stdout.includes('Enter the owner(s) of the plugin'));
|
||||
// createPlugin.stdin.write('@someuser\n');
|
||||
|
||||
print('Waiting for plugin create script to be done');
|
||||
await waitForExit(createPlugin);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const { handleError } = require('./helpers');
|
||||
|
||||
async function generateTempDir() {
|
||||
const tempDir = await require('fs-extra').mkdtemp(
|
||||
require('path').join(require('os').tmpdir(), 'backstage-e2e-'),
|
||||
);
|
||||
process.stdout.write(tempDir);
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
module.exports = generateTempDir;
|
||||
|
||||
process.on('unhandledRejection', handleError);
|
||||
generateTempDir().catch(handleError);
|
||||
Reference in New Issue
Block a user