Skip to content

ADR 0008: M2 Playwright happy path

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.

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 dev at http://127.0.0.1:8787/v1/health
  • Web: pnpm --filter @commitment-desk/web dev at http://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.

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.

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.

The committed test:

  1. signs in with the seeded reviewer’s magic link;
  2. searches for capture A, creates a parcel from its submitted fields, matches it, and accepts it;
  3. asserts capture.parcel_matched and capture.accepted in the audit timeline;
  4. searches for capture B, matches it to the parcel created in step 2, and returns it with a reason;
  5. asserts capture.returned and 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.

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.

  • 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.