/e2e-test-fixture
The Playwright planner and generator agents produce tests that assume an authenticated user and seeded state. This skill supplies that scaffolding so generated tests actually run against the running stack. Without it they fail at the sign-in redirect.
Runs in flow-frontend. E2E lives in packages/playwright-flow-factory (targets
flow-factory on port 3001) and packages/playwright-flow-global (targets flow-global on
3000). Shared auth/seeding helpers live in packages/playwright-shared (support/ modules,
re-exported from index.ts). Read that index.ts for the current fixture API — do not rely
on a memorized list of exports. Names drift.
Prerequisites
- The target app and its backing services are running locally (see
local-clusterin the workspaceCLAUDE.md). Identity service must be reachable for seeding. - The app is configured to authenticate against the local
authtestmock OIDC: setOKTA_ISSUER=http://localhost:9000in the app's.env.development.
Steps
Pick the app package.
playwright-flow-factory(3001) orplaywright-flow-global(3000). Each has its ownplaywright.config.tsand asetupproject that runssupport/auth.setup.tsbefore the test project, saving storage state to.auth/user.json.Seed the user and capabilities in
auth.setup.tsusing the capability helper exported by@hadrian-mtv/playwright-shared(it talks to the identity service —IDENTITY_SERVICE_URL, defaulthttp://localhost:2341). Readpackages/playwright-shared/index.tsandsupport/capabilities.tsfor the current API and the shared test user id rather than trusting a remembered signature. Upsert the test employee, then grant the minimum capabilities the scenario exercises — broad grants hide permission-gating bugs.Authenticate via the auth helper from
@hadrian-mtv/playwright-shared(support/auth.ts). It walks the NextAuth + authtest redirect chain (/api/auth/signin→ authtest → callback → home), verifies the session, and writes storage state to.auth/user.json. The test project reuses it viastorageStateso tests start logged in.Seed domain state the scenario needs before the test acts — create the work order, part, or PO through the same backend services, not by stubbing the UI. The test should drive the real stack; faked state is the mock-heavy anti-pattern the team rejects.
Point the runner at the stack. Leaving
PLAYWRIGHT_BASE_URLunset makes the config auto-startpnpm dev:flow-<app>on the right port; set it (e.g. in CI/Docker) to run against an already-running server and skip the auto-start.Run.
pnpm test:e2e:flow-factoryorpnpm test:e2e:flow-global. On failure, open the report with the matching:reportscript and check the trace.
Notes
- The shared test user id and the auth/capability helpers live in
playwright-shared— reuse them; do not hardcode a new user id per package. - If sign-in flakes with a proxy 502, the auth helper already retries; a persistent failure
means the app isn't up or
OKTA_ISSUERisn't pointed at authtest.