Skip to content

E2E: cleanup utility#7171

Open
phyllis-sy-wu wants to merge 2 commits intopsyw-0401-E2E-migrate-remaining-tests-to-use-new-infrafrom
psyw-0402-E2E-cleanup-utility
Open

E2E: cleanup utility#7171
phyllis-sy-wu wants to merge 2 commits intopsyw-0401-E2E-migrate-remaining-tests-to-use-new-infrafrom
psyw-0402-E2E-cleanup-utility

Conversation

@phyllis-sy-wu
Copy link
Copy Markdown
Contributor

@phyllis-sy-wu phyllis-sy-wu commented Apr 2, 2026

WHY are these changes introduced?

E2E tests create apps on the Dev Dashboard that can accumulate over time — especially when tests fail mid-run, CI times out, or cleanup is skipped during development. This PR adds:

  1. Standalone cleanup utility (scripts/cleanup.ts) — bulk cleanup of leftover apps via browser automation
  2. E2E_SKIP_CLEANUP toggle — env var to disable per-test teardown for debugging
  3. Improved teardownApp — rewritten with browser login, dashboard search, direct FQDN-based uninstall, and retry logic

WHAT is this pull request doing?

New: scripts/cleanup.ts

Standalone cleanup script that finds E2E test apps on the Dev Dashboard, uninstalls them from all stores, and deletes them.

pnpm test:e2e-cleanup              # Full cleanup: uninstall + delete
pnpm test:e2e-cleanup -- --list    # List matching apps without action
pnpm test:e2e-cleanup -- --delete  # Delete only (skip apps still installed)
pnpm test:e2e-cleanup -- --headed  # Show browser window
pnpm test:e2e-cleanup -- --pattern X   # Match apps containing "X" (default: "E2E-")

Features:

  • Browser-based login via shared completeLogin helper
  • Dashboard pagination — finds apps across all pages
  • Install count from dashboard card text — no extra navigation needed
  • Per-app retry with configurable max retries (default: 2)
  • Per-app and total timing in output
  • All timeouts use shared BROWSER_TIMEOUT constants
  • Exports cleanupAllApps() for use as a Playwright globalTeardown in the future

Updated: teardownApp in setup/app.ts

Rewritten with a reliable 4-step flow:

  1. Login — authenticates browser via completeLogin (browser isn't authenticated on dev.shopify.com from the test's OAuth flow)
  2. Find app — navigates to dashboard with ?search={appName} (fast, no pagination)
  3. Uninstall (if installed) — goes directly to admin.shopify.com/store/{slug}/settings/apps via known FQDN
  4. Delete — goes to app settings page with retry loop for uninstall propagation delay

All timeouts use shared BROWSER_TIMEOUT constants. Debug logging when DEBUG=1.

E2E_SKIP_CLEANUP toggle

All test finally blocks check this env var. When set, both local file cleanup and remote app teardown are skipped:

E2E_SKIP_CLEANUP=1 DEBUG=1 pnpm --filter e2e exec playwright test
# Apps remain on dashboard for inspection. Clean up later with: pnpm test:e2e-cleanup

Design: two cleanup mechanisms

  • teardownApp (per-test, automatic) — knows the app name and store FQDN, uses direct URLs, no discovery. Runs in test finally blocks.
  • cleanup.ts (bulk, manual) — discovers all matching apps via dashboard pagination, discovers stores via store switcher. Safety net for orphaned apps.

How to test your changes?

Cleanup script:

  1. Create test apps: E2E_SKIP_CLEANUP=1 DEBUG=1 pnpm --filter e2e exec playwright test app-deploy
  2. List them: pnpm test:e2e-cleanup -- --list
  3. Clean up: pnpm test:e2e-cleanup -- --headed

Per-test teardown:

  1. Run: DEBUG=1 pnpm --filter e2e exec playwright test app-deploy
  2. Check output for [e2e] teardown: steps (login, find, uninstall, delete)

Measuring impact

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Copy Markdown
Contributor Author

