-
Notifications
You must be signed in to change notification settings - Fork 232
QA to E2E: app basic flow (no extensions) #7047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
phyllis-sy-wu
wants to merge
4
commits into
main
Choose a base branch
from
psyw-0318-QAtoE2E-basic-flow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| /* eslint-disable no-restricted-imports */ | ||
| import {appScaffoldFixture as test} from '../setup/app.js' | ||
| import {requireEnv} from '../setup/env.js' | ||
| import {expect} from '@playwright/test' | ||
| import * as fs from 'fs' | ||
| import * as path from 'path' | ||
|
|
||
phyllis-sy-wu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| test.describe('App basic flow (no extensions)', () => { | ||
| test('init, dev, execute, quit, clean, deploy, versions, config link, deploy to secondary', async ({ | ||
| appScaffold, | ||
| cli, | ||
| env, | ||
| }) => { | ||
| // Full flow: init + dev (3 min) + deploy + config link + secondary deploy — needs 10 min | ||
| test.setTimeout(10 * 60 * 1000) | ||
|
|
||
| requireEnv(env, 'clientId', 'storeFqdn', 'secondaryClientId') | ||
|
|
||
| // Step 1: Create a React Router app | ||
| const initResult = await appScaffold.init({ | ||
| template: 'reactRouter', | ||
| flavor: 'javascript', | ||
| packageManager: 'npm', | ||
| }) | ||
| expect(initResult.exitCode, '‼️ Step 1 - app init failed').toBe(0) | ||
|
|
||
| // Step 2: Start dev server via PTY | ||
| // Unset CI so keyboard shortcuts are enabled in the Dev UI | ||
| const dev = await cli.spawn(['app', 'dev', '--path', appScaffold.appDir], {env: {CI: ''}}) | ||
| try { | ||
| await dev.waitForOutput('Ready, watching for changes in your app', 3 * 60 * 1000).catch((err: Error) => { | ||
| throw new Error(`‼️ Step 2 - app dev failed\n${err.message}`) | ||
| }) | ||
|
|
||
| // Step 3: Run a GraphQL query while the dev server is running | ||
| const executeResult = await cli.exec( | ||
| ['app', 'execute', '--query', 'query { shop { name } }', '--path', appScaffold.appDir], | ||
| {timeout: 60 * 1000}, | ||
| ) | ||
| const executeOutput = executeResult.stdout + executeResult.stderr | ||
| expect(executeResult.exitCode, '‼️ Step 3 - app execute failed').toBe(0) | ||
phyllis-sy-wu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expect(executeOutput, '‼️ Step 3 - app execute: response missing "shop" field').toContain('"shop"') | ||
|
|
||
| // Step 4: Press q to quit the dev server | ||
| dev.sendKey('q') | ||
| const devExitCode = await dev.waitForExit(30_000).catch((err: Error) => { | ||
| throw new Error(`‼️ Step 4 - app dev did not exit after pressing q\n${err.message}`) | ||
| }) | ||
| expect(devExitCode, '‼️ Step 4 - app dev quit failed').toBe(0) | ||
| } finally { | ||
| // Step 5: Always clean up the dev preview, even if the test fails | ||
| dev.kill() | ||
phyllis-sy-wu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const cleanResult = await cli.exec(['app', 'dev', 'clean', '--path', appScaffold.appDir]) | ||
| const cleanOutput = cleanResult.stdout + cleanResult.stderr | ||
| expect(cleanResult.exitCode, '‼️ Step 5 - app dev clean failed').toBe(0) | ||
| expect(cleanOutput, '‼️ Step 5 - app dev clean: missing "Dev preview stopped" in output').toContain( | ||
| 'Dev preview stopped', | ||
| ) | ||
| } | ||
|
|
||
| // Step 6: Deploy the primary app | ||
| const versionTag = `QA-E2E-1st-${Date.now()}` | ||
| const deployResult = await cli.exec( | ||
| [ | ||
| 'app', | ||
| 'deploy', | ||
| '--path', | ||
| appScaffold.appDir, | ||
| '--force', | ||
| '--version', | ||
| versionTag, | ||
| '--message', | ||
| 'E2E basic flow deployment', | ||
| ], | ||
| {timeout: 5 * 60 * 1000}, | ||
| ) | ||
| expect(deployResult.exitCode, '‼️ Step 6 - app deploy failed').toBe(0) | ||
|
|
||
| // Step 7: List versions and verify our tag appears | ||
| const listResult = await cli.exec(['app', 'versions', 'list', '--path', appScaffold.appDir, '--json'], { | ||
| timeout: 60 * 1000, | ||
| }) | ||
| const listOutput = listResult.stdout + listResult.stderr | ||
| expect(listResult.exitCode, '‼️ Step 7 - app versions list failed').toBe(0) | ||
| expect(listOutput, `‼️ Step 7 - app versions list: missing version tag "${versionTag}"`).toContain(versionTag) | ||
|
|
||
| // Step 8: Config link to the secondary app | ||
| // Pre-create a minimal TOML stub so getTomls() finds the secondary client ID and skips | ||
| // the interactive "Configuration file name" prompt entirely. This avoids PTY timing races | ||
| // where the Enter key arrives before ink has fully initialized the text prompt, which | ||
| // causes renderTextPrompt to return '' → filenameFromName('') = 'shopify.app.toml' → | ||
| // that file already exists → overwrite confirmation prompt hangs. | ||
| // (--config and --client-id are mutually exclusive flags, so we can't pass both directly.) | ||
| fs.writeFileSync( | ||
| path.join(appScaffold.appDir, 'shopify.app.secondary.toml'), | ||
| `client_id = "${env.secondaryClientId}"\n`, | ||
| ) | ||
|
|
||
| const configLink = await cli.spawn( | ||
| ['app', 'config', 'link', '--path', appScaffold.appDir, '--client-id', env.secondaryClientId], | ||
| {env: {CI: '', SHOPIFY_FLAG_CLIENT_ID: undefined}}, | ||
| ) | ||
| await configLink.waitForOutput('is now linked to', 2 * 60 * 1000).catch((err: Error) => { | ||
| throw new Error(`‼️ Step 8 - app config link failed\n${err.message}`) | ||
| }) | ||
| const configLinkExitCode = await configLink.waitForExit(30_000) | ||
| expect(configLinkExitCode, '‼️ Step 8 - app config link failed').toBe(0) | ||
|
|
||
| // Step 9: Deploy to the secondary app using the linked config file | ||
| const secondaryVersionTag = `QA-E2E-2nd-${Date.now()}` | ||
| const secondaryDeployResult = await cli.exec( | ||
| [ | ||
| 'app', | ||
| 'deploy', | ||
| '--path', | ||
| appScaffold.appDir, | ||
| '--config', | ||
| 'secondary', | ||
| '--force', | ||
| '--version', | ||
| secondaryVersionTag, | ||
| '--message', | ||
| 'E2E secondary app deployment', | ||
| ], | ||
| {timeout: 5 * 60 * 1000, env: {SHOPIFY_FLAG_CLIENT_ID: undefined}}, | ||
phyllis-sy-wu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
| expect(secondaryDeployResult.exitCode, '‼️ Step 9 - app deploy (secondary) failed').toBe(0) | ||
| }) | ||
| }) | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.