From eea6be97b537d9a92e345ad2d476720b967826f2 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 14:58:02 -0500 Subject: [PATCH 01/14] Run the remote E2E tests on Linux, Windows and macOS for stable lines The remote E2E tests run on Linux only, and they can't fail a pull request. Release E2E runs them on Linux, Windows and macOS against every pull request into a stable line, and against any branch or tag on demand. Its gate job fails unless every system passed. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-e2e.yml | 189 ++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 .github/workflows/release-e2e.yml diff --git a/.github/workflows/release-e2e.yml b/.github/workflows/release-e2e.yml new file mode 100644 index 00000000000..bca6b698af9 --- /dev/null +++ b/.github/workflows/release-e2e.yml @@ -0,0 +1,189 @@ +name: Release E2E + +# Runs the remote E2E tests on Linux, Windows and macOS against every pull request into a stable +# line, so a release is tested on each system before it ships. The PR workflow runs the same tests +# on Linux only. The tests use real Shopify accounts and stores, through the same secrets as that +# workflow's E2E tests. +# +# `edited` covers a pull request retargeted to a stable line. It runs on every edit: skipping the +# gate on the others would record a skipped "Release E2E", which counts as passing and replaces the +# last run. +on: + pull_request: + types: [opened, synchronize, reopened, edited] + branches: + - 'stable/**' + workflow_dispatch: + inputs: + branch-or-tag: + description: 'Branch or tag to test, such as stable/5.2 or 5.2.0' + type: string + required: true + +permissions: + contents: read + +concurrency: + group: release-e2e-${{ github.event.pull_request.number || inputs.branch-or-tag }} + cancel-in-progress: true + +env: + DEBUG: '1' + SHOPIFY_CLI_ENV: development + PNPM_VERSION: '10.11.1' + # `playwright install chromium` hangs under Node 26. + PLAYWRIGHT_NODE_VERSION: '24.22.1' + +jobs: + commit: + name: Find the commit to test + runs-on: ubuntu-latest + timeout-minutes: 5 + outputs: + sha: ${{ steps.commit.outputs.sha }} + steps: + - name: Find the commit + id: commit + env: + EVENT: ${{ github.event_name }} + PULL_REQUEST_SHA: ${{ github.event.pull_request.head.sha }} + BRANCH_OR_TAG: ${{ inputs.branch-or-tag }} + run: | + set -euo pipefail + if [ "$EVENT" = pull_request ]; then + echo "sha=$PULL_REQUEST_SHA" >> "$GITHUB_OUTPUT" + exit 0 + fi + # Only a branch or tag of this repository, so a run never tests a fork's commit with this + # repository's secrets. Every system tests the commit it named when the run started. + REFS=$(git ls-remote "https://github.com/$GITHUB_REPOSITORY" "refs/heads/$BRANCH_OR_TAG" "refs/tags/$BRANCH_OR_TAG" "refs/tags/$BRANCH_OR_TAG^{}") + # An annotated tag lists both the tag object and, with ^{}, the commit it points to. + SHA=$(awk '$2 ~ /\^\{\}$/ {peeled = $1} {last = $1} END {print peeled ? peeled : last}' <<< "$REFS") + COUNT=$(awk '$2 !~ /\^\{\}$/' <<< "$REFS" | grep -c . || true) + if [ "$COUNT" -ne 1 ]; then + echo "::error::$BRANCH_OR_TAG must name exactly one branch or tag of $GITHUB_REPOSITORY; it names $COUNT." + exit 1 + fi + echo "Testing $BRANCH_OR_TAG at $SHA" + echo "sha=$SHA" >> "$GITHUB_OUTPUT" + + e2e: + name: E2E on ${{ matrix.system }} (shard ${{ matrix.shard }}) + needs: commit + # Fork pull requests get no secrets. The gate then fails, since a release can't skip these tests. + if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository + runs-on: ${{ matrix.os }} + # Leave room for setup, reports and cleanup after Playwright's global timeout. + timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + # App names and the cleanup pattern take their number from E2E_SHARD, so each job has its own + # `leg`: jobs with the same shard on two systems would share it, and one's cleanup could + # delete the other's apps. + # Windows and macOS create apps with npm, the default for new apps. Tests that choose a + # package manager themselves still use pnpm. + # The store lifecycle test runs on Linux only: each run needs a free store slot in the test + # organization. + include: + - {system: Linux, os: ubuntu-latest, shard: 1/2, leg: 1, package-manager: pnpm, skip: ''} + - {system: Linux, os: ubuntu-latest, shard: 2/2, leg: 2, package-manager: pnpm, skip: ''} + - {system: Windows, os: windows-latest, shard: 1/2, leg: 3, package-manager: npm, skip: store-lifecycle} + - {system: Windows, os: windows-latest, shard: 2/2, leg: 4, package-manager: npm, skip: store-lifecycle} + - {system: macOS, os: macos-latest, shard: 1/2, leg: 5, package-manager: npm, skip: store-lifecycle} + - {system: macOS, os: macos-latest, shard: 2/2, leg: 6, package-manager: npm, skip: store-lifecycle} + env: + E2E_ACCOUNT_EMAIL: ${{ secrets.E2E_ACCOUNT_EMAIL }} + E2E_ACCOUNT_PASSWORD: ${{ secrets.E2E_ACCOUNT_PASSWORD }} + E2E_ORG_ID: ${{ secrets.E2E_ORG_ID }} + E2E_LOADTEST_HEADER: ${{ secrets.E2E_LOADTEST_HEADER }} + E2E_SHARD: ${{ matrix.leg }}/6 + E2E_PACKAGE_MANAGER: ${{ matrix.package-manager }} + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ needs.commit.outputs.sha }} + fetch-depth: 1 + persist-credentials: false + + - name: Verify the checked-out commit + shell: bash + env: + SHA: ${{ needs.commit.outputs.sha }} + run: | + set -euo pipefail + HEAD_SHA=$(git rev-parse HEAD) + if [ "$HEAD_SHA" != "$SHA" ]; then + echo "::error::Checked out $HEAD_SHA instead of $SHA." + exit 1 + fi + + - name: Setup deps + uses: ./.github/actions/setup-cli-deps + with: + node-version: ${{ env.PLAYWRIGHT_NODE_VERSION }} + + - name: Build + run: pnpm nx run-many --all --target=build --output-style=stream + + - name: Install Playwright Chromium + run: pnpm exec playwright install chromium + working-directory: packages/e2e + + - name: Rebuild node-pty + run: pnpm rebuild node-pty + + # One retry, so a passing retry shows as flaky in the report instead of failing the release. + - name: Run E2E tests + id: e2e + shell: bash + working-directory: packages/e2e + env: + SHARD: ${{ matrix.shard }} + SKIP: ${{ matrix.skip }} + run: | + set -euo pipefail + ARGS=(--project remote --shard "$SHARD" --retries 1) + if [ -n "$SKIP" ]; then ARGS+=(--grep-invert "$SKIP"); fi + pnpm exec playwright test "${ARGS[@]}" + + - name: Upload Playwright report + uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: release-e2e-report-leg-${{ matrix.leg }} + # Playwright traces contain request headers and must not expose E2E_LOADTEST_HEADER. + path: | + packages/e2e/playwright-report/ + !packages/e2e/playwright-report/**/*.zip + retention-days: 14 + + - name: Upload test results + uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: release-e2e-results-leg-${{ matrix.leg }} + path: | + packages/e2e/test-results/ + !packages/e2e/test-results/**/trace.zip + retention-days: 14 + + - name: Clean up this job's E2E apps + if: ${{ always() && steps.e2e.outcome != 'skipped' }} + timeout-minutes: 5 + shell: bash + run: | + RUN_TOKEN=$(node -e "process.stdout.write(BigInt(process.env.GITHUB_RUN_ID).toString(36))") + SHARD_NUMBER=${E2E_SHARD%/*} + pnpm --filter e2e exec tsx scripts/cleanup-apps.ts --pattern "r${RUN_TOKEN}a${GITHUB_RUN_ATTEMPT}s${SHARD_NUMBER}-" + + gate: + name: Release E2E + needs: [commit, e2e] + if: always() + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Verify the tests passed on every system + if: needs.commit.result != 'success' || needs.e2e.result != 'success' + run: exit 1 From 08cfcd513348cd0c974a90b96a8c11aab3a75844 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 14:58:21 -0500 Subject: [PATCH 02/14] Run Release E2E on this draft pull request Temporary: a later commit removes this trigger before review. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-e2e.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release-e2e.yml b/.github/workflows/release-e2e.yml index bca6b698af9..9685ff1a671 100644 --- a/.github/workflows/release-e2e.yml +++ b/.github/workflows/release-e2e.yml @@ -13,6 +13,8 @@ on: types: [opened, synchronize, reopened, edited] branches: - 'stable/**' + # Draft only: runs the workflow on its own pull request. Removed before review. + - main workflow_dispatch: inputs: branch-or-tag: From 32ae01588539c0b0556cd87ca8b406a69010b2d4 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 15:08:12 -0500 Subject: [PATCH 03/14] Make node-pty's macOS spawn helper executable node-pty 1.1.0's macOS prebuilds ship spawn-helper without the execute bit, so every pseudo-terminal in the E2E tests failed to start with "posix_spawnp failed". Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-e2e.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/release-e2e.yml b/.github/workflows/release-e2e.yml index 9685ff1a671..40a488110e8 100644 --- a/.github/workflows/release-e2e.yml +++ b/.github/workflows/release-e2e.yml @@ -135,6 +135,13 @@ jobs: - name: Rebuild node-pty run: pnpm rebuild node-pty + # node-pty's published macOS prebuilds ship spawn-helper without the execute bit, so every + # pseudo-terminal would fail to start with "posix_spawnp failed". + - name: Make node-pty's spawn helper executable + if: runner.os == 'macOS' + working-directory: packages/e2e + run: chmod +x "$(node -p "require('path').dirname(require.resolve('node-pty/package.json'))")"/prebuilds/darwin-*/spawn-helper + # One retry, so a passing retry shows as flaky in the report instead of failing the release. - name: Run E2E tests id: e2e From 546f0a7b897712a07cd8537dc538df036bc1bd91 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 15:09:12 -0500 Subject: [PATCH 04/14] Try spawning pseudo-terminals with Node's own path (draft only) On Windows, node-pty looks up the command on PATH as a file named exactly "node", without adding .exe, so it can't start the CLI. This tries the harness fix on Windows and macOS; the change itself goes to the E2E package upstream, and a later commit reverts it here. Co-Authored-By: Claude Opus 5.5 --- packages/e2e/setup/cli.ts | 2 +- packages/e2e/setup/global-auth.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/e2e/setup/cli.ts b/packages/e2e/setup/cli.ts index a81817bc858..7e2ff41841a 100644 --- a/packages/e2e/setup/cli.ts +++ b/packages/e2e/setup/cli.ts @@ -134,7 +134,7 @@ export const cliFixture = envFixture.extend<{cli: CLIProcess}>({ cliLog.log(env, `spawn: node ${executables.cli}`) cliLog.log(env, args.join(' ')) - const ptyProcess = nodePty.spawn('node', [executables.cli, ...args], { + const ptyProcess = nodePty.spawn(process.execPath, [executables.cli, ...args], { name: 'xterm-color', cols: 120, rows: 30, diff --git a/packages/e2e/setup/global-auth.ts b/packages/e2e/setup/global-auth.ts index 0ac051d63d1..d9f72b1bc36 100644 --- a/packages/e2e/setup/global-auth.ts +++ b/packages/e2e/setup/global-auth.ts @@ -121,7 +121,7 @@ async function authenticateOnce({ let ptyProcess: IPty try { const nodePty = await import('node-pty') - ptyProcess = nodePty.spawn('node', [executables.cli, 'auth', 'login'], { + ptyProcess = nodePty.spawn(process.execPath, [executables.cli, 'auth', 'login'], { name: 'xterm-color', cols: 120, rows: 30, From 7c8dccfefb409dc3004fafb053344b6fba21109f Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 15:26:35 -0500 Subject: [PATCH 05/14] Try matching the app config path whatever its separators (draft only) app dev ignored edits to shopify.app.toml on Windows in the E2E tests: chokidar reports backslash paths there, and the file watcher compared them with the configuration path as they were. This tries the fix on Windows; the change itself goes upstream, and a later commit reverts it here. Co-Authored-By: Claude Opus 5.5 --- packages/app/src/cli/services/dev/app-events/file-watcher.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/app/src/cli/services/dev/app-events/file-watcher.ts b/packages/app/src/cli/services/dev/app-events/file-watcher.ts index 177b7fdd1c5..cc253ea062e 100644 --- a/packages/app/src/cli/services/dev/app-events/file-watcher.ts +++ b/packages/app/src/cli/services/dev/app-events/file-watcher.ts @@ -290,7 +290,7 @@ export class FileWatcher { private readonly handleFileEvent = (event: string, path: string) => { const startTime = startHRTime() const normalizedPath = normalizePath(path) - const isConfigAppPath = path === this.app.configPath + const isConfigAppPath = normalizedPath === normalizePath(this.app.configPath) const isExtensionToml = path.endsWith('.extension.toml') outputDebug(`🌀: ${event} ${path.replace(this.app.directory, '')}\n`) @@ -370,7 +370,7 @@ export class FileWatcher { extensionHandle?: string, ) { const isExtensionToml = path.endsWith('.extension.toml') - const isConfigAppPath = path === this.app.configPath + const isConfigAppPath = normalizePath(path) === normalizePath(this.app.configPath) switch (event) { case 'change': From 1d3f4164f760c5a9fdbb6341c649624e41ccbd99 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 15:49:02 -0500 Subject: [PATCH 06/14] Try the new E2E cases on every system (draft only) Function build and run, app info, app dev on a React Router app with app execute, GraphiQL and app logs, and Hydrogen init and build. The cases go to the E2E package upstream, and a later commit reverts them here. Co-Authored-By: Claude Opus 5.5 --- packages/e2e/README.md | 2 +- packages/e2e/setup/admin-api.ts | 2 +- packages/e2e/setup/app.ts | 8 +- packages/e2e/setup/constants.ts | 2 +- .../e2e/tests/app-dev-react-router.spec.ts | 121 ++++++++++++++++++ packages/e2e/tests/app-function.spec.ts | 89 +++++++++++++ packages/e2e/tests/hydrogen.spec.ts | 59 +++++++++ 7 files changed, 277 insertions(+), 6 deletions(-) create mode 100644 packages/e2e/tests/app-dev-react-router.spec.ts create mode 100644 packages/e2e/tests/app-function.spec.ts create mode 100644 packages/e2e/tests/hydrogen.spec.ts diff --git a/packages/e2e/README.md b/packages/e2e/README.md index e8ccdb4d168..7c4bebf3833 100644 --- a/packages/e2e/README.md +++ b/packages/e2e/README.md @@ -12,7 +12,7 @@ App tests reuse existing stores. They never create or delete a store. Each test Create dedicated development stores once in the E2E organization and give the E2E account access. Use the `no-delete-e2e-` name prefix: the store cleanup script refuses to delete these stores, including in `--force` mode. -The store domains are defined in `E2E_STORES` in `setup/constants.ts`. Each of the seven dev cases selects a named store directly; store 8 is spare. Adding a test requires an explicit assignment, with no worker or shard allocation. +The store domains are defined in `E2E_STORES` in `setup/constants.ts`. Each of the eight dev cases selects a named store directly; none is spare. Adding a test requires an explicit assignment, with no worker or shard allocation. Copy `.env.example` to `.env` and supply the account, organization, and load-test header. Set `E2E_STORE_FQDN` to override the fixed assignments for local development. The test account must have access to the selected store. diff --git a/packages/e2e/setup/admin-api.ts b/packages/e2e/setup/admin-api.ts index 13a8060d48a..60f54f75163 100644 --- a/packages/e2e/setup/admin-api.ts +++ b/packages/e2e/setup/admin-api.ts @@ -9,7 +9,7 @@ import {stripAnsi} from '../helpers/strip-ansi.js' import type {CLIProcess} from './cli.js' /** Admin API version for harness-side GraphQL requests. */ -const ADMIN_API_VERSION = '2026-04' +export const ADMIN_API_VERSION = '2026-04' interface AdminApiUninstallCtx { cli: Pick diff --git a/packages/e2e/setup/app.ts b/packages/e2e/setup/app.ts index 563764c4fa1..aee3ae9df20 100644 --- a/packages/e2e/setup/app.ts +++ b/packages/e2e/setup/app.ts @@ -226,11 +226,13 @@ export async function functionBuild(ctx: CLIContext): Promise { export async function functionRun( ctx: CLIContext & { inputPath: string + /** The Function export to run, for Functions with more than one target. */ + exportName?: string }, ): Promise { - return ctx.cli.exec(['app', 'function', 'run', '--input', ctx.inputPath, '--path', ctx.appDir], { - timeout: CLI_TIMEOUT.short, - }) + const args = ['app', 'function', 'run', '--input', ctx.inputPath, '--path', ctx.appDir] + if (ctx.exportName) args.push('--export', ctx.exportName) + return ctx.cli.exec(args, {timeout: CLI_TIMEOUT.short}) } export async function versionsList( diff --git a/packages/e2e/setup/constants.ts b/packages/e2e/setup/constants.ts index ac277d555a4..a9ba731c426 100644 --- a/packages/e2e/setup/constants.ts +++ b/packages/e2e/setup/constants.ts @@ -6,7 +6,7 @@ export const E2E_STORES = { namedConfig: 'no-delete-e2e-reusable-store-5.myshopify.com', defaultConfig: 'no-delete-e2e-reusable-store-6.myshopify.com', fullConfig: 'no-delete-e2e-reusable-store-7.myshopify.com', - spare: 'no-delete-e2e-reusable-store-8.myshopify.com', + reactRouterDev: 'no-delete-e2e-reusable-store-8.myshopify.com', } as const // --------------------------------------------------------------------------- diff --git a/packages/e2e/tests/app-dev-react-router.spec.ts b/packages/e2e/tests/app-dev-react-router.spec.ts new file mode 100644 index 00000000000..fd6e5f54953 --- /dev/null +++ b/packages/e2e/tests/app-dev-react-router.spec.ts @@ -0,0 +1,121 @@ +/* eslint-disable no-restricted-imports, no-restricted-globals -- the test reads the dev GraphiQL server directly */ +import {appTestFixture as test, createApp, devDashboardAppUrl} from '../setup/app.js' +import {ADMIN_API_VERSION} from '../setup/admin-api.js' +import {teardownAll} from '../setup/teardown.js' +import {E2E_STORES, CLI_TIMEOUT} from '../setup/constants.js' +import {e2eAppName, requireEnv} from '../setup/env.js' +import {expect} from '@playwright/test' +import {randomBytes} from 'crypto' +import * as fs from 'fs' +import * as path from 'path' + +const SHOP_NAME_QUERY = 'query { shop { name } }' + +test.describe('App dev with a React Router app', () => { + test('dev runs the web commands, and app execute, GraphiQL and app logs reach the store', async ({ + cli, + env, + dashboard, + }) => { + const storeFqdn = env.storeFqdn || E2E_STORES.reactRouterDev + // Creating the app installs its dependencies, and dev then runs its web commands. + test.setTimeout(15 * 60_000) + requireEnv(env, 'orgId') + + const parentDir = fs.mkdtempSync(path.join(env.tempDir, 'app-')) + const appName = e2eAppName('rrdv') + const graphiqlKey = randomBytes(16).toString('hex') + const graphiqlPort = env.processEnv.SHOPIFY_FLAG_GRAPHIQL_PORT + let appUrl: string | undefined + let appDir: string | undefined + + try { + // The TypeScript template runs its web commands with npx and npm, which app dev starts. + const initResult = await createApp({ + cli, + parentDir, + name: appName, + template: 'reactRouter', + flavor: 'typescript', + orgId: env.orgId, + }) + expect(initResult.exitCode, `createApp failed:\nstdout: ${initResult.stdout}\nstderr: ${initResult.stderr}`).toBe( + 0, + ) + appDir = initResult.appDir + appUrl = await devDashboardAppUrl({cli, appDir, orgId: env.orgId}) + + const dev = await cli.spawn(['app', 'dev', '--path', appDir], { + env: {CI: '', SHOPIFY_FLAG_STORE: storeFqdn, SHOPIFY_FLAG_GRAPHIQL_KEY: graphiqlKey}, + }) + + try { + // `prisma generate` is the template's predev command. + await dev.waitForOutput('Generated Prisma Client', CLI_TIMEOUT.long) + await dev.waitForOutput('Ready, watching for changes in your app', CLI_TIMEOUT.long) + + const executeResult = await cli.exec([ + 'app', + 'execute', + '--query', + SHOP_NAME_QUERY, + '--store', + storeFqdn, + '--json', + '--path', + appDir, + ]) + expect( + executeResult.exitCode, + `app execute failed:\nstdout: ${executeResult.stdout}\nstderr: ${executeResult.stderr}`, + ).toBe(0) + const shopName = JSON.parse(executeResult.stdout).data?.shop?.name + expect(shopName, `app execute returned no shop name:\n${executeResult.stdout}`).toBeTruthy() + + const graphiqlUrl = `http://localhost:${graphiqlPort}/graphiql/graphql.json?key=${graphiqlKey}&api_version=${ADMIN_API_VERSION}` + const graphiqlResponse = await fetch(graphiqlUrl, { + method: 'POST', + headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({query: SHOP_NAME_QUERY}), + signal: AbortSignal.timeout(CLI_TIMEOUT.short), + }) + const graphiqlBody = await graphiqlResponse.text() + expect(graphiqlResponse.status, `GraphiQL request failed:\n${graphiqlBody}`).toBe(200) + expect(JSON.parse(graphiqlBody).data?.shop?.name).toBe(shopName) + + const logsResult = await cli.exec(['app', 'logs', '--json', '--limit', '5', '--path', appDir]) + expect( + logsResult.exitCode, + `app logs failed:\nstdout: ${logsResult.stdout}\nstderr: ${logsResult.stderr}`, + ).toBe(0) + expect( + Array.isArray(JSON.parse(logsResult.stdout).logs), + `app logs printed no logs list:\n${logsResult.stdout}`, + ).toBe(true) + + dev.sendKey('q') + const exitCode = await dev.waitForExit(CLI_TIMEOUT.short) + expect(exitCode, `dev exited with non-zero code. Output:\n${dev.getOutput()}`).toBe(0) + } catch (error) { + // eslint-disable-next-line no-console + console.error(`[react-router dev] Captured PTY output:\n${dev.getOutput()}`) + throw error + } + } finally { + // E2E_SKIP_TEARDOWN=1 skips teardown for debugging. Run cleanup scripts afterward. + if (!process.env.E2E_SKIP_TEARDOWN) { + await teardownAll({ + cli, + dashboard, + appName, + appUrl, + appDir, + orgId: env.orgId, + storeFqdn, + workerIndex: env.workerIndex, + }) + fs.rmSync(parentDir, {recursive: true, force: true}) + } + } + }) +}) diff --git a/packages/e2e/tests/app-function.spec.ts b/packages/e2e/tests/app-function.spec.ts new file mode 100644 index 00000000000..bd6f530af52 --- /dev/null +++ b/packages/e2e/tests/app-function.spec.ts @@ -0,0 +1,89 @@ +/* eslint-disable no-restricted-imports */ +import { + appInfo, + appTestFixture as test, + createApp, + devDashboardAppUrl, + functionBuild, + functionRun, + generateExtension, +} from '../setup/app.js' +import {teardownAll} from '../setup/teardown.js' +import {TEST_TIMEOUT} from '../setup/constants.js' +import {e2eAppName, requireEnv} from '../setup/env.js' +import {expect} from '@playwright/test' +import * as fs from 'fs' +import * as path from 'path' + +const FUNCTION_NAME = 'e2e-discount' + +// One cart line and every discount class, for the discount Function's cart lines target. +const DISCOUNT_INPUT = { + cart: {lines: [{id: 'gid://shopify/CartLine/0', cost: {subtotalAmount: {amount: '10.0'}}}]}, + discount: {discountClasses: ['PRODUCT', 'ORDER', 'SHIPPING']}, +} + +test.describe('App functions', () => { + test('builds and runs a discount Function, and app info lists it', async ({cli, env, dashboard}) => { + test.setTimeout(TEST_TIMEOUT.long) + requireEnv(env, 'orgId') + + const parentDir = fs.mkdtempSync(path.join(env.tempDir, 'app-')) + const appName = e2eAppName('func') + let appUrl: string | undefined + + try { + const initResult = await createApp({cli, parentDir, name: appName, template: 'none', orgId: env.orgId}) + expect(initResult.exitCode, `createApp failed:\nstderr: ${initResult.stderr}`).toBe(0) + const appDir = initResult.appDir + appUrl = await devDashboardAppUrl({cli, appDir, orgId: env.orgId}) + + const generateResult = await generateExtension({ + cli, + appDir, + name: FUNCTION_NAME, + template: 'discount', + flavor: 'typescript', + }) + expect( + generateResult.exitCode, + `generateExtension failed:\nstdout: ${generateResult.stdout}\nstderr: ${generateResult.stderr}`, + ).toBe(0) + + const functionDir = path.join(appDir, 'extensions', FUNCTION_NAME) + const buildResult = await functionBuild({cli, appDir: functionDir}) + expect( + buildResult.exitCode, + `function build failed:\nstdout: ${buildResult.stdout}\nstderr: ${buildResult.stderr}`, + ).toBe(0) + + const inputPath = path.join(parentDir, 'discount-input.json') + fs.writeFileSync(inputPath, JSON.stringify(DISCOUNT_INPUT)) + const runResult = await functionRun({ + cli, + appDir: functionDir, + inputPath, + exportName: 'cart-lines-discounts-generate-run', + }) + expect(runResult.exitCode, `function run failed:\nstdout: ${runResult.stdout}\nstderr: ${runResult.stderr}`).toBe( + 0, + ) + expect(runResult.stdout, 'function run should print the discount operations').toContain('operations') + + const info = await appInfo({cli, appDir}) + expect(info.allExtensions.map((extension) => extension.configuration.handle)).toContain(FUNCTION_NAME) + } finally { + // E2E_SKIP_TEARDOWN=1 skips teardown for debugging. Run cleanup scripts afterward. + if (!process.env.E2E_SKIP_TEARDOWN) { + fs.rmSync(parentDir, {recursive: true, force: true}) + await teardownAll({ + dashboard, + appName, + appUrl, + orgId: env.orgId, + workerIndex: env.workerIndex, + }) + } + } + }) +}) diff --git a/packages/e2e/tests/hydrogen.spec.ts b/packages/e2e/tests/hydrogen.spec.ts new file mode 100644 index 00000000000..88f7cc2480b --- /dev/null +++ b/packages/e2e/tests/hydrogen.spec.ts @@ -0,0 +1,59 @@ +/* eslint-disable no-restricted-imports */ +import {cliFixture as test} from '../setup/cli.js' +import {CLI_TIMEOUT, TEST_TIMEOUT} from '../setup/constants.js' +import {expect} from '@playwright/test' +import * as fs from 'fs' +import * as os from 'os' +import * as path from 'path' + +test.describe('Hydrogen', () => { + test('init creates a mock.shop storefront that builds', async ({cli}) => { + test.setTimeout(TEST_TIMEOUT.long) + + // Outside this repository, so the package manager doesn't treat the storefront as part of the + // repository's workspace. + const parentDir = fs.mkdtempSync(path.join(os.tmpdir(), 'e2e-hydrogen-')) + const storefrontDir = path.join(parentDir, 'storefront') + const packageManager = process.env.E2E_PACKAGE_MANAGER ?? 'pnpm' + + try { + const initResult = await cli.exec( + [ + 'hydrogen', + 'init', + '--path', + storefrontDir, + '--mock-shop', + '--language', + 'ts', + '--styling', + 'none', + '--markets', + 'none', + '--no-shortcut', + '--no-git', + '--install-deps', + '--package-manager', + packageManager, + ], + {timeout: CLI_TIMEOUT.long}, + ) + expect( + initResult.exitCode, + `hydrogen init failed:\nstdout: ${initResult.stdout}\nstderr: ${initResult.stderr}`, + ).toBe(0) + expect(fs.existsSync(path.join(storefrontDir, 'node_modules')), 'hydrogen init should install dependencies').toBe( + true, + ) + + const buildResult = await cli.exec(['hydrogen', 'build', '--path', storefrontDir], {timeout: CLI_TIMEOUT.long}) + expect( + buildResult.exitCode, + `hydrogen build failed:\nstdout: ${buildResult.stdout}\nstderr: ${buildResult.stderr}`, + ).toBe(0) + expect(fs.existsSync(path.join(storefrontDir, 'dist')), 'hydrogen build should write dist').toBe(true) + } finally { + fs.rmSync(parentDir, {recursive: true, force: true}) + } + }) +}) From bc7b44b486327ba6e2e4b36b741a9381a0ac65c2 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 16:08:36 -0500 Subject: [PATCH 07/14] Try the fixed cases, the extension serving case and the local project (draft only) The React Router test waits for the web dev server, Hydrogen installs with pnpm, and a new case checks that app dev serves an admin action and the theme app extension preview. The workflow also runs the local project, which needs no account. A later commit reverts the test changes here; they go to the E2E package upstream. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-e2e.yml | 6 +- packages/e2e/tests/app-dev-extensions.spec.ts | 115 ++++++++++++++++++ .../e2e/tests/app-dev-react-router.spec.ts | 12 +- packages/e2e/tests/hydrogen.spec.ts | 11 +- 4 files changed, 133 insertions(+), 11 deletions(-) create mode 100644 packages/e2e/tests/app-dev-extensions.spec.ts diff --git a/.github/workflows/release-e2e.yml b/.github/workflows/release-e2e.yml index 40a488110e8..b572bb0e631 100644 --- a/.github/workflows/release-e2e.yml +++ b/.github/workflows/release-e2e.yml @@ -142,7 +142,9 @@ jobs: working-directory: packages/e2e run: chmod +x "$(node -p "require('path').dirname(require.resolve('node-pty/package.json'))")"/prebuilds/darwin-*/spawn-helper - # One retry, so a passing retry shows as flaky in the report instead of failing the release. + # The local project needs no account. It checks the harness and the CLI's basics, such as + # starting a pseudo-terminal, on each system. One retry, so a passing retry shows as flaky in + # the report instead of failing the release. - name: Run E2E tests id: e2e shell: bash @@ -152,7 +154,7 @@ jobs: SKIP: ${{ matrix.skip }} run: | set -euo pipefail - ARGS=(--project remote --shard "$SHARD" --retries 1) + ARGS=(--project local --project remote --shard "$SHARD" --retries 1) if [ -n "$SKIP" ]; then ARGS+=(--grep-invert "$SKIP"); fi pnpm exec playwright test "${ARGS[@]}" diff --git a/packages/e2e/tests/app-dev-extensions.spec.ts b/packages/e2e/tests/app-dev-extensions.spec.ts new file mode 100644 index 00000000000..7885b893398 --- /dev/null +++ b/packages/e2e/tests/app-dev-extensions.spec.ts @@ -0,0 +1,115 @@ +/* eslint-disable no-restricted-imports, no-restricted-globals -- the test reads the dev servers directly */ +import {appTestFixture as test, createApp, devDashboardAppUrl, generateExtension} from '../setup/app.js' +import {teardownAll} from '../setup/teardown.js' +import {E2E_STORES, CLI_TIMEOUT, TEST_TIMEOUT} from '../setup/constants.js' +import {e2eAppName, requireEnv} from '../setup/env.js' +import {expect} from '@playwright/test' +import * as fs from 'fs' +import * as path from 'path' + +const ADMIN_ACTION = 'e2e-admin-action' +const THEME_EXTENSION = 'e2e-theme-ext' +const READY_MESSAGE = 'Ready, watching for changes in your app' +const PASSWORD_PROMPT = 'store password' + +interface ExtensionsPayload { + extensions: {handle: string; assets: {main: {url: string}}}[] +} + +async function fetchOk(url: string): Promise<{status: number; contentType: string; body: string}> { + const response = await fetch(url, {signal: AbortSignal.timeout(CLI_TIMEOUT.short)}) + return {status: response.status, contentType: response.headers.get('content-type') ?? '', body: await response.text()} +} + +test.describe('App dev serves extensions', () => { + test('dev builds and serves the admin action and the theme app extension preview', async ({cli, env, dashboard}) => { + const storeFqdn = env.storeFqdn || E2E_STORES.devServer + test.setTimeout(TEST_TIMEOUT.long) + requireEnv(env, 'orgId') + + const parentDir = fs.mkdtempSync(path.join(env.tempDir, 'app-')) + const appName = e2eAppName('dext') + const themeExtensionPort = env.processEnv.SHOPIFY_FLAG_THEME_APP_EXTENSION_PORT + let appUrl: string | undefined + let appDir: string | undefined + + try { + const initResult = await createApp({cli, parentDir, name: appName, template: 'none', orgId: env.orgId}) + expect(initResult.exitCode, `createApp failed:\nstderr: ${initResult.stderr}`).toBe(0) + appDir = initResult.appDir + appUrl = await devDashboardAppUrl({cli, appDir, orgId: env.orgId}) + + for (const extension of [ + {name: ADMIN_ACTION, template: 'admin_action', flavor: 'preact'}, + {name: THEME_EXTENSION, template: 'theme_app_extension'}, + ]) { + // eslint-disable-next-line no-await-in-loop + const result = await generateExtension({cli, appDir, ...extension}) + expect( + result.exitCode, + `generateExtension "${extension.name}" failed:\nstdout: ${result.stdout}\nstderr: ${result.stderr}`, + ).toBe(0) + } + + const dev = await cli.spawn(['app', 'dev', '--path', appDir], {env: {CI: '', SHOPIFY_FLAG_STORE: storeFqdn}}) + + try { + // The theme app extension preview asks for the storefront password of a protected store. + const waiting = new AbortController() + const ready = dev + .waitForOutput(READY_MESSAGE, {timeoutMs: CLI_TIMEOUT.long, signal: waiting.signal}) + .then(() => 'ready' as const) + const passwordPrompt = dev + .waitForOutput(PASSWORD_PROMPT, {timeoutMs: CLI_TIMEOUT.long, signal: waiting.signal}) + .then(() => 'password' as const) + ready.catch(() => {}) + passwordPrompt.catch(() => {}) + const first = await Promise.race([ready, passwordPrompt]).finally(() => waiting.abort()) + expect(first, `app dev asked for the storefront password of ${storeFqdn}`).toBe('ready') + + // The admin action's bundle, through the dev proxy, as the admin loads it. + const proxyPort = dev.getOutput().match(/Proxy server started on port (\d+)/)?.[1] + expect(proxyPort, 'app dev should print the proxy port').toBeTruthy() + const payload = await fetchOk(`http://localhost:${proxyPort}/extensions`) + expect(payload.status, `GET /extensions failed:\n${payload.body}`).toBe(200) + const adminAction = (JSON.parse(payload.body) as ExtensionsPayload).extensions.find( + (extension) => extension.handle === ADMIN_ACTION, + ) + expect(adminAction, `the dev server should list ${ADMIN_ACTION}:\n${payload.body}`).toBeDefined() + const bundlePath = new URL(adminAction!.assets.main.url).pathname + const bundle = await fetchOk(`http://localhost:${proxyPort}${bundlePath}`) + expect(bundle.status, `GET ${bundlePath} failed:\n${bundle.body.slice(0, 500)}`).toBe(200) + expect(bundle.contentType).toContain('javascript') + expect(bundle.body.length).toBeGreaterThan(0) + + // The theme app extension preview server. + const preview = await fetchOk(`http://127.0.0.1:${themeExtensionPort}/`) + expect(preview.status, `GET the theme app extension preview failed:\n${preview.body.slice(0, 500)}`).toBe(200) + expect(preview.contentType).toContain('text/html') + + dev.sendKey('q') + const exitCode = await dev.waitForExit(CLI_TIMEOUT.short) + expect(exitCode, `dev exited with non-zero code. Output:\n${dev.getOutput()}`).toBe(0) + } catch (error) { + // eslint-disable-next-line no-console + console.error(`[dev extensions] Captured PTY output:\n${dev.getOutput()}`) + throw error + } + } finally { + // E2E_SKIP_TEARDOWN=1 skips teardown for debugging. Run cleanup scripts afterward. + if (!process.env.E2E_SKIP_TEARDOWN) { + await teardownAll({ + cli, + dashboard, + appName, + appUrl, + appDir, + orgId: env.orgId, + storeFqdn, + workerIndex: env.workerIndex, + }) + fs.rmSync(parentDir, {recursive: true, force: true}) + } + } + }) +}) diff --git a/packages/e2e/tests/app-dev-react-router.spec.ts b/packages/e2e/tests/app-dev-react-router.spec.ts index fd6e5f54953..c337bab31ea 100644 --- a/packages/e2e/tests/app-dev-react-router.spec.ts +++ b/packages/e2e/tests/app-dev-react-router.spec.ts @@ -30,7 +30,7 @@ test.describe('App dev with a React Router app', () => { let appDir: string | undefined try { - // The TypeScript template runs its web commands with npx and npm, which app dev starts. + // The TypeScript template's web commands use npx and npm, whichever package manager the app uses. const initResult = await createApp({ cli, parentDir, @@ -50,8 +50,11 @@ test.describe('App dev with a React Router app', () => { }) try { - // `prisma generate` is the template's predev command. - await dev.waitForOutput('Generated Prisma Client', CLI_TIMEOUT.long) + // The web dev command, `npx prisma migrate deploy && npm exec react-router dev`, gets as far as + // the dev server only if app dev can start npx and npm. + await dev.waitForOutput('Running pre-dev command', CLI_TIMEOUT.long) + await dev.waitForOutput('All migrations have been successfully applied', CLI_TIMEOUT.long) + await dev.waitForOutput('Local: http://localhost:', CLI_TIMEOUT.long) await dev.waitForOutput('Ready, watching for changes in your app', CLI_TIMEOUT.long) const executeResult = await cli.exec([ @@ -114,7 +117,8 @@ test.describe('App dev with a React Router app', () => { storeFqdn, workerIndex: env.workerIndex, }) - fs.rmSync(parentDir, {recursive: true, force: true}) + // Windows can hold files for a moment after dev's web processes exit. + fs.rmSync(parentDir, {recursive: true, force: true, maxRetries: 10, retryDelay: 500}) } } }) diff --git a/packages/e2e/tests/hydrogen.spec.ts b/packages/e2e/tests/hydrogen.spec.ts index 88f7cc2480b..7acca1ca2b8 100644 --- a/packages/e2e/tests/hydrogen.spec.ts +++ b/packages/e2e/tests/hydrogen.spec.ts @@ -10,11 +10,11 @@ test.describe('Hydrogen', () => { test('init creates a mock.shop storefront that builds', async ({cli}) => { test.setTimeout(TEST_TIMEOUT.long) - // Outside this repository, so the package manager doesn't treat the storefront as part of the - // repository's workspace. + // Outside this repository, so pnpm doesn't treat the storefront as part of the repository's + // workspace. pnpm whatever the job's package manager: with npm, hydrogen init didn't finish within + // 5 minutes on Windows, and the app tests already cover npm. const parentDir = fs.mkdtempSync(path.join(os.tmpdir(), 'e2e-hydrogen-')) const storefrontDir = path.join(parentDir, 'storefront') - const packageManager = process.env.E2E_PACKAGE_MANAGER ?? 'pnpm' try { const initResult = await cli.exec( @@ -34,7 +34,7 @@ test.describe('Hydrogen', () => { '--no-git', '--install-deps', '--package-manager', - packageManager, + 'pnpm', ], {timeout: CLI_TIMEOUT.long}, ) @@ -53,7 +53,8 @@ test.describe('Hydrogen', () => { ).toBe(0) expect(fs.existsSync(path.join(storefrontDir, 'dist')), 'hydrogen build should write dist').toBe(true) } finally { - fs.rmSync(parentDir, {recursive: true, force: true}) + // Windows can hold files for a moment after the processes that used them exit. + fs.rmSync(parentDir, {recursive: true, force: true, maxRetries: 10, retryDelay: 500}) } }) }) From 38c542d8c740f2f05babba615a74b6bd6aab8762 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 16:20:55 -0500 Subject: [PATCH 08/14] Try the admin action case, longer login retries and the local project once per system (draft only) The serving case checks only the admin action, since the theme app extension preview needs the store's storefront password. The local project runs whole on each system's first shard, so the remote shards stay even. Release runs retry the login 4 times, 30 seconds apart. A later commit reverts the E2E package changes here. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-e2e.yml | 19 ++++-- packages/e2e/setup/auth-diagnostics.ts | 45 ++++++++++++-- packages/e2e/setup/global-auth.ts | 11 +++- packages/e2e/tests/app-dev-extensions.spec.ts | 59 +++++++------------ packages/e2e/tests/auth-diagnostics.spec.ts | 49 +++++++++++++-- 5 files changed, 128 insertions(+), 55 deletions(-) diff --git a/.github/workflows/release-e2e.yml b/.github/workflows/release-e2e.yml index b572bb0e631..6bd6609e927 100644 --- a/.github/workflows/release-e2e.yml +++ b/.github/workflows/release-e2e.yml @@ -101,6 +101,10 @@ jobs: E2E_LOADTEST_HEADER: ${{ secrets.E2E_LOADTEST_HEADER }} E2E_SHARD: ${{ matrix.leg }}/6 E2E_PACKAGE_MANAGER: ${{ matrix.package-manager }} + # A failed login fails every test in the job, so a release run retries it longer than the PR + # workflow does. + E2E_AUTH_ATTEMPTS: '4' + E2E_AUTH_RETRY_DELAY_MS: '30000' steps: - uses: actions/checkout@v6 with: @@ -143,10 +147,17 @@ jobs: run: chmod +x "$(node -p "require('path').dirname(require.resolve('node-pty/package.json'))")"/prebuilds/darwin-*/spawn-helper # The local project needs no account. It checks the harness and the CLI's basics, such as - # starting a pseudo-terminal, on each system. One retry, so a passing retry shows as flaky in - # the report instead of failing the release. - - name: Run E2E tests + # starting a pseudo-terminal, on each system. It runs whole, once per system, so the remote + # shards stay even. One retry for both, so a passing retry shows as flaky in the report + # instead of failing the release. + - name: Run local E2E tests + if: matrix.shard == '1/2' + working-directory: packages/e2e + run: pnpm exec playwright test --project local --retries 1 + + - name: Run remote E2E tests id: e2e + if: ${{ !cancelled() }} shell: bash working-directory: packages/e2e env: @@ -154,7 +165,7 @@ jobs: SKIP: ${{ matrix.skip }} run: | set -euo pipefail - ARGS=(--project local --project remote --shard "$SHARD" --retries 1) + ARGS=(--project remote --shard "$SHARD" --retries 1) if [ -n "$SKIP" ]; then ARGS+=(--grep-invert "$SKIP"); fi pnpm exec playwright test "${ARGS[@]}" diff --git a/packages/e2e/setup/auth-diagnostics.ts b/packages/e2e/setup/auth-diagnostics.ts index c3138f78c2d..7f66386ff99 100644 --- a/packages/e2e/setup/auth-diagnostics.ts +++ b/packages/e2e/setup/auth-diagnostics.ts @@ -8,6 +8,7 @@ export interface AuthConfig { interface NavigationResponse { ok(): boolean + status?(): number } interface UrlWaiter { @@ -18,16 +19,45 @@ export class AuthSetupError extends Error { readonly stage: AuthStage readonly reason: string readonly retryable: boolean + /** The HTTP status of a failed page load. The error carries nothing else from the response. */ + readonly status?: number - constructor(stage: AuthStage, reason: string) { - super(`[e2e][auth] failed stage=${stage} reason=${reason}`) + constructor(stage: AuthStage, reason: string, status?: number) { + super(`[e2e][auth] failed stage=${stage} reason=${reason}${status === undefined ? '' : ` status=${status}`}`) this.name = 'AuthSetupError' this.stage = stage this.reason = reason this.retryable = isRetryableAuthFailure(stage, reason) + this.status = status } } +export interface AuthRetryOptions { + maxAttempts: number + delayMs: number +} + +/** + * Attempts and delay for each authentication stage. E2E_AUTH_ATTEMPTS and E2E_AUTH_RETRY_DELAY_MS + * override the defaults of 2 attempts, 1 second apart. + */ +export function readAuthRetryOptions(env: NodeJS.ProcessEnv = process.env): AuthRetryOptions { + return { + maxAttempts: readIntegerSetting(env, 'E2E_AUTH_ATTEMPTS', 2, 1), + delayMs: readIntegerSetting(env, 'E2E_AUTH_RETRY_DELAY_MS', 1_000, 0), + } +} + +function readIntegerSetting(env: NodeJS.ProcessEnv, name: string, fallback: number, minimum: number): number { + const value = env[name]?.trim() + if (!value) return fallback + const parsed = Number(value) + if (!Number.isInteger(parsed) || parsed < minimum) { + throw new Error(`${name} must be a whole number of at least ${minimum}, not "${value}"`) + } + return parsed +} + export function readAuthConfig(env: NodeJS.ProcessEnv = process.env): AuthConfig { const requiredValues = { E2E_ACCOUNT_EMAIL: env.E2E_ACCOUNT_EMAIL, @@ -53,7 +83,8 @@ export function readAuthConfig(env: NodeJS.ProcessEnv = process.env): AuthConfig function isRetryableAuthFailure(stage: AuthStage, reason: string): boolean { return ( (stage === 'device-code-generation' && reason === 'timeout') || - (stage === 'browser-login' && (reason === 'page-load' || reason === 'cli-confirmation-timeout')) || + (stage === 'browser-login' && + (reason === 'page-load' || reason === 'login-form' || reason === 'cli-confirmation-timeout')) || (stage === 'session-prewarm' && reason.endsWith('-page-load')) ) } @@ -91,6 +122,7 @@ export async function runAuthStages({ complete, dispose, onRetry, + maxAttempts, delayMs, }: { authenticate: () => Promise @@ -98,11 +130,12 @@ export async function runAuthStages({ complete: (authenticatedSession: T) => Promise dispose: (authenticatedSession: T) => Promise onRetry?: (failure: AuthSetupError, nextAttempt: number) => void + maxAttempts?: number delayMs?: number }): Promise { - const authenticatedSession = await retryAuthOperation(authenticate, {onRetry, delayMs}) + const authenticatedSession = await retryAuthOperation(authenticate, {onRetry, maxAttempts, delayMs}) try { - await retryAuthOperation(() => prewarm(authenticatedSession), {onRetry, delayMs}) + await retryAuthOperation(() => prewarm(authenticatedSession), {onRetry, maxAttempts, delayMs}) await complete(authenticatedSession) } finally { await dispose(authenticatedSession) @@ -116,7 +149,7 @@ export async function requireSuccessfulNavigation( ): Promise { try { const response = await navigate() - if (!response?.ok()) throw new AuthSetupError(stage, reason) + if (!response?.ok()) throw new AuthSetupError(stage, reason, response?.status?.()) } catch (error) { if (error instanceof AuthSetupError) throw error throw new AuthSetupError(stage, reason) diff --git a/packages/e2e/setup/global-auth.ts b/packages/e2e/setup/global-auth.ts index d9f72b1bc36..2f91250203b 100644 --- a/packages/e2e/setup/global-auth.ts +++ b/packages/e2e/setup/global-auth.ts @@ -12,6 +12,7 @@ import { AuthSetupError, isExpectedAuthDestination, readAuthConfig, + readAuthRetryOptions, requireExpectedAuthDestination, requireSuccessfulNavigation, runAuthStages, @@ -45,6 +46,7 @@ interface AuthenticatedBrowserSession { export async function prepareGlobalAuth() { const {authDir, storageStatePath, xdgEnv} = authStatePaths() const authConfig = readAuthConfig() + const retryOptions = readAuthRetryOptions() globalLog('auth', 'starting') const processEnv: NodeJS.ProcessEnv = { @@ -76,19 +78,24 @@ export async function prepareGlobalAuth() { dispose: async ({browser}) => browser.close(), onRetry: (failure, nextAttempt) => { process.stdout.write( - `[e2e][auth] retry stage=${failure.stage} reason=${failure.reason} next_attempt=${nextAttempt}\n`, + `[e2e][auth] retry stage=${failure.stage} reason=${failure.reason}${statusSuffix(failure)} next_attempt=${nextAttempt}\n`, ) }, + ...retryOptions, }) } catch (error) { const failure = error instanceof AuthSetupError ? error : new AuthSetupError('browser-login', 'unexpected-error') - process.stderr.write(`[e2e][auth] failed stage=${failure.stage} reason=${failure.reason}\n`) + process.stderr.write(`[e2e][auth] failed stage=${failure.stage} reason=${failure.reason}${statusSuffix(failure)}\n`) throw failure } globalLog('auth', 'complete') } +function statusSuffix(failure: AuthSetupError): string { + return failure.status === undefined ? '' : ` status=${failure.status}` +} + function resetAuthDirectories(authDir: string, xdgEnv: Record): void { fs.rmSync(authDir, {recursive: true, force: true}) fs.mkdirSync(authDir, {recursive: true}) diff --git a/packages/e2e/tests/app-dev-extensions.spec.ts b/packages/e2e/tests/app-dev-extensions.spec.ts index 7885b893398..e3f0bacf527 100644 --- a/packages/e2e/tests/app-dev-extensions.spec.ts +++ b/packages/e2e/tests/app-dev-extensions.spec.ts @@ -1,4 +1,4 @@ -/* eslint-disable no-restricted-imports, no-restricted-globals -- the test reads the dev servers directly */ +/* eslint-disable no-restricted-imports, no-restricted-globals -- the test reads the dev proxy directly */ import {appTestFixture as test, createApp, devDashboardAppUrl, generateExtension} from '../setup/app.js' import {teardownAll} from '../setup/teardown.js' import {E2E_STORES, CLI_TIMEOUT, TEST_TIMEOUT} from '../setup/constants.js' @@ -8,28 +8,24 @@ import * as fs from 'fs' import * as path from 'path' const ADMIN_ACTION = 'e2e-admin-action' -const THEME_EXTENSION = 'e2e-theme-ext' -const READY_MESSAGE = 'Ready, watching for changes in your app' -const PASSWORD_PROMPT = 'store password' interface ExtensionsPayload { extensions: {handle: string; assets: {main: {url: string}}}[] } -async function fetchOk(url: string): Promise<{status: number; contentType: string; body: string}> { +async function get(url: string): Promise<{status: number; contentType: string; body: string}> { const response = await fetch(url, {signal: AbortSignal.timeout(CLI_TIMEOUT.short)}) return {status: response.status, contentType: response.headers.get('content-type') ?? '', body: await response.text()} } test.describe('App dev serves extensions', () => { - test('dev builds and serves the admin action and the theme app extension preview', async ({cli, env, dashboard}) => { + test('dev builds the admin action and serves its bundle', async ({cli, env, dashboard}) => { const storeFqdn = env.storeFqdn || E2E_STORES.devServer test.setTimeout(TEST_TIMEOUT.long) requireEnv(env, 'orgId') const parentDir = fs.mkdtempSync(path.join(env.tempDir, 'app-')) const appName = e2eAppName('dext') - const themeExtensionPort = env.processEnv.SHOPIFY_FLAG_THEME_APP_EXTENSION_PORT let appUrl: string | undefined let appDir: string | undefined @@ -39,54 +35,38 @@ test.describe('App dev serves extensions', () => { appDir = initResult.appDir appUrl = await devDashboardAppUrl({cli, appDir, orgId: env.orgId}) - for (const extension of [ - {name: ADMIN_ACTION, template: 'admin_action', flavor: 'preact'}, - {name: THEME_EXTENSION, template: 'theme_app_extension'}, - ]) { - // eslint-disable-next-line no-await-in-loop - const result = await generateExtension({cli, appDir, ...extension}) - expect( - result.exitCode, - `generateExtension "${extension.name}" failed:\nstdout: ${result.stdout}\nstderr: ${result.stderr}`, - ).toBe(0) - } + const generateResult = await generateExtension({ + cli, + appDir, + name: ADMIN_ACTION, + template: 'admin_action', + flavor: 'preact', + }) + expect( + generateResult.exitCode, + `generateExtension failed:\nstdout: ${generateResult.stdout}\nstderr: ${generateResult.stderr}`, + ).toBe(0) const dev = await cli.spawn(['app', 'dev', '--path', appDir], {env: {CI: '', SHOPIFY_FLAG_STORE: storeFqdn}}) try { - // The theme app extension preview asks for the storefront password of a protected store. - const waiting = new AbortController() - const ready = dev - .waitForOutput(READY_MESSAGE, {timeoutMs: CLI_TIMEOUT.long, signal: waiting.signal}) - .then(() => 'ready' as const) - const passwordPrompt = dev - .waitForOutput(PASSWORD_PROMPT, {timeoutMs: CLI_TIMEOUT.long, signal: waiting.signal}) - .then(() => 'password' as const) - ready.catch(() => {}) - passwordPrompt.catch(() => {}) - const first = await Promise.race([ready, passwordPrompt]).finally(() => waiting.abort()) - expect(first, `app dev asked for the storefront password of ${storeFqdn}`).toBe('ready') + await dev.waitForOutput('Ready, watching for changes in your app', CLI_TIMEOUT.long) - // The admin action's bundle, through the dev proxy, as the admin loads it. + // The bundle the admin loads for the action, through the dev proxy. const proxyPort = dev.getOutput().match(/Proxy server started on port (\d+)/)?.[1] expect(proxyPort, 'app dev should print the proxy port').toBeTruthy() - const payload = await fetchOk(`http://localhost:${proxyPort}/extensions`) + const payload = await get(`http://localhost:${proxyPort}/extensions`) expect(payload.status, `GET /extensions failed:\n${payload.body}`).toBe(200) const adminAction = (JSON.parse(payload.body) as ExtensionsPayload).extensions.find( (extension) => extension.handle === ADMIN_ACTION, ) expect(adminAction, `the dev server should list ${ADMIN_ACTION}:\n${payload.body}`).toBeDefined() const bundlePath = new URL(adminAction!.assets.main.url).pathname - const bundle = await fetchOk(`http://localhost:${proxyPort}${bundlePath}`) + const bundle = await get(`http://localhost:${proxyPort}${bundlePath}`) expect(bundle.status, `GET ${bundlePath} failed:\n${bundle.body.slice(0, 500)}`).toBe(200) expect(bundle.contentType).toContain('javascript') expect(bundle.body.length).toBeGreaterThan(0) - // The theme app extension preview server. - const preview = await fetchOk(`http://127.0.0.1:${themeExtensionPort}/`) - expect(preview.status, `GET the theme app extension preview failed:\n${preview.body.slice(0, 500)}`).toBe(200) - expect(preview.contentType).toContain('text/html') - dev.sendKey('q') const exitCode = await dev.waitForExit(CLI_TIMEOUT.short) expect(exitCode, `dev exited with non-zero code. Output:\n${dev.getOutput()}`).toBe(0) @@ -108,7 +88,8 @@ test.describe('App dev serves extensions', () => { storeFqdn, workerIndex: env.workerIndex, }) - fs.rmSync(parentDir, {recursive: true, force: true}) + // Windows can hold files for a moment after dev's processes exit. + fs.rmSync(parentDir, {recursive: true, force: true, maxRetries: 10, retryDelay: 500}) } } }) diff --git a/packages/e2e/tests/auth-diagnostics.spec.ts b/packages/e2e/tests/auth-diagnostics.spec.ts index 27729dc36d9..343315351f6 100644 --- a/packages/e2e/tests/auth-diagnostics.spec.ts +++ b/packages/e2e/tests/auth-diagnostics.spec.ts @@ -2,6 +2,7 @@ import { AuthSetupError, isExpectedAuthDestination, readAuthConfig, + readAuthRetryOptions, requireExpectedAuthDestination, requireSuccessfulNavigation, retryAuthOperation, @@ -47,11 +48,12 @@ test.describe('auth diagnostics', () => { expect(attempts).toBe(2) }) - test('marks only device login and page-load failures as retryable', () => { + test('marks only device login, page-load and login form failures as retryable', () => { expect(new AuthSetupError('device-code-generation', 'timeout').retryable).toBe(true) expect(new AuthSetupError('browser-login', 'page-load').retryable).toBe(true) + expect(new AuthSetupError('browser-login', 'login-form').retryable).toBe(true) expect(new AuthSetupError('session-prewarm', 'admin-page-load').retryable).toBe(true) - expect(new AuthSetupError('browser-login', 'login-form').retryable).toBe(false) + expect(new AuthSetupError('browser-login', 'webauthn-setup').retryable).toBe(false) }) test('does not retry deterministic authentication failures', async () => { @@ -61,14 +63,53 @@ test.describe('auth diagnostics', () => { retryAuthOperation( async () => { attempts++ - throw new AuthSetupError('browser-login', 'login-form') + throw new AuthSetupError('browser-login', 'webauthn-setup') }, {delayMs: 0}, ), - ).rejects.toThrow('stage=browser-login reason=login-form') + ).rejects.toThrow('stage=browser-login reason=webauthn-setup') expect(attempts).toBe(1) }) + test('reads the attempts and delay from the environment, with defaults', () => { + expect(readAuthRetryOptions({})).toEqual({maxAttempts: 2, delayMs: 1_000}) + expect(readAuthRetryOptions({E2E_AUTH_ATTEMPTS: '4', E2E_AUTH_RETRY_DELAY_MS: '30000'})).toEqual({ + maxAttempts: 4, + delayMs: 30_000, + }) + expect(() => readAuthRetryOptions({E2E_AUTH_ATTEMPTS: '0'})).toThrow('E2E_AUTH_ATTEMPTS') + expect(() => readAuthRetryOptions({E2E_AUTH_RETRY_DELAY_MS: 'soon'})).toThrow('E2E_AUTH_RETRY_DELAY_MS') + }) + + test('retries a stage as many times as configured', async () => { + let attempts = 0 + + await expect( + retryAuthOperation( + async () => { + attempts++ + throw new AuthSetupError('browser-login', 'login-form') + }, + {maxAttempts: 4, delayMs: 0}, + ), + ).rejects.toThrow('stage=browser-login reason=login-form') + expect(attempts).toBe(4) + }) + + test('reports only the HTTP status of a failed page load', async () => { + const failure = await requireSuccessfulNavigation( + async () => ({ok: () => false, status: () => 429, text: () => 'token=secret'}), + 'browser-login', + 'page-load', + ).catch((error: unknown) => error) + + expect(failure).toBeInstanceOf(AuthSetupError) + expect((failure as AuthSetupError).status).toBe(429) + expect((failure as AuthSetupError).message).toBe( + '[e2e][auth] failed stage=browser-login reason=page-load status=429', + ) + }) + test('retries one HTTP prewarm failure without restarting authentication', async () => { let authenticationAttempts = 0 let prewarmAttempts = 0 From c0a47b44c074337f8a58d8fbb0f1d60b70e1fcae Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 16:38:40 -0500 Subject: [PATCH 09/14] Try cross-spawn 7.1.0, the version 5.2.0 shipped (draft only) 5.2.0 broke npm and npx web commands in app dev on Windows through cross-spawn 7.1.0, and 5.2.1 moved to 7.1.2. This run checks that the React Router dev test fails on Windows with 7.1.0. The React Router test also installs its app with pnpm now. A later commit reverts the dependency here. Co-Authored-By: Claude Opus 5.5 --- package.json | 2 +- .../e2e/tests/app-dev-react-router.spec.ts | 4 +++- pnpm-lock.yaml | 20 +++++++++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index b5d31ad8153..e46a1c3f159 100644 --- a/package.json +++ b/package.json @@ -165,7 +165,7 @@ "follow-redirects": "1.16.2", "fast-uri": "3.1.9", "immutable@>=5.0.0 <5.1.8": "5.1.8", - "cross-spawn": "7.1.2" + "cross-spawn": "7.1.0" }, "knip": { "$schema": "https://unpkg.com/knip@5/schema.json", diff --git a/packages/e2e/tests/app-dev-react-router.spec.ts b/packages/e2e/tests/app-dev-react-router.spec.ts index c337bab31ea..0fd3337939b 100644 --- a/packages/e2e/tests/app-dev-react-router.spec.ts +++ b/packages/e2e/tests/app-dev-react-router.spec.ts @@ -30,13 +30,15 @@ test.describe('App dev with a React Router app', () => { let appDir: string | undefined try { - // The TypeScript template's web commands use npx and npm, whichever package manager the app uses. + // The TypeScript template's web commands use npx and npm whatever installed the app, so pnpm + // installs it: with npm, creating the app could take over 5 minutes on Windows and macOS. const initResult = await createApp({ cli, parentDir, name: appName, template: 'reactRouter', flavor: 'typescript', + packageManager: 'pnpm', orgId: env.orgId, }) expect(initResult.exitCode, `createApp failed:\nstdout: ${initResult.stdout}\nstderr: ${initResult.stderr}`).toBe( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2d7f4fe9313..27e260e5bcd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,7 +49,7 @@ overrides: follow-redirects: 1.16.2 fast-uri: 3.1.9 immutable@>=5.0.0 <5.1.8: 5.1.8 - cross-spawn: 7.1.2 + cross-spawn: 7.1.0 patchedDependencies: when-exit@2.1.5: @@ -4969,8 +4969,8 @@ packages: resolution: {integrity: sha512-Pcw1JTvZLSJH83iiGWt6fRcT+BjZlCDRVwYLbUcHzv/CRpB7r0MlSrGbIyQvVSNyGnbt7G4AXuyCiDR3POvZ1A==, tarball: https://registry.npmjs.org/cross-inspect/-/cross-inspect-1.0.1.tgz} engines: {node: '>=16.0.0'} - cross-spawn@7.1.2: - resolution: {integrity: sha512-8BPK2r+sKWC8sDinRwLwrFMq2lXTBBwzYYEB9LiCznfMurOi4FOvQflq3XOLGG+HPdMSVpe+k/s96+AtDEOgPg==, tarball: https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.1.2.tgz} + cross-spawn@7.1.0: + resolution: {integrity: sha512-/PHUIV1x/hZLpJN8KmyV2aYkT8pll4RjQ59TmhwkL/9B4HdOtlBQ2pos6iB2cfVRzpGHk3HXlRa8sdVYrPjIYw==, tarball: https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.1.0.tgz} engines: {node: '>= 8'} crossws@0.3.5: @@ -13878,7 +13878,7 @@ snapshots: dependencies: tslib: 2.8.1 - cross-spawn@7.1.2: + cross-spawn@7.1.0: dependencies: path-key: 3.1.1 shebang-command: 2.0.0 @@ -14590,7 +14590,7 @@ snapshots: '@types/estree': 1.0.9 ajv: 6.15.0 chalk: 4.1.2 - cross-spawn: 7.1.2 + cross-spawn: 7.1.0 debug: 4.4.3(supports-color@7.2.0) escape-string-regexp: 4.0.0 eslint-scope: 8.4.0 @@ -14651,7 +14651,7 @@ snapshots: execa@7.2.0: dependencies: - cross-spawn: 7.1.2 + cross-spawn: 7.1.0 get-stream: 6.0.1 human-signals: 4.3.1 is-stream: 3.0.0 @@ -14663,7 +14663,7 @@ snapshots: execa@8.0.1: dependencies: - cross-spawn: 7.1.2 + cross-spawn: 7.1.0 get-stream: 8.0.1 human-signals: 5.0.0 is-stream: 3.0.0 @@ -14821,7 +14821,7 @@ snapshots: foreground-child@3.3.1: dependencies: - cross-spawn: 7.1.2 + cross-spawn: 7.1.0 signal-exit: 4.1.0 form-data-encoder@2.1.4: {} @@ -16453,7 +16453,7 @@ snapshots: ansis: 3.17.0 async-retry: 1.3.3 change-case: 4.1.2 - cross-spawn: 7.1.2 + cross-spawn: 7.1.0 debug: 4.4.3(supports-color@7.2.0) ejs: 3.1.10 find-yarn-workspace-root: 2.0.0 @@ -17352,7 +17352,7 @@ snapshots: spawndamnit@3.0.1: dependencies: - cross-spawn: 7.1.2 + cross-spawn: 7.1.0 signal-exit: 4.1.0 spdx-correct@3.2.0: From 43fb3fd5b89615b1745139b3697118d4229de3a8 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 16:45:45 -0500 Subject: [PATCH 10/14] Drop the draft-only trials The E2E harness fixes, the new cases and the app dev fix go upstream as their own changes, and the dependency trial is over. This pull request changes only the workflow. Co-Authored-By: Claude Opus 5.5 --- package.json | 2 +- .../services/dev/app-events/file-watcher.ts | 4 +- packages/e2e/README.md | 2 +- packages/e2e/setup/admin-api.ts | 2 +- packages/e2e/setup/app.ts | 8 ++- packages/e2e/setup/auth-diagnostics.ts | 45 +++-------------- packages/e2e/setup/cli.ts | 2 +- packages/e2e/setup/constants.ts | 2 +- packages/e2e/setup/global-auth.ts | 13 ++--- packages/e2e/tests/auth-diagnostics.spec.ts | 49 ++----------------- pnpm-lock.yaml | 20 ++++---- 11 files changed, 33 insertions(+), 116 deletions(-) diff --git a/package.json b/package.json index e46a1c3f159..b5d31ad8153 100644 --- a/package.json +++ b/package.json @@ -165,7 +165,7 @@ "follow-redirects": "1.16.2", "fast-uri": "3.1.9", "immutable@>=5.0.0 <5.1.8": "5.1.8", - "cross-spawn": "7.1.0" + "cross-spawn": "7.1.2" }, "knip": { "$schema": "https://unpkg.com/knip@5/schema.json", diff --git a/packages/app/src/cli/services/dev/app-events/file-watcher.ts b/packages/app/src/cli/services/dev/app-events/file-watcher.ts index cc253ea062e..177b7fdd1c5 100644 --- a/packages/app/src/cli/services/dev/app-events/file-watcher.ts +++ b/packages/app/src/cli/services/dev/app-events/file-watcher.ts @@ -290,7 +290,7 @@ export class FileWatcher { private readonly handleFileEvent = (event: string, path: string) => { const startTime = startHRTime() const normalizedPath = normalizePath(path) - const isConfigAppPath = normalizedPath === normalizePath(this.app.configPath) + const isConfigAppPath = path === this.app.configPath const isExtensionToml = path.endsWith('.extension.toml') outputDebug(`🌀: ${event} ${path.replace(this.app.directory, '')}\n`) @@ -370,7 +370,7 @@ export class FileWatcher { extensionHandle?: string, ) { const isExtensionToml = path.endsWith('.extension.toml') - const isConfigAppPath = normalizePath(path) === normalizePath(this.app.configPath) + const isConfigAppPath = path === this.app.configPath switch (event) { case 'change': diff --git a/packages/e2e/README.md b/packages/e2e/README.md index 7c4bebf3833..e8ccdb4d168 100644 --- a/packages/e2e/README.md +++ b/packages/e2e/README.md @@ -12,7 +12,7 @@ App tests reuse existing stores. They never create or delete a store. Each test Create dedicated development stores once in the E2E organization and give the E2E account access. Use the `no-delete-e2e-` name prefix: the store cleanup script refuses to delete these stores, including in `--force` mode. -The store domains are defined in `E2E_STORES` in `setup/constants.ts`. Each of the eight dev cases selects a named store directly; none is spare. Adding a test requires an explicit assignment, with no worker or shard allocation. +The store domains are defined in `E2E_STORES` in `setup/constants.ts`. Each of the seven dev cases selects a named store directly; store 8 is spare. Adding a test requires an explicit assignment, with no worker or shard allocation. Copy `.env.example` to `.env` and supply the account, organization, and load-test header. Set `E2E_STORE_FQDN` to override the fixed assignments for local development. The test account must have access to the selected store. diff --git a/packages/e2e/setup/admin-api.ts b/packages/e2e/setup/admin-api.ts index 60f54f75163..13a8060d48a 100644 --- a/packages/e2e/setup/admin-api.ts +++ b/packages/e2e/setup/admin-api.ts @@ -9,7 +9,7 @@ import {stripAnsi} from '../helpers/strip-ansi.js' import type {CLIProcess} from './cli.js' /** Admin API version for harness-side GraphQL requests. */ -export const ADMIN_API_VERSION = '2026-04' +const ADMIN_API_VERSION = '2026-04' interface AdminApiUninstallCtx { cli: Pick diff --git a/packages/e2e/setup/app.ts b/packages/e2e/setup/app.ts index aee3ae9df20..563764c4fa1 100644 --- a/packages/e2e/setup/app.ts +++ b/packages/e2e/setup/app.ts @@ -226,13 +226,11 @@ export async function functionBuild(ctx: CLIContext): Promise { export async function functionRun( ctx: CLIContext & { inputPath: string - /** The Function export to run, for Functions with more than one target. */ - exportName?: string }, ): Promise { - const args = ['app', 'function', 'run', '--input', ctx.inputPath, '--path', ctx.appDir] - if (ctx.exportName) args.push('--export', ctx.exportName) - return ctx.cli.exec(args, {timeout: CLI_TIMEOUT.short}) + return ctx.cli.exec(['app', 'function', 'run', '--input', ctx.inputPath, '--path', ctx.appDir], { + timeout: CLI_TIMEOUT.short, + }) } export async function versionsList( diff --git a/packages/e2e/setup/auth-diagnostics.ts b/packages/e2e/setup/auth-diagnostics.ts index 7f66386ff99..c3138f78c2d 100644 --- a/packages/e2e/setup/auth-diagnostics.ts +++ b/packages/e2e/setup/auth-diagnostics.ts @@ -8,7 +8,6 @@ export interface AuthConfig { interface NavigationResponse { ok(): boolean - status?(): number } interface UrlWaiter { @@ -19,45 +18,16 @@ export class AuthSetupError extends Error { readonly stage: AuthStage readonly reason: string readonly retryable: boolean - /** The HTTP status of a failed page load. The error carries nothing else from the response. */ - readonly status?: number - constructor(stage: AuthStage, reason: string, status?: number) { - super(`[e2e][auth] failed stage=${stage} reason=${reason}${status === undefined ? '' : ` status=${status}`}`) + constructor(stage: AuthStage, reason: string) { + super(`[e2e][auth] failed stage=${stage} reason=${reason}`) this.name = 'AuthSetupError' this.stage = stage this.reason = reason this.retryable = isRetryableAuthFailure(stage, reason) - this.status = status } } -export interface AuthRetryOptions { - maxAttempts: number - delayMs: number -} - -/** - * Attempts and delay for each authentication stage. E2E_AUTH_ATTEMPTS and E2E_AUTH_RETRY_DELAY_MS - * override the defaults of 2 attempts, 1 second apart. - */ -export function readAuthRetryOptions(env: NodeJS.ProcessEnv = process.env): AuthRetryOptions { - return { - maxAttempts: readIntegerSetting(env, 'E2E_AUTH_ATTEMPTS', 2, 1), - delayMs: readIntegerSetting(env, 'E2E_AUTH_RETRY_DELAY_MS', 1_000, 0), - } -} - -function readIntegerSetting(env: NodeJS.ProcessEnv, name: string, fallback: number, minimum: number): number { - const value = env[name]?.trim() - if (!value) return fallback - const parsed = Number(value) - if (!Number.isInteger(parsed) || parsed < minimum) { - throw new Error(`${name} must be a whole number of at least ${minimum}, not "${value}"`) - } - return parsed -} - export function readAuthConfig(env: NodeJS.ProcessEnv = process.env): AuthConfig { const requiredValues = { E2E_ACCOUNT_EMAIL: env.E2E_ACCOUNT_EMAIL, @@ -83,8 +53,7 @@ export function readAuthConfig(env: NodeJS.ProcessEnv = process.env): AuthConfig function isRetryableAuthFailure(stage: AuthStage, reason: string): boolean { return ( (stage === 'device-code-generation' && reason === 'timeout') || - (stage === 'browser-login' && - (reason === 'page-load' || reason === 'login-form' || reason === 'cli-confirmation-timeout')) || + (stage === 'browser-login' && (reason === 'page-load' || reason === 'cli-confirmation-timeout')) || (stage === 'session-prewarm' && reason.endsWith('-page-load')) ) } @@ -122,7 +91,6 @@ export async function runAuthStages({ complete, dispose, onRetry, - maxAttempts, delayMs, }: { authenticate: () => Promise @@ -130,12 +98,11 @@ export async function runAuthStages({ complete: (authenticatedSession: T) => Promise dispose: (authenticatedSession: T) => Promise onRetry?: (failure: AuthSetupError, nextAttempt: number) => void - maxAttempts?: number delayMs?: number }): Promise { - const authenticatedSession = await retryAuthOperation(authenticate, {onRetry, maxAttempts, delayMs}) + const authenticatedSession = await retryAuthOperation(authenticate, {onRetry, delayMs}) try { - await retryAuthOperation(() => prewarm(authenticatedSession), {onRetry, maxAttempts, delayMs}) + await retryAuthOperation(() => prewarm(authenticatedSession), {onRetry, delayMs}) await complete(authenticatedSession) } finally { await dispose(authenticatedSession) @@ -149,7 +116,7 @@ export async function requireSuccessfulNavigation( ): Promise { try { const response = await navigate() - if (!response?.ok()) throw new AuthSetupError(stage, reason, response?.status?.()) + if (!response?.ok()) throw new AuthSetupError(stage, reason) } catch (error) { if (error instanceof AuthSetupError) throw error throw new AuthSetupError(stage, reason) diff --git a/packages/e2e/setup/cli.ts b/packages/e2e/setup/cli.ts index 7e2ff41841a..a81817bc858 100644 --- a/packages/e2e/setup/cli.ts +++ b/packages/e2e/setup/cli.ts @@ -134,7 +134,7 @@ export const cliFixture = envFixture.extend<{cli: CLIProcess}>({ cliLog.log(env, `spawn: node ${executables.cli}`) cliLog.log(env, args.join(' ')) - const ptyProcess = nodePty.spawn(process.execPath, [executables.cli, ...args], { + const ptyProcess = nodePty.spawn('node', [executables.cli, ...args], { name: 'xterm-color', cols: 120, rows: 30, diff --git a/packages/e2e/setup/constants.ts b/packages/e2e/setup/constants.ts index a9ba731c426..ac277d555a4 100644 --- a/packages/e2e/setup/constants.ts +++ b/packages/e2e/setup/constants.ts @@ -6,7 +6,7 @@ export const E2E_STORES = { namedConfig: 'no-delete-e2e-reusable-store-5.myshopify.com', defaultConfig: 'no-delete-e2e-reusable-store-6.myshopify.com', fullConfig: 'no-delete-e2e-reusable-store-7.myshopify.com', - reactRouterDev: 'no-delete-e2e-reusable-store-8.myshopify.com', + spare: 'no-delete-e2e-reusable-store-8.myshopify.com', } as const // --------------------------------------------------------------------------- diff --git a/packages/e2e/setup/global-auth.ts b/packages/e2e/setup/global-auth.ts index 2f91250203b..0ac051d63d1 100644 --- a/packages/e2e/setup/global-auth.ts +++ b/packages/e2e/setup/global-auth.ts @@ -12,7 +12,6 @@ import { AuthSetupError, isExpectedAuthDestination, readAuthConfig, - readAuthRetryOptions, requireExpectedAuthDestination, requireSuccessfulNavigation, runAuthStages, @@ -46,7 +45,6 @@ interface AuthenticatedBrowserSession { export async function prepareGlobalAuth() { const {authDir, storageStatePath, xdgEnv} = authStatePaths() const authConfig = readAuthConfig() - const retryOptions = readAuthRetryOptions() globalLog('auth', 'starting') const processEnv: NodeJS.ProcessEnv = { @@ -78,24 +76,19 @@ export async function prepareGlobalAuth() { dispose: async ({browser}) => browser.close(), onRetry: (failure, nextAttempt) => { process.stdout.write( - `[e2e][auth] retry stage=${failure.stage} reason=${failure.reason}${statusSuffix(failure)} next_attempt=${nextAttempt}\n`, + `[e2e][auth] retry stage=${failure.stage} reason=${failure.reason} next_attempt=${nextAttempt}\n`, ) }, - ...retryOptions, }) } catch (error) { const failure = error instanceof AuthSetupError ? error : new AuthSetupError('browser-login', 'unexpected-error') - process.stderr.write(`[e2e][auth] failed stage=${failure.stage} reason=${failure.reason}${statusSuffix(failure)}\n`) + process.stderr.write(`[e2e][auth] failed stage=${failure.stage} reason=${failure.reason}\n`) throw failure } globalLog('auth', 'complete') } -function statusSuffix(failure: AuthSetupError): string { - return failure.status === undefined ? '' : ` status=${failure.status}` -} - function resetAuthDirectories(authDir: string, xdgEnv: Record): void { fs.rmSync(authDir, {recursive: true, force: true}) fs.mkdirSync(authDir, {recursive: true}) @@ -128,7 +121,7 @@ async function authenticateOnce({ let ptyProcess: IPty try { const nodePty = await import('node-pty') - ptyProcess = nodePty.spawn(process.execPath, [executables.cli, 'auth', 'login'], { + ptyProcess = nodePty.spawn('node', [executables.cli, 'auth', 'login'], { name: 'xterm-color', cols: 120, rows: 30, diff --git a/packages/e2e/tests/auth-diagnostics.spec.ts b/packages/e2e/tests/auth-diagnostics.spec.ts index 343315351f6..27729dc36d9 100644 --- a/packages/e2e/tests/auth-diagnostics.spec.ts +++ b/packages/e2e/tests/auth-diagnostics.spec.ts @@ -2,7 +2,6 @@ import { AuthSetupError, isExpectedAuthDestination, readAuthConfig, - readAuthRetryOptions, requireExpectedAuthDestination, requireSuccessfulNavigation, retryAuthOperation, @@ -48,66 +47,26 @@ test.describe('auth diagnostics', () => { expect(attempts).toBe(2) }) - test('marks only device login, page-load and login form failures as retryable', () => { + test('marks only device login and page-load failures as retryable', () => { expect(new AuthSetupError('device-code-generation', 'timeout').retryable).toBe(true) expect(new AuthSetupError('browser-login', 'page-load').retryable).toBe(true) - expect(new AuthSetupError('browser-login', 'login-form').retryable).toBe(true) expect(new AuthSetupError('session-prewarm', 'admin-page-load').retryable).toBe(true) - expect(new AuthSetupError('browser-login', 'webauthn-setup').retryable).toBe(false) + expect(new AuthSetupError('browser-login', 'login-form').retryable).toBe(false) }) test('does not retry deterministic authentication failures', async () => { let attempts = 0 - await expect( - retryAuthOperation( - async () => { - attempts++ - throw new AuthSetupError('browser-login', 'webauthn-setup') - }, - {delayMs: 0}, - ), - ).rejects.toThrow('stage=browser-login reason=webauthn-setup') - expect(attempts).toBe(1) - }) - - test('reads the attempts and delay from the environment, with defaults', () => { - expect(readAuthRetryOptions({})).toEqual({maxAttempts: 2, delayMs: 1_000}) - expect(readAuthRetryOptions({E2E_AUTH_ATTEMPTS: '4', E2E_AUTH_RETRY_DELAY_MS: '30000'})).toEqual({ - maxAttempts: 4, - delayMs: 30_000, - }) - expect(() => readAuthRetryOptions({E2E_AUTH_ATTEMPTS: '0'})).toThrow('E2E_AUTH_ATTEMPTS') - expect(() => readAuthRetryOptions({E2E_AUTH_RETRY_DELAY_MS: 'soon'})).toThrow('E2E_AUTH_RETRY_DELAY_MS') - }) - - test('retries a stage as many times as configured', async () => { - let attempts = 0 - await expect( retryAuthOperation( async () => { attempts++ throw new AuthSetupError('browser-login', 'login-form') }, - {maxAttempts: 4, delayMs: 0}, + {delayMs: 0}, ), ).rejects.toThrow('stage=browser-login reason=login-form') - expect(attempts).toBe(4) - }) - - test('reports only the HTTP status of a failed page load', async () => { - const failure = await requireSuccessfulNavigation( - async () => ({ok: () => false, status: () => 429, text: () => 'token=secret'}), - 'browser-login', - 'page-load', - ).catch((error: unknown) => error) - - expect(failure).toBeInstanceOf(AuthSetupError) - expect((failure as AuthSetupError).status).toBe(429) - expect((failure as AuthSetupError).message).toBe( - '[e2e][auth] failed stage=browser-login reason=page-load status=429', - ) + expect(attempts).toBe(1) }) test('retries one HTTP prewarm failure without restarting authentication', async () => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 27e260e5bcd..2d7f4fe9313 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,7 +49,7 @@ overrides: follow-redirects: 1.16.2 fast-uri: 3.1.9 immutable@>=5.0.0 <5.1.8: 5.1.8 - cross-spawn: 7.1.0 + cross-spawn: 7.1.2 patchedDependencies: when-exit@2.1.5: @@ -4969,8 +4969,8 @@ packages: resolution: {integrity: sha512-Pcw1JTvZLSJH83iiGWt6fRcT+BjZlCDRVwYLbUcHzv/CRpB7r0MlSrGbIyQvVSNyGnbt7G4AXuyCiDR3POvZ1A==, tarball: https://registry.npmjs.org/cross-inspect/-/cross-inspect-1.0.1.tgz} engines: {node: '>=16.0.0'} - cross-spawn@7.1.0: - resolution: {integrity: sha512-/PHUIV1x/hZLpJN8KmyV2aYkT8pll4RjQ59TmhwkL/9B4HdOtlBQ2pos6iB2cfVRzpGHk3HXlRa8sdVYrPjIYw==, tarball: https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.1.0.tgz} + cross-spawn@7.1.2: + resolution: {integrity: sha512-8BPK2r+sKWC8sDinRwLwrFMq2lXTBBwzYYEB9LiCznfMurOi4FOvQflq3XOLGG+HPdMSVpe+k/s96+AtDEOgPg==, tarball: https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.1.2.tgz} engines: {node: '>= 8'} crossws@0.3.5: @@ -13878,7 +13878,7 @@ snapshots: dependencies: tslib: 2.8.1 - cross-spawn@7.1.0: + cross-spawn@7.1.2: dependencies: path-key: 3.1.1 shebang-command: 2.0.0 @@ -14590,7 +14590,7 @@ snapshots: '@types/estree': 1.0.9 ajv: 6.15.0 chalk: 4.1.2 - cross-spawn: 7.1.0 + cross-spawn: 7.1.2 debug: 4.4.3(supports-color@7.2.0) escape-string-regexp: 4.0.0 eslint-scope: 8.4.0 @@ -14651,7 +14651,7 @@ snapshots: execa@7.2.0: dependencies: - cross-spawn: 7.1.0 + cross-spawn: 7.1.2 get-stream: 6.0.1 human-signals: 4.3.1 is-stream: 3.0.0 @@ -14663,7 +14663,7 @@ snapshots: execa@8.0.1: dependencies: - cross-spawn: 7.1.0 + cross-spawn: 7.1.2 get-stream: 8.0.1 human-signals: 5.0.0 is-stream: 3.0.0 @@ -14821,7 +14821,7 @@ snapshots: foreground-child@3.3.1: dependencies: - cross-spawn: 7.1.0 + cross-spawn: 7.1.2 signal-exit: 4.1.0 form-data-encoder@2.1.4: {} @@ -16453,7 +16453,7 @@ snapshots: ansis: 3.17.0 async-retry: 1.3.3 change-case: 4.1.2 - cross-spawn: 7.1.0 + cross-spawn: 7.1.2 debug: 4.4.3(supports-color@7.2.0) ejs: 3.1.10 find-yarn-workspace-root: 2.0.0 @@ -17352,7 +17352,7 @@ snapshots: spawndamnit@3.0.1: dependencies: - cross-spawn: 7.1.0 + cross-spawn: 7.1.2 signal-exit: 4.1.0 spdx-correct@3.2.0: From dddf1dab2328bf084ef6dcadf48bd1fdfbdc1cda Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 16:45:47 -0500 Subject: [PATCH 11/14] Run Release E2E only for stable lines and on demand Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-e2e.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release-e2e.yml b/.github/workflows/release-e2e.yml index 6bd6609e927..febf5561f8a 100644 --- a/.github/workflows/release-e2e.yml +++ b/.github/workflows/release-e2e.yml @@ -13,8 +13,6 @@ on: types: [opened, synchronize, reopened, edited] branches: - 'stable/**' - # Draft only: runs the workflow on its own pull request. Removed before review. - - main workflow_dispatch: inputs: branch-or-tag: From 9a0ba5106cfaad86bdda6e480e94e497eed59410 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 16:46:15 -0500 Subject: [PATCH 12/14] Drop the draft-only test files The new E2E cases go upstream as their own changes. This pull request changes only the workflow. Co-Authored-By: Claude Opus 5.5 --- packages/e2e/tests/app-dev-extensions.spec.ts | 96 ------------- .../e2e/tests/app-dev-react-router.spec.ts | 127 ------------------ packages/e2e/tests/app-function.spec.ts | 89 ------------ packages/e2e/tests/hydrogen.spec.ts | 60 --------- 4 files changed, 372 deletions(-) delete mode 100644 packages/e2e/tests/app-dev-extensions.spec.ts delete mode 100644 packages/e2e/tests/app-dev-react-router.spec.ts delete mode 100644 packages/e2e/tests/app-function.spec.ts delete mode 100644 packages/e2e/tests/hydrogen.spec.ts diff --git a/packages/e2e/tests/app-dev-extensions.spec.ts b/packages/e2e/tests/app-dev-extensions.spec.ts deleted file mode 100644 index e3f0bacf527..00000000000 --- a/packages/e2e/tests/app-dev-extensions.spec.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* eslint-disable no-restricted-imports, no-restricted-globals -- the test reads the dev proxy directly */ -import {appTestFixture as test, createApp, devDashboardAppUrl, generateExtension} from '../setup/app.js' -import {teardownAll} from '../setup/teardown.js' -import {E2E_STORES, CLI_TIMEOUT, TEST_TIMEOUT} from '../setup/constants.js' -import {e2eAppName, requireEnv} from '../setup/env.js' -import {expect} from '@playwright/test' -import * as fs from 'fs' -import * as path from 'path' - -const ADMIN_ACTION = 'e2e-admin-action' - -interface ExtensionsPayload { - extensions: {handle: string; assets: {main: {url: string}}}[] -} - -async function get(url: string): Promise<{status: number; contentType: string; body: string}> { - const response = await fetch(url, {signal: AbortSignal.timeout(CLI_TIMEOUT.short)}) - return {status: response.status, contentType: response.headers.get('content-type') ?? '', body: await response.text()} -} - -test.describe('App dev serves extensions', () => { - test('dev builds the admin action and serves its bundle', async ({cli, env, dashboard}) => { - const storeFqdn = env.storeFqdn || E2E_STORES.devServer - test.setTimeout(TEST_TIMEOUT.long) - requireEnv(env, 'orgId') - - const parentDir = fs.mkdtempSync(path.join(env.tempDir, 'app-')) - const appName = e2eAppName('dext') - let appUrl: string | undefined - let appDir: string | undefined - - try { - const initResult = await createApp({cli, parentDir, name: appName, template: 'none', orgId: env.orgId}) - expect(initResult.exitCode, `createApp failed:\nstderr: ${initResult.stderr}`).toBe(0) - appDir = initResult.appDir - appUrl = await devDashboardAppUrl({cli, appDir, orgId: env.orgId}) - - const generateResult = await generateExtension({ - cli, - appDir, - name: ADMIN_ACTION, - template: 'admin_action', - flavor: 'preact', - }) - expect( - generateResult.exitCode, - `generateExtension failed:\nstdout: ${generateResult.stdout}\nstderr: ${generateResult.stderr}`, - ).toBe(0) - - const dev = await cli.spawn(['app', 'dev', '--path', appDir], {env: {CI: '', SHOPIFY_FLAG_STORE: storeFqdn}}) - - try { - await dev.waitForOutput('Ready, watching for changes in your app', CLI_TIMEOUT.long) - - // The bundle the admin loads for the action, through the dev proxy. - const proxyPort = dev.getOutput().match(/Proxy server started on port (\d+)/)?.[1] - expect(proxyPort, 'app dev should print the proxy port').toBeTruthy() - const payload = await get(`http://localhost:${proxyPort}/extensions`) - expect(payload.status, `GET /extensions failed:\n${payload.body}`).toBe(200) - const adminAction = (JSON.parse(payload.body) as ExtensionsPayload).extensions.find( - (extension) => extension.handle === ADMIN_ACTION, - ) - expect(adminAction, `the dev server should list ${ADMIN_ACTION}:\n${payload.body}`).toBeDefined() - const bundlePath = new URL(adminAction!.assets.main.url).pathname - const bundle = await get(`http://localhost:${proxyPort}${bundlePath}`) - expect(bundle.status, `GET ${bundlePath} failed:\n${bundle.body.slice(0, 500)}`).toBe(200) - expect(bundle.contentType).toContain('javascript') - expect(bundle.body.length).toBeGreaterThan(0) - - dev.sendKey('q') - const exitCode = await dev.waitForExit(CLI_TIMEOUT.short) - expect(exitCode, `dev exited with non-zero code. Output:\n${dev.getOutput()}`).toBe(0) - } catch (error) { - // eslint-disable-next-line no-console - console.error(`[dev extensions] Captured PTY output:\n${dev.getOutput()}`) - throw error - } - } finally { - // E2E_SKIP_TEARDOWN=1 skips teardown for debugging. Run cleanup scripts afterward. - if (!process.env.E2E_SKIP_TEARDOWN) { - await teardownAll({ - cli, - dashboard, - appName, - appUrl, - appDir, - orgId: env.orgId, - storeFqdn, - workerIndex: env.workerIndex, - }) - // Windows can hold files for a moment after dev's processes exit. - fs.rmSync(parentDir, {recursive: true, force: true, maxRetries: 10, retryDelay: 500}) - } - } - }) -}) diff --git a/packages/e2e/tests/app-dev-react-router.spec.ts b/packages/e2e/tests/app-dev-react-router.spec.ts deleted file mode 100644 index 0fd3337939b..00000000000 --- a/packages/e2e/tests/app-dev-react-router.spec.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* eslint-disable no-restricted-imports, no-restricted-globals -- the test reads the dev GraphiQL server directly */ -import {appTestFixture as test, createApp, devDashboardAppUrl} from '../setup/app.js' -import {ADMIN_API_VERSION} from '../setup/admin-api.js' -import {teardownAll} from '../setup/teardown.js' -import {E2E_STORES, CLI_TIMEOUT} from '../setup/constants.js' -import {e2eAppName, requireEnv} from '../setup/env.js' -import {expect} from '@playwright/test' -import {randomBytes} from 'crypto' -import * as fs from 'fs' -import * as path from 'path' - -const SHOP_NAME_QUERY = 'query { shop { name } }' - -test.describe('App dev with a React Router app', () => { - test('dev runs the web commands, and app execute, GraphiQL and app logs reach the store', async ({ - cli, - env, - dashboard, - }) => { - const storeFqdn = env.storeFqdn || E2E_STORES.reactRouterDev - // Creating the app installs its dependencies, and dev then runs its web commands. - test.setTimeout(15 * 60_000) - requireEnv(env, 'orgId') - - const parentDir = fs.mkdtempSync(path.join(env.tempDir, 'app-')) - const appName = e2eAppName('rrdv') - const graphiqlKey = randomBytes(16).toString('hex') - const graphiqlPort = env.processEnv.SHOPIFY_FLAG_GRAPHIQL_PORT - let appUrl: string | undefined - let appDir: string | undefined - - try { - // The TypeScript template's web commands use npx and npm whatever installed the app, so pnpm - // installs it: with npm, creating the app could take over 5 minutes on Windows and macOS. - const initResult = await createApp({ - cli, - parentDir, - name: appName, - template: 'reactRouter', - flavor: 'typescript', - packageManager: 'pnpm', - orgId: env.orgId, - }) - expect(initResult.exitCode, `createApp failed:\nstdout: ${initResult.stdout}\nstderr: ${initResult.stderr}`).toBe( - 0, - ) - appDir = initResult.appDir - appUrl = await devDashboardAppUrl({cli, appDir, orgId: env.orgId}) - - const dev = await cli.spawn(['app', 'dev', '--path', appDir], { - env: {CI: '', SHOPIFY_FLAG_STORE: storeFqdn, SHOPIFY_FLAG_GRAPHIQL_KEY: graphiqlKey}, - }) - - try { - // The web dev command, `npx prisma migrate deploy && npm exec react-router dev`, gets as far as - // the dev server only if app dev can start npx and npm. - await dev.waitForOutput('Running pre-dev command', CLI_TIMEOUT.long) - await dev.waitForOutput('All migrations have been successfully applied', CLI_TIMEOUT.long) - await dev.waitForOutput('Local: http://localhost:', CLI_TIMEOUT.long) - await dev.waitForOutput('Ready, watching for changes in your app', CLI_TIMEOUT.long) - - const executeResult = await cli.exec([ - 'app', - 'execute', - '--query', - SHOP_NAME_QUERY, - '--store', - storeFqdn, - '--json', - '--path', - appDir, - ]) - expect( - executeResult.exitCode, - `app execute failed:\nstdout: ${executeResult.stdout}\nstderr: ${executeResult.stderr}`, - ).toBe(0) - const shopName = JSON.parse(executeResult.stdout).data?.shop?.name - expect(shopName, `app execute returned no shop name:\n${executeResult.stdout}`).toBeTruthy() - - const graphiqlUrl = `http://localhost:${graphiqlPort}/graphiql/graphql.json?key=${graphiqlKey}&api_version=${ADMIN_API_VERSION}` - const graphiqlResponse = await fetch(graphiqlUrl, { - method: 'POST', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({query: SHOP_NAME_QUERY}), - signal: AbortSignal.timeout(CLI_TIMEOUT.short), - }) - const graphiqlBody = await graphiqlResponse.text() - expect(graphiqlResponse.status, `GraphiQL request failed:\n${graphiqlBody}`).toBe(200) - expect(JSON.parse(graphiqlBody).data?.shop?.name).toBe(shopName) - - const logsResult = await cli.exec(['app', 'logs', '--json', '--limit', '5', '--path', appDir]) - expect( - logsResult.exitCode, - `app logs failed:\nstdout: ${logsResult.stdout}\nstderr: ${logsResult.stderr}`, - ).toBe(0) - expect( - Array.isArray(JSON.parse(logsResult.stdout).logs), - `app logs printed no logs list:\n${logsResult.stdout}`, - ).toBe(true) - - dev.sendKey('q') - const exitCode = await dev.waitForExit(CLI_TIMEOUT.short) - expect(exitCode, `dev exited with non-zero code. Output:\n${dev.getOutput()}`).toBe(0) - } catch (error) { - // eslint-disable-next-line no-console - console.error(`[react-router dev] Captured PTY output:\n${dev.getOutput()}`) - throw error - } - } finally { - // E2E_SKIP_TEARDOWN=1 skips teardown for debugging. Run cleanup scripts afterward. - if (!process.env.E2E_SKIP_TEARDOWN) { - await teardownAll({ - cli, - dashboard, - appName, - appUrl, - appDir, - orgId: env.orgId, - storeFqdn, - workerIndex: env.workerIndex, - }) - // Windows can hold files for a moment after dev's web processes exit. - fs.rmSync(parentDir, {recursive: true, force: true, maxRetries: 10, retryDelay: 500}) - } - } - }) -}) diff --git a/packages/e2e/tests/app-function.spec.ts b/packages/e2e/tests/app-function.spec.ts deleted file mode 100644 index bd6f530af52..00000000000 --- a/packages/e2e/tests/app-function.spec.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* eslint-disable no-restricted-imports */ -import { - appInfo, - appTestFixture as test, - createApp, - devDashboardAppUrl, - functionBuild, - functionRun, - generateExtension, -} from '../setup/app.js' -import {teardownAll} from '../setup/teardown.js' -import {TEST_TIMEOUT} from '../setup/constants.js' -import {e2eAppName, requireEnv} from '../setup/env.js' -import {expect} from '@playwright/test' -import * as fs from 'fs' -import * as path from 'path' - -const FUNCTION_NAME = 'e2e-discount' - -// One cart line and every discount class, for the discount Function's cart lines target. -const DISCOUNT_INPUT = { - cart: {lines: [{id: 'gid://shopify/CartLine/0', cost: {subtotalAmount: {amount: '10.0'}}}]}, - discount: {discountClasses: ['PRODUCT', 'ORDER', 'SHIPPING']}, -} - -test.describe('App functions', () => { - test('builds and runs a discount Function, and app info lists it', async ({cli, env, dashboard}) => { - test.setTimeout(TEST_TIMEOUT.long) - requireEnv(env, 'orgId') - - const parentDir = fs.mkdtempSync(path.join(env.tempDir, 'app-')) - const appName = e2eAppName('func') - let appUrl: string | undefined - - try { - const initResult = await createApp({cli, parentDir, name: appName, template: 'none', orgId: env.orgId}) - expect(initResult.exitCode, `createApp failed:\nstderr: ${initResult.stderr}`).toBe(0) - const appDir = initResult.appDir - appUrl = await devDashboardAppUrl({cli, appDir, orgId: env.orgId}) - - const generateResult = await generateExtension({ - cli, - appDir, - name: FUNCTION_NAME, - template: 'discount', - flavor: 'typescript', - }) - expect( - generateResult.exitCode, - `generateExtension failed:\nstdout: ${generateResult.stdout}\nstderr: ${generateResult.stderr}`, - ).toBe(0) - - const functionDir = path.join(appDir, 'extensions', FUNCTION_NAME) - const buildResult = await functionBuild({cli, appDir: functionDir}) - expect( - buildResult.exitCode, - `function build failed:\nstdout: ${buildResult.stdout}\nstderr: ${buildResult.stderr}`, - ).toBe(0) - - const inputPath = path.join(parentDir, 'discount-input.json') - fs.writeFileSync(inputPath, JSON.stringify(DISCOUNT_INPUT)) - const runResult = await functionRun({ - cli, - appDir: functionDir, - inputPath, - exportName: 'cart-lines-discounts-generate-run', - }) - expect(runResult.exitCode, `function run failed:\nstdout: ${runResult.stdout}\nstderr: ${runResult.stderr}`).toBe( - 0, - ) - expect(runResult.stdout, 'function run should print the discount operations').toContain('operations') - - const info = await appInfo({cli, appDir}) - expect(info.allExtensions.map((extension) => extension.configuration.handle)).toContain(FUNCTION_NAME) - } finally { - // E2E_SKIP_TEARDOWN=1 skips teardown for debugging. Run cleanup scripts afterward. - if (!process.env.E2E_SKIP_TEARDOWN) { - fs.rmSync(parentDir, {recursive: true, force: true}) - await teardownAll({ - dashboard, - appName, - appUrl, - orgId: env.orgId, - workerIndex: env.workerIndex, - }) - } - } - }) -}) diff --git a/packages/e2e/tests/hydrogen.spec.ts b/packages/e2e/tests/hydrogen.spec.ts deleted file mode 100644 index 7acca1ca2b8..00000000000 --- a/packages/e2e/tests/hydrogen.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* eslint-disable no-restricted-imports */ -import {cliFixture as test} from '../setup/cli.js' -import {CLI_TIMEOUT, TEST_TIMEOUT} from '../setup/constants.js' -import {expect} from '@playwright/test' -import * as fs from 'fs' -import * as os from 'os' -import * as path from 'path' - -test.describe('Hydrogen', () => { - test('init creates a mock.shop storefront that builds', async ({cli}) => { - test.setTimeout(TEST_TIMEOUT.long) - - // Outside this repository, so pnpm doesn't treat the storefront as part of the repository's - // workspace. pnpm whatever the job's package manager: with npm, hydrogen init didn't finish within - // 5 minutes on Windows, and the app tests already cover npm. - const parentDir = fs.mkdtempSync(path.join(os.tmpdir(), 'e2e-hydrogen-')) - const storefrontDir = path.join(parentDir, 'storefront') - - try { - const initResult = await cli.exec( - [ - 'hydrogen', - 'init', - '--path', - storefrontDir, - '--mock-shop', - '--language', - 'ts', - '--styling', - 'none', - '--markets', - 'none', - '--no-shortcut', - '--no-git', - '--install-deps', - '--package-manager', - 'pnpm', - ], - {timeout: CLI_TIMEOUT.long}, - ) - expect( - initResult.exitCode, - `hydrogen init failed:\nstdout: ${initResult.stdout}\nstderr: ${initResult.stderr}`, - ).toBe(0) - expect(fs.existsSync(path.join(storefrontDir, 'node_modules')), 'hydrogen init should install dependencies').toBe( - true, - ) - - const buildResult = await cli.exec(['hydrogen', 'build', '--path', storefrontDir], {timeout: CLI_TIMEOUT.long}) - expect( - buildResult.exitCode, - `hydrogen build failed:\nstdout: ${buildResult.stdout}\nstderr: ${buildResult.stderr}`, - ).toBe(0) - expect(fs.existsSync(path.join(storefrontDir, 'dist')), 'hydrogen build should write dist').toBe(true) - } finally { - // Windows can hold files for a moment after the processes that used them exit. - fs.rmSync(parentDir, {recursive: true, force: true, maxRetries: 10, retryDelay: 500}) - } - }) -}) From f406018ec6d4e845fe02804a185ca8a339bfca22 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 16:47:00 -0500 Subject: [PATCH 13/14] Describe what Release E2E runs Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-e2e.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-e2e.yml b/.github/workflows/release-e2e.yml index febf5561f8a..55fd11a84db 100644 --- a/.github/workflows/release-e2e.yml +++ b/.github/workflows/release-e2e.yml @@ -1,9 +1,9 @@ name: Release E2E -# Runs the remote E2E tests on Linux, Windows and macOS against every pull request into a stable -# line, so a release is tested on each system before it ships. The PR workflow runs the same tests -# on Linux only. The tests use real Shopify accounts and stores, through the same secrets as that -# workflow's E2E tests. +# Runs the E2E tests on Linux, Windows and macOS against every pull request into a stable line, so a +# release is tested on each system before it ships. The PR workflow runs them on Linux only. The +# remote tests use real Shopify accounts and stores, through the same secrets as that workflow's +# E2E tests. # # `edited` covers a pull request retargeted to a stable line. It runs on every edit: skipping the # gate on the others would record a skipped "Release E2E", which counts as passing and replaces the From 17d19fe35411cc07b8657168e9219ff02fe46f81 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 3 Dec 2026 17:49:43 -0500 Subject: [PATCH 14/14] Give the remote E2E tests a longer global timeout on release runs Windows and macOS are slower, and a long test plus its retry can pass Playwright's configured 20 minutes. The remote run gets 35 minutes, and the job 50. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-e2e.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-e2e.yml b/.github/workflows/release-e2e.yml index 55fd11a84db..2b9676f9589 100644 --- a/.github/workflows/release-e2e.yml +++ b/.github/workflows/release-e2e.yml @@ -73,8 +73,9 @@ jobs: # Fork pull requests get no secrets. The gate then fails, since a release can't skip these tests. if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository runs-on: ${{ matrix.os }} - # Leave room for setup, reports and cleanup after Playwright's global timeout. - timeout-minutes: 45 + # Leave room for setup, the local tests, reports and cleanup around the remote tests' global + # timeout. + timeout-minutes: 50 strategy: fail-fast: false matrix: @@ -163,7 +164,8 @@ jobs: SKIP: ${{ matrix.skip }} run: | set -euo pipefail - ARGS=(--project remote --shard "$SHARD" --retries 1) + # Slower systems and one retry need more than the config's 20-minute global timeout. + ARGS=(--project remote --shard "$SHARD" --retries 1 --global-timeout 2100000) if [ -n "$SKIP" ]; then ARGS+=(--grep-invert "$SKIP"); fi pnpm exec playwright test "${ARGS[@]}"