phyllis-sy-wu commented Apr 2, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@phyllis-sy-wu phyllis-sy-wu added the #gsd:49408 Agentic app validation label Apr 2, 2026
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0402-E2E-cleanup-utility branch 4 times, most recently from 5c6b425 to 7e992d2 Compare April 2, 2026 22:23
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0401-E2E-migrate-remaining-tests-to-use-new-infra branch from 1d49241 to 8be6206 Compare April 2, 2026 22:24
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0402-E2E-cleanup-utility branch 3 times, most recently from b83a2b2 to 42157aa Compare April 3, 2026 00:45
@phyllis-sy-wu phyllis-sy-wu marked this pull request as ready for review April 3, 2026 00:48
@phyllis-sy-wu phyllis-sy-wu requested a review from a team as a code owner April 3, 2026 00:48
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0402-E2E-cleanup-utility branch from 42157aa to bc5f2f8 Compare April 6, 2026 19:42
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0401-E2E-migrate-remaining-tests-to-use-new-infra branch from 8be6206 to 3a642b1 Compare April 6, 2026 19:42
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0402-E2E-cleanup-utility branch from bc5f2f8 to 14613f3 Compare April 7, 2026 03:40
@phyllis-sy-wu phyllis-sy-wu mentioned this pull request Apr 7, 2026
3 tasks
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0401-E2E-migrate-remaining-tests-to-use-new-infra branch from 3a642b1 to a7567f7 Compare April 7, 2026 18:41
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0402-E2E-cleanup-utility branch 2 times, most recently from f902ebd to 1899bb0 Compare April 8, 2026 16:21
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0401-E2E-migrate-remaining-tests-to-use-new-infra branch from a7567f7 to 0e2a505 Compare April 8, 2026 16:21
@phyllis-sy-wu phyllis-sy-wu changed the base branch from psyw-0401-E2E-migrate-remaining-tests-to-use-new-infra to graphite-base/7171 April 8, 2026 18:46
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0402-E2E-cleanup-utility branch from 1899bb0 to 2d2cfbe Compare April 9, 2026 04:31
@phyllis-sy-wu phyllis-sy-wu changed the base branch from graphite-base/7171 to psyw-0401-E2E-migrate-remaining-tests-to-use-new-infra April 9, 2026 04:31
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0402-E2E-cleanup-utility branch from 2d2cfbe to a91fa51 Compare April 9, 2026 06:11
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0401-E2E-migrate-remaining-tests-to-use-new-infra branch from 04cbb24 to 57c09aa Compare April 9, 2026 06:11
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0402-E2E-cleanup-utility branch from a91fa51 to 98fd534 Compare April 9, 2026 06:30
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0401-E2E-migrate-remaining-tests-to-use-new-infra branch from 57c09aa to 9aa7b21 Compare April 9, 2026 14:38
@phyllis-sy-wu phyllis-sy-wu force-pushed the psyw-0402-E2E-cleanup-utility branch from 98fd534 to 0460404 Compare April 9, 2026 14:38
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/private/node/ui.d.ts
 import { Logger, LogLevel } from '../../public/node/output.js';
-import React from 'react';
 import { Key, RenderOptions } from 'ink';
 import { EventEmitter } from 'events';
-/**
- * Signal that the current Ink tree is done. Must be called within an
- * InkLifecycleRoot — throws if the provider is missing so lifecycle
- * bugs surface immediately instead of silently hanging.
- */
-export declare function useComplete(): (error?: Error) => void;
-/**
- * Root wrapper for Ink trees. Owns the single `exit()` call site — children
- * signal completion via `useComplete()`, which sets state here. The `useEffect`
- * fires post-render, guaranteeing all batched state updates have been flushed
- * before the tree is torn down.
- */
-export declare function InkLifecycleRoot({ children }: {
-    children: React.ReactNode;
-}): React.JSX.Element;
 interface RenderOnceOptions {
     logLevel?: LogLevel;
     logger?: Logger;
     renderOptions?: RenderOptions;
 }
 export declare function renderOnce(element: JSX.Element, { logLevel, renderOptions }: RenderOnceOptions): string | undefined;
-export declare function render(element: JSX.Element, options?: RenderOptions): Promise<void>;
+export declare function render(element: JSX.Element, options?: RenderOptions): Promise<unknown>;
 export declare class Stdout extends EventEmitter {
     columns: number;
     rows: number;
     readonly frames: string[];
     private _lastFrame?;
     constructor(options: {
         columns?: number;
         rows?: number;
     });
     write: (frame: string) => void;
     lastFrame: () => string | undefined;
 }
 export declare function handleCtrlC(input: string, key: Key, exit?: () => void): void;
 export {};
packages/cli-kit/dist/public/node/ui.d.ts
@@ -34,7 +34,7 @@ export interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps
  * 00:00:00 │ frontend │ third frontend message
  *
  */
-export declare function renderConcurrent({ renderOptions, ...props }: RenderConcurrentOptions): Promise<void>;
+export declare function renderConcurrent({ renderOptions, ...props }: RenderConcurrentOptions): Promise<unknown>;
 export type AlertCustomSection = CustomSection;
 export type RenderAlertOptions = Omit<AlertOptions, 'type'>;
 /**

@phyllis-sy-wu phyllis-sy-wu requested a review from ryancbahan April 9, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:49408 Agentic app validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant