ADR 0008: M2 Playwright happy path
- Status: Accepted
- Date: 2026-11-24
- Deciders: AP Dev Solutions, LLC
- Related: the project overview §14 (M2 done-when),
docs/adr/0003-m2-reviewer-sessions.md,docs/adr/0005-m2-parcel-resolution.md,openspec/changes/m2-playwright/design.md
Context
Section titled “Context”Unit, core, adapter, and API tests covered the reviewer workflow in pieces, but M2’s done-when is a browser flow: sign in, see a capture, match the parcel, accept or return it, and see the audit trail. Manual browser checks caught regressions during M2, but they were not committed and could not protect future changes.
Decisions
Section titled “Decisions”Playwright drives the real local stack
Section titled “Playwright drives the real local stack”playwright.config.ts runs Chromium against the real Vite web app and the real Wrangler API. The
config declares two webServer entries with readiness checks:
- API:
pnpm --filter @commitment-desk/api devathttp://127.0.0.1:8787/v1/health - Web:
pnpm --filter @commitment-desk/web devathttp://localhost:5173
Outside CI, reuseExistingServer lets the suite use an already-running pnpm dev. CI starts both
fresh. A jsdom-based test was rejected because it cannot prove cookies, proxying, navigation, and the
API contract together.
pnpm test:e2e seeds first
Section titled “pnpm test:e2e seeds first”The command is pnpm seed && playwright test. Seeding applies migrations and guarantees the synthetic
tenant, reviewer, admin, API key, and parcels exist. The suite reads .local-demo.json for the API
URL, API key, reviewer email, and town. It errors with a clear message if the file is missing.
The suite provisions its own captures
Section titled “The suite provisions its own captures”Each run generates a unique identifier used in permit numbers, map/lots, addresses, and idempotency
keys. The suite submits two captures through POST /v1/captures, then finds them through the real
inbox search. It does not rely on the seed’s parcel counts, leftover manual captures, or a clean
database.
Addresses are unique per run as well as map/lots. Parcel resolution matches by map/lot and then by address, so a repeated address across runs could silently attach a new capture to an old parcel.
One flow covers both dispositions
Section titled “One flow covers both dispositions”The committed test:
- signs in with the seeded reviewer’s magic link;
- searches for capture A, creates a parcel from its submitted fields, matches it, and accepts it;
- asserts
capture.parcel_matchedandcapture.acceptedin the audit timeline; - searches for capture B, matches it to the parcel created in step 2, and returns it with a reason;
- asserts
capture.returnedand the reason in the audit timeline.
This exercises new-parcel creation, existing-parcel matching, accept, return, search, and audit rendering in one fast test.
Selectors follow user-facing roles and labels
Section titled “Selectors follow user-facing roles and labels”The suite uses roles and labels such as Search, Create new parcel, Confirm accept, and
Reason (required). The audit timeline is the only class-based locator because it has no semantic
role; its action names and notes are the audit contract.
CI runs Chromium in its own job
Section titled “CI runs Chromium in its own job”A separate e2e job installs dependencies, runs pnpm exec playwright install --with-deps chromium,
and runs pnpm test:e2e. One Chromium project is deliberate; cross-browser coverage can be added if
the product supports more than one browser.
Consequences
Section titled “Consequences”- The M2 done-when is enforced automatically and is reproducible locally.
- Browser regressions in login, search, parcel matching, review actions, or the timeline fail CI.
- The suite writes synthetic captures to the local D1 database. That is acceptable because the data is synthetic and unique per run; it is not a hosted or production test.
- Cross-browser, visual, accessibility, performance, upload, admin, and error-path coverage remain future work.
- CI gains a browser download and roughly one extra job; the fast verify job is unchanged.