Generate Scenario Tests
You are generating Playwright test files from plain English scenario descriptions.
Process
- •
Read ALL scenario files from
test/scenarios/*.md - •
Read the shared test harness at
test/scenarios/generated/helpers.ts - •
Read the existing generated test as a template:
test/scenarios/generated/spawn-single-session.spec.ts - •
For each scenario file, read the relevant React components to understand:
- •What
data-testidattributes exist (search fordata-testidinassets/dashboard/src/) - •What routes exist (
assets/dashboard/src/App.tsx) - •What API endpoints are called (
internal/dashboard/handlers.go)
- •What
- •
For each scenario file, generate a
.spec.tsfile intest/scenarios/generated/- •File name: same as scenario file but with
.spec.tsextension - •Follow the exact patterns from the template test
- •Use
data-testidselectors where available, fall back to role-based selectors - •Include both browser assertions (Playwright expects) and API assertions (fetch calls)
- •Map
## Preconditionstotest.beforeAllsetup - •Map
## Verificationsto test assertions
- •File name: same as scenario file but with
Rules
- •Use helpers from
helpers.ts— do NOT duplicate helper logic in tests - •Use
data-testidselectors as the primary selector strategy - •Each scenario file produces exactly one
.spec.tsfile - •Each
.spec.tsfile has onetest.describeblock with one or moretestblocks - •Use real agent commands like
sh -c 'echo hello; sleep 600'for test agents (mirrorsinternal/e2e/e2e.goline 240) - •Always call
waitForHealthy()inbeforeAll - •Always call
waitForDashboardLive(page)after navigation - •Set reasonable timeouts for async operations (15s for spawn, 10s for WebSocket)
Output
After generating all test files, run:
bash
cd test/scenarios/generated && npx tsc --noEmit
Report any type errors and fix them before presenting the results.