diff --git a/packages/e2e-test/src/commands/run.ts b/packages/e2e-test/src/commands/run.ts index fe4d87bea4..3eedb90b21 100644 --- a/packages/e2e-test/src/commands/run.ts +++ b/packages/e2e-test/src/commands/run.ts @@ -57,13 +57,14 @@ export async function run() { const appDir = await createApp('test-app', workspaceDir, rootDir); print('Creating a Backstage Plugin'); - const pluginName = await createPlugin('test-plugin', appDir); + const pluginId = 'test'; + await createPlugin({ appDir, pluginId, select: 'plugin' }); print('Creating a Backstage Backend Plugin'); - await createPlugin('test-plugin', appDir, ['--backend']); + await createPlugin({ appDir, pluginId, select: 'backend-plugin' }); print('Starting the app'); - await testAppServe(pluginName, appDir); + await testAppServe(pluginId, appDir); if (Boolean(process.env.POSTGRES_USER)) { print('Testing the PostgreSQL backend startup'); @@ -328,14 +329,18 @@ async function overrideModuleResolutions(appDir: string, workspaceDir: string) { /** * Uses create-plugin command to create a new plugin in the app */ -async function createPlugin( - pluginName: string, - appDir: string, - options: string[] = [], -) { - const child = spawnPiped(['yarn', 'create-plugin', ...options], { - cwd: appDir, - }); +async function createPlugin(options: { + appDir: string; + pluginId: string; + select: string; +}) { + const { appDir, pluginId, select } = options; + const child = spawnPiped( + ['yarn', 'new', '--select', select, '--option', `id=${pluginId}`], + { + cwd: appDir, + }, + ); try { let stdout = ''; @@ -343,20 +348,14 @@ async function createPlugin( stdout = stdout + data.toString('utf8'); }); - await waitFor(() => stdout.includes('Enter an ID for the plugin')); - child.stdin?.write(`${pluginName}\n`); - - // await waitFor(() => stdout.includes('Enter the owner(s) of the plugin')); - // child.stdin.write('@someuser\n'); - print('Waiting for plugin create script to be done'); await waitForExit(child); - const canonicalName = options.includes('--backend') - ? `${pluginName}-backend` - : pluginName; - - const pluginDir = resolvePath(appDir, 'plugins', canonicalName); + const pluginDir = resolvePath( + appDir, + 'plugins', + select === 'backend-plugin' ? `${pluginId}-backend` : pluginId, + ); print(`Running 'yarn tsc' in root for newly created plugin`); await runPlain(['yarn', 'tsc'], { cwd: appDir }); @@ -365,8 +364,6 @@ async function createPlugin( print(`Running 'yarn ${cmd.join(' ')}' in newly created plugin`); await runPlain(['yarn', ...cmd], { cwd: pluginDir }); } - - return canonicalName; } finally { child.kill(); } @@ -375,7 +372,7 @@ async function createPlugin( /** * Start serving the newly created app and make sure that the create plugin is rendering correctly */ -async function testAppServe(pluginName: string, appDir: string) { +async function testAppServe(pluginId: string, appDir: string) { const startApp = spawnPiped(['yarn', 'start'], { cwd: appDir, env: { @@ -398,8 +395,8 @@ async function testAppServe(pluginName: string, appDir: string) { await waitForPageWithText(page, '/', 'My Company Catalog'); await waitForPageWithText( page, - `/${pluginName}`, - `Welcome to ${pluginName}!`, + `/${pluginId}`, + `Welcome to ${pluginId}!`, ); print('Both App and Plugin loaded correctly');