Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
613e20c to
bf4a32b
Compare
67d2e41 to
97411c9
Compare
bf4a32b to
a7f4fd5
Compare
97411c9 to
7b3f2da
Compare
a7f4fd5 to
47a7f22
Compare
7b3f2da to
c9fc623
Compare
47a7f22 to
1c6838f
Compare
1c6838f to
73d2cae
Compare
c9fc623 to
4e400ce
Compare
73d2cae to
de46b8d
Compare
3be5740 to
96e0270
Compare
96e0270 to
68d2d07
Compare
de46b8d to
3a6b042
Compare
68d2d07 to
d98268a
Compare
3a6b042 to
5a5c2f7
Compare
5a5c2f7 to
60d2a44
Compare
d98268a to
d8abeab
Compare
d8abeab to
b844449
Compare
60d2a44 to
38c34a9
Compare
b844449 to
6df7f48
Compare
38c34a9 to
425707b
Compare
| const nextHref = await nextLink.getAttribute('href') | ||
| if (!nextHref) break | ||
| const nextUrl = nextHref.startsWith('http') ? nextHref : `https://dev.shopify.com${nextHref}` | ||
| await page.goto(nextUrl, {waitUntil: 'domcontentloaded'}) |
There was a problem hiding this comment.
Pagination uses locator.isVisible({timeout}), which does not wait and can skip later pages
findAppsOnDashboard() assumes nextLink.isVisible({ timeout: ... }) waits for the pagination control to appear, but this codebase already documents that modern Playwright does not wait in locator.isVisible(). The script only does goto(..., { waitUntil: 'domcontentloaded' }) plus a fixed sleep before checking pagination, so if the dashboard renders the next link slightly later, discovery will stop on the current page and miss later apps. The same pattern is also used for button#nextURL in the installs-page flow, so later installs pages can be skipped too. This is consistent with existing project guidance: setup/browser.ts explicitly says to use isVisibleWithin(), and setup/app.ts already uses that helper for the same dashboard pagination case. The result is silent partial cleanup: operators can run the tool and never scan all apps or installs, leaving orphaned E2E apps in the dev org.
React with 👍/👎 — all feedback helps improve the agent.

WHY are these changes introduced?
E2E tests create apps that can accumulate when tests fail mid-run, CI times out, or teardown fails. This script automates bulk-clean for leftover apps.
WHAT is this pull request doing?
cleanup-apps.tsStandalone cleanup script that finds leftover E2E test apps on the Dev Dashboard, uninstalls them from all stores, and deletes them.
Logic
The per-app mechanics delegate to the shared
setup/building blocks (uninstallAppFromStore,deleteAppFromDevDashboard,refreshIfPageError) — same primitives used by per-test teardown. The script adds bulk discovery, pagination, and per-app retry on top.Discovery phase:
completeLoginhelperrefreshIfPageErrorup to 3× as extra resilience on 500/502 (hard-fails after 3 attempts)a[href*=\"/apps/\"]selectorsE2E-)a[href*=\"next_cursor\"];refreshIfPageErrorruns at the top of every iteration so error-page returns throw instead of silently yielding 0 appsUninstall (per app):
{appUrl}/installspage.content())button#nextURLand repeat 2–3 on each pageuninstallAppFromStore(page, slug, appName)— the shared setup helper navigates to the store's/settings/apps, clicks the ⋯ menu → Uninstall → confirm, then reloads and verifies the app is gone. Returnstrueif gone (or already absent),falseif still listed.falseor throws: markallUninstalled = falseand log the store slug + error{appUrl}/installs, scan every row across all pages — any non-empty row → returnfalseallUninstalledDelete (per app):
deleteAppFromDevDashboard(page, appUrl)— the shared setup helper navigates to{appUrl}/settings, clicks Delete app (scroll + reload-once fallback for the button's propagation lag), types "DELETE" if the confirm input is present, clicks confirm, then reloads and returnstrueon 404 (deleted) orfalseotherwise. ThrowsSTILL_HAS_INSTALLSif the Delete button stays disabled after reload (fail-fast signal — retries won't help).falseas "deletion could not be verified" and retry via the outer loop.Per-app retry wrapper:
(N/3) failed: ...), wait, re-navigate to dashboard, retry the full uninstall + delete flowSTILL_HAS_INSTALLSshort-circuits the retry loop → record as skipped(Xs)); summary printed at end:X succeeded, Y skipped, Z failed (Xs total)--listmode: runs discovery only, prints app names and install counts.--uninstallmode: runs uninstall only, skips apps with 0 installs.--deletemode: runs delete only, skips apps with installs > 0.Features:
setup/building blocks — single source of truth for per-store uninstall and per-app delete semantics (shared with per-test teardown)refreshIfPageErrorhelper — hard-fails after 3 consecutive 500/502 responsesSTILL_HAS_INSTALLS(fail-fast skip)cleanupAllApps()for use as a Playwright globalTeardown or from other scriptsHow is this different from per-test teardown?
setup/teardown.ts) — knows the specific app name and store FQDN, uses direct URLs, no discovery. Runs automatically in test `finally` blocks.How to test your changes?
pnpm --filter e2e exec tsx scripts/cleanup-apps.ts --listpnpm --filter e2e exec tsx scripts/cleanup-apps.ts --headedExample
pnpm --filter e2e exec tsx scripts/cleanup-apps.ts --headedcleanup-apps.mov
Expand for complete log
Post-release steps
Checklist