Generate Scenario Tests
You are generating Playwright test files from plain English scenario descriptions.
Process
Read ALL scenario files from
test/scenarios/*.mdRead the shared test harness at
test/scenarios/generated/helpers.tsRead the existing generated test as a template:
test/scenarios/generated/spawn-single-session.spec.tsFor each scenario file, read the relevant React components to understand:
- What
data-testidattributes exist (search fordata-testidinassets/dashboard/src/) - For
<select>controls, what the actual<option value>strings are (do not assume labels map to values) - 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 - When selecting dropdown options in Playwright, use the real option
value(e.g.__multiple__), not a guessed label-derived value - 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:
cd test/scenarios/generated && npx tsc --noEmit
Report any type errors and fix them before presenting the results.
Verification
After type-checking passes, run the generated scenario tests to confirm they pass end-to-end:
./test.sh --scenarios --run '<scenario name>'
Replace <scenario name> with the test describe block name (e.g., 'Remote access onboarding').
If multiple scenarios were generated, run each one. Fix any failures before presenting the results.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.