Skip to content

Correct E2E teardown ordering and remove browser gates - #8316

Draft
isaacroldan wants to merge 9 commits into
mainfrom
isaac/e2e-teardown-via-api
Draft

Correct E2E teardown ordering and remove browser gates#8316
isaacroldan wants to merge 9 commits into
mainfrom
isaac/e2e-teardown-via-api

Conversation

@isaacroldan

@isaacroldan isaacroldan commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Why

Per-test cleanup deleted the dev store before the app. Store cancellation can leave installation records that keep the app's Dev Dashboard delete action disabled, so this order can leak apps. The cleanup path also used store-admin page state as a gate and could replace the original test failure with a teardown exception.

What

  • Uses the required order for store-backed tests: uninstall app, wait for zero installs, delete app, then delete store.
  • Checks app identity and installCount through the App Management API. The API work runs in the existing tsx subprocess boundary and uses cli-kit's GraphQL client, including shared throttling, network retry, and token refresh behavior.
  • Treats a missing or null install count as unknown instead of zero. A missing app must be confirmed twice before it is classified as already deleted.
  • Keeps Playwright only for the final Dev Dashboard app deletion. Store-admin page state is no longer a cleanup prerequisite.
  • Requires confirmed app deletion before store deletion. Each phase records completed, failed, or skipped without throwing from teardown.
  • Uses the numeric Dev Dashboard app route when available and validates the account-picker hostname with URL parsing.
  • Adds local tests for phase order, failure gates, exact app selection, stale client IDs, missing install counts, and non-throwing cleanup.
  • Fixes the existing E2E DOM-click type error so the type-check gate can run the E2E jobs.

No changeset: this changes internal E2E infrastructure only.

Testing

  • pnpm --filter @shopify/e2e type-check
  • pnpm --filter @shopify/e2e lint
  • pnpm exec playwright test --project local — 23 passed
  • PR CI — all checks passed, including both remote E2E shards and current-run cleanup. Live teardown records show zero installs, app deletion, then store deletion with no failed cleanup phases.

The E2E teardown drove the Dev Dashboard and store admin UI for work
the App Management API can answer directly:

- App lookup: replace the browser pagination in findAppOnDevDashboard
  with appByKey (client_id) and an appsConnection title search fallback.
- Install gating: replace the isStoreAppsEmpty page scrape and the
  disabled-Delete-button probing with installCount polling. The same
  check gates both store deletion and app deletion.
- Store uninstall: drop the browser click-through fallback; the Admin
  API path (from #8309) is now the only one in teardown.

The browser is only used for the final delete-app click, which has no
API mutation. The cleanup scripts keep their browser paths: org-wide
sweeps have no local app dir to mint Admin API tokens from.

API calls reuse the worker's CLI session via cli-kit, following the
cleanup-stores.ts pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Aug 12, 2026
isaacroldan and others added 3 commits August 12, 2026 15:57
Importing cli-kit's dist ESM inside Playwright's transpiled harness
crashes Node's require(esm) path on CI's Node version ("Unexpected
module status 3"). tsx's loader handles the interop — the same reason
the cleanup scripts import cli-kit under tsx without issues.

This also removes the process.env XDG mutation: the session dirs are
passed to the subprocess environment directly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The App Management API resolves the request's organization from
specifically-named GraphQL variables (organizationId, apiKey, appId).
The lookup variable was named "key", so every teardown lookup failed
with 404 "Cannot find a valid organization" and app/store deletion was
skipped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- appByKey now sends organizationId: without it a deleted app cannot
  resolve an organization and 404s instead of returning null.
- Client IDs are only taken from /apps/{segment} URL parts that are
  non-numeric; deploy output yields /apps/{numericAppId} URLs, which
  now fall back to a name search.
- The settings-page navigation clicks through the accounts.shopify.com
  account picker, which cold browser contexts bounce to — the main
  reason direct-URL app deletion has been failing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@isaacroldan
isaacroldan force-pushed the isaac/e2e-teardown-via-api branch from c6d8bce to 69bb1f6 Compare August 12, 2026 14:21
Comment thread packages/e2e/setup/app.ts Fixed
isaacroldan and others added 3 commits August 12, 2026 16:35
Settings pages under client-key URLs usually render without the Delete
button; the numeric-id form (what the dashboard links to and the CLI's
appDeepLink builds) works reliably — the run-level cleanup deletes
11/11 apps with it while key-form teardown deletes went 2/13. The app
GID from the API lookup provides the numeric id.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Assisted-By: devx/215513a9-13fa-4e74-bb8f-79faee6e4f09
@isaacroldan isaacroldan changed the title Use App Management API instead of browser for E2E teardown checks Correct E2E teardown ordering and remove browser gates Aug 14, 2026
Assisted-By: devx/215513a9-13fa-4e74-bb8f-79faee6e4f09
Assisted-By: devx/215513a9-13fa-4e74-bb8f-79faee6e4f09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants