Plan: Playwright E2E Test Suite
Status
| Step | Description | Status |
|---|---|---|
1 |
Project scaffold (package.json, playwright.config.ts, tsconfig.json, Dockerfile) |
Done (2026-04-05) |
2 |
Auth setup (Keycloak OIDC browser login for 3 users, storage state) |
Done (2026-04-05) |
3 |
Helpers (waitForHtmx, clickTab) + 6 page objects |
Done (2026-04-05) |
4 |
Auth + dashboard + navigation specs (25 tests) |
Done (2026-04-05) |
5 |
Case search + case detail specs (18 tests) |
Done (2026-04-05) |
6 |
Applications + renewals specs (12 tests) |
Done (2026-04-05) |
7 |
RBAC + accessibility specs (8 tests) |
Done (2026-04-05) |
8 |
Wire xtask e2e + docker-compose e2e service + healthchecks on all 19 services |
Done (2026-04-05) |
9 |
Validate against live devstack, documentation |
Done (2026-04-26) — |
Epic: &43
Issues: TBD
Branch: feature/playwright-e2e
Labels: type::feature, priority::high, program::infrastructure, service::web
Context
The worker portal has wired handlers, seed data, OIDC auth, and a TypeScript manifest. E2E tests are the last gate before security hardening. This implements worker-portal-snap Step 10 (Playwright E2E), expanding the 5 scenarios in that plan to 61 comprehensive tests.
The test suite follows CRAIG’s proven pattern: Dockerized Playwright, real Keycloak login, page objects, seed-independent assertions.
Scope
In scope:
-
Dockerized Playwright via docker-compose
e2eprofile -
Real Keycloak OIDC browser login (PKCE S256) for jane.doe, bob.smith, admin
-
6 page objects (dashboard, case search, case detail, application, renewal, login)
-
9 spec files: auth (6), dashboard (7), case-search (7), case-detail (11), applications (8), renewals (4), navigation (10), rbac (3), accessibility (5 gated)
-
All assertions seed-independent (structural, not value-based)
-
Docker healthchecks on all 19 application services
-
cargo xtask e2ecommand matching CRAIG’s pattern
Out of scope:
-
Security hardening tests (separate plan, depends on this)
-
Performance/load testing (separate plan)
-
Service-to-service auth token (known gap — tests handle gracefully)
Design
Dockerized Execution
Tests run in the official mcr.microsoft.com/playwright Docker image.
The canopy-e2e service is gated behind the e2e profile so it doesn’t start with normal docker compose up.
cargo xtask e2e regenerates the seed manifest, builds the Playwright image, and runs tests.
Auth Setup
Real Keycloak browser login for each test user — no mocked sessions.
Storage state saved per role: auth/caseworker.json, auth/bob-smith.json, auth/admin.json.
Subsequent test projects load storage state so every spec starts authenticated.
Seed-Independent Assertions
Tests use semantic predicates (findApproved(), findExpedited()) to navigate to entities.
Assertions check structure ("table has rows", "element is visible") not values ("name is Golda").
Tests pass with any seed value, not just seed 42.
Healthchecks
All 19 application services now have Docker healthchecks (wget -qO- http://localhost:{port}/healthz).
The E2E container depends on canopy-web: condition: service_healthy.
Steps
Files Touched
| File | Change |
|---|---|
|
Playwright config, auth setup, helpers, page objects, 9 spec files, Dockerfile |
|
Wire to docker compose --profile e2e |
|
Add canopy-e2e service + healthchecks on all 19 app services |
Verification
-
cargo xtask dev restart --shared-db -
cargo xtask seed --seed 42 --households 50 -
cargo xtask e2e— 59 tests pass (5 accessibility skipped) -
cargo xtask seed --seed 99 --households 50→cargo xtask e2e— still passes -
CANOPY_A11Y_AUDIT=1 cargo xtask e2e— accessibility audit runs -
JUnit XML at
test-results/e2e/results.xml
Documentation Updates
-
.claude/docs/local-dev.md— documentcargo xtask e2e -
CHANGELOG.adoc— entry for E2E test suite -
docs/modules/ROOT/pages/plans/worker-portal-snap.adoc— mark Step 10 complete
Errata
Infrastructure bugs discovered during E2E validation
-
Session store database misconfiguration — canopy-web and canopy-portal were both using
canopy_securityas their DATABASE_URL. The tower-sessions-sqlx-store migration silently failed because canopy-security’s_sqlx_migrationstable already existed. Fixed by creating dedicatedcanopy_webandcanopy_portaldatabases indevstack/postgres/init.sql. CRAIG avoids this entirely by usingMemoryStore. -
Static assets missing from Docker runtime — The
Dockerfileruntime stage copied binaries and rulesets but notservices/canopy-web/static/(htmx.min.js, alpine.min.js). AddedCOPY --from=builderfor BFF static assets. -
SRI integrity hash mismatch — htmx and Alpine.js were loaded from unpkg CDN with incorrect SHA-384 integrity hashes. The browser silently blocked both scripts (SRI failure does not trigger
onerror). Switched to local-only vendor loading matching CRAIG’s pattern. CDN loading with SRI is unreliable for air-gapped and Dockerized environments. -
OIDC callback hardcoded redirect —
auth::callback()always redirected to/after login. Addedreturn_toURL preservation so users land back on the page they were trying to reach. This is an improvement over CRAIG’s pattern (which also hardcodes/).
Potential Improvements
-
Service-to-service auth — BFF calls to upstream services (canopy-applications, canopy-security, etc.) return 401. The application process page renders but with empty/default data. Needs a service account or token forwarding mechanism.
-
Vendored JS dependency tracking — htmx.min.js and alpine.min.js are vendored without version tracking. Consider a
vendor.tomlmanifest checked bycargo xtask validate. -
Session cookie persistence — With PostgresStore, each E2E test still re-authenticates via Keycloak SSO because the storageState cookie references a session from the auth-setup project which gets a different session ID after the redirect chain. The
return_topattern makes this transparent but a session-aware test setup could reduce auth round-trips.
Tracked follow-ups (filed 2026-04-24 after audit of plan Errata + Potential Improvements sections across the repo):
Tracked follow-ups (filed 2026-05-04 during PI sweep):
-
#411 — Resolved 2026-05-05 via OIDC RFC 6749 refresh_token grant in canopy-web’s
AuthenticatedWorkerextractor. Worker portal no longer 401s after the access-token TTL elapses. See bff-token-refresh.