Plan: 100% Test Coverage — Supplemental (Sad Paths, Dark Theme, RBAC)
- Status
- Context
- Scope
- Steps
- Step 1: Integration — missing happy paths
- Step 2: Integration — state machine 409 tests
- Step 3: Integration — input validation 400 tests
- Step 4: Integration — RBAC 403 tests
- Step 5: E2E — dark theme accessibility audits
- Step 6: E2E — accessibility audits for missing pages
- Step 7: E2E — action effect verification
- Step 8: E2E — deny application workflow
- Files Touched
- Verification
- Documentation Updates
Status
| Step | Description | Status |
|---|---|---|
1 |
Integration: missing happy paths (5 endpoints) |
Done (2026-04-09) |
2 |
Integration: state machine 409 tests (5 services) |
Done (2026-04-09) |
3 |
Integration: input validation 400 tests (7 services) |
Done (2026-04-09) |
4 |
Integration: RBAC 403 tests (7 services missing wrong-role tests) |
Done (2026-04-09) |
5 |
E2E: dark theme accessibility audits (all pages, both themes) |
Done (2026-04-09) |
6 |
E2E: accessibility audits for missing pages (applications list, notices, appeals, 404) |
Done (2026-04-09) |
7 |
E2E: action effect verification with real seed data |
Done (2026-04-09) |
8 |
E2E: deny application workflow end-to-end |
Done (2026-04-09) |
Branch: test/100-pct-supplemental
Context
The primary test-coverage-100-pct plan achieved 100% endpoint coverage (178 integration tests, 75 E2E tests, 521 unit tests = 774 total). A follow-up audit identified remaining gaps:
-
Zero 409 tests — no state machine violation or uniqueness constraint is tested anywhere.
-
Zero input validation 400 tests — date range inversions, invalid enum values, missing required fields.
-
RBAC 403 only in 2 of 14 services — canopy-reporting and canopy-security have wrong-role tests; 7 other services with role guards do not.
-
Dark theme never tested — WCAG accessibility audits only run in browser default (light) mode. Dark theme has different color palettes and contrast ratios that must be independently verified.
-
5 pages lack accessibility audits — /applications list, /notices list, /appeals list, 404 error page.
-
5 endpoints lack happy-path tests — PUT applications, PATCH security alert, resolve discrepancy, resend notice, notice PDF with real data.
-
Action POST effects never verified — tests check HTTP < 500 but never verify the action created/modified the expected state.
Scope
In scope:
-
5 missing happy-path integration tests
-
5 state machine 409 tests (duplicate issuance, double-schedule, double-decide, double-terminate, duplicate interim contact)
-
~10 input validation 400 tests (invalid dates, enums, missing fields)
-
7 RBAC 403 tests (one per service missing wrong-role coverage)
-
Dark theme Playwright project in playwright.config.ts
-
All accessibility audits duplicated for dark theme
-
4 missing page accessibility audits
-
5 action effect E2E tests with real seed data
-
1 deny workflow E2E test
Out of scope:
-
Stub services (exchange, caps, wic, portal) — no routes to test
-
canopy-web BFF integration tests — covered by E2E
-
Load/performance testing
-
htmx partial response accessibility (axe-core operates on full pages only)
Steps
Step 1: Integration — missing happy paths
Files: services/canopy-applications/tests/application_test.rs, services/canopy-notices/tests/notices_test.rs, services/canopy-security/tests/security_test.rs, services/canopy-snap/tests/snap_test.rs
| Test Function | Endpoint | Assertion |
|---|---|---|
|
PUT /v1/applications/{id} |
Status 200, re-GET shows updated |
|
GET /v1/notices/{id}/pdf (happy path) |
Generate notice → GET /pdf → status 200, content-type contains "pdf" or "octet-stream" |
|
POST /v1/notices/{id}/resend |
Generate notice → resend → status 200 |
|
PATCH /v1/security/alerts/{id} |
List alerts → pick first → PATCH with |
|
PUT /v1/verification/discrepancies/{id}/resolve |
Create discrepancy via determine flow or seed → resolve → status 200 |
For resolve_discrepancy: this requires a discrepancy to exist, which requires IEVS match processing.
If no discrepancy exists in the DB, this test should be conditional (return early with warning).
Step 2: Integration — state machine 409 tests
Files: services/canopy-enrollment/tests/enrollment_test.rs, services/canopy-appeals/tests/appeals_test.rs, services/canopy-renewals/tests/renewals_test.rs
| Test Function | Action | Expected |
|---|---|---|
|
Create enrollment → issue April → issue April again |
Second issue returns 409 or 400 |
|
Create enrollment → terminate → terminate again |
Second terminate returns 409 or 400 |
|
File appeal → schedule hearing → schedule again |
Second schedule returns 404 (handler checks "not in pending status") |
|
File appeal → schedule → decide → decide again |
Second decide returns 404 (handler checks status) |
|
File appeal → withdraw → withdraw again |
Second withdraw returns 404 (handler checks status) |
Note: the appeals handlers return 404 with "not found or not in {status}" messages for state violations, not 409. Tests should assert the specific 404 with diagnostic message, not silently accept it.
Step 3: Integration — input validation 400 tests
Files: Multiple test files across services
| Test Function | Input | Expected |
|---|---|---|
|
start_date=2027-04-01, end_date=2026-04-01 |
400 or 422 |
|
GET /v1/params?household_size=0 |
400 |
|
GET /v1/abawd/tracking (no person_id or household_id) |
400 |
|
PUT /v1/verification/discrepancies/{id}/resolve with |
400 |
|
POST /v1/notices with |
400 |
|
POST change-report with |
400 or 422 |
|
POST /v1/appeals with |
400 or 422 |
|
POST /v1/applications with |
400 or accept (business logic may not validate) |
|
POST /v1/determine with |
400 or 500 (rules engine may reject) |
|
POST /v1/determine with |
400 or accept (handler may not validate) |
For each test: if the service doesn’t validate and returns 200/201, the test should still document the behavior.
Use assert!(resp.status == 400 || resp.status == 422, "service accepted invalid input — consider adding validation") where behavior is undefined.
Step 4: Integration — RBAC 403 tests
Files: RBAC test files across 7 services
Add a bob.smith (caseworker-only) 403 test to each service that has role-restricted endpoints above caseworker level.
| Service | Endpoint | Guard to Test |
|---|---|---|
canopy-snap |
POST /v1/determine |
|
canopy-tanf |
POST /v1/determine |
|
canopy-medicaid |
POST /v1/determine |
|
canopy-enrollment |
POST /v1/enrollments |
|
canopy-persons |
POST /v1/persons |
|
canopy-appeals |
POST /v1/appeals |
|
canopy-notices |
POST /v1/notices |
|
For services requiring caseworker_or_above: bob.smith (caseworker) will succeed, so 403 tests are only meaningful for services with higher role requirements (eligibility_specialist, supervisor, admin).
Meaningful 403 tests:
-
canopy-snap POST /determine → bob.smith 403
-
canopy-tanf POST /determine → bob.smith 403
-
canopy-medicaid POST /determine → bob.smith 403
-
canopy-enrollment POST /enrollments → bob.smith 403
-
canopy-tanf GET /fti-audit-log → jane.doe 403 (already exists ✓)
-
canopy-medicaid GET /fti-audit-log → jane.doe 403 (already exists ✓)
-
canopy-reporting GET /fns-388 → bob.smith 403 (already exists ✓)
-
canopy-security GET /events → bob.smith 403 (already exists ✓)
New tests needed: 4 (snap, tanf, medicaid, enrollment determine/create with bob.smith).
Step 5: E2E — dark theme accessibility audits
Files: tests/e2e/playwright.config.ts, tests/e2e/specs/accessibility.spec.ts
Add a dark-theme project to playwright.config.ts:
{
name: 'dark-theme',
use: {
...devices['Desktop Chrome'],
storageState: 'auth/caseworker.json',
colorScheme: 'dark',
},
dependencies: ['auth-setup'],
testMatch: /accessibility/,
}
This runs all 5 existing accessibility tests in dark theme automatically via Playwright’s colorScheme option.
The data-theme attribute on <html> defaults to system, and with colorScheme: 'dark' the browser reports dark preference, triggering prefers-color-scheme: dark CSS.
Also add a JavaScript injection to force data-theme="dark" before axe runs, in case the application uses data-theme rather than prefers-color-scheme:
// In accessibility.spec.ts, for dark-theme project:
test.beforeEach(async ({ page }) => {
await page.addInitScript(() => {
document.documentElement.setAttribute('data-theme', 'dark');
});
});
Alternatively, use a separate accessibility-dark.spec.ts that sets data-theme="dark" explicitly.
Step 6: E2E — accessibility audits for missing pages
Files: tests/e2e/specs/accessibility.spec.ts
Add axe audits for 4 missing pages:
test('applications list', async ({ page }) => {
await page.goto('/applications');
await auditPage(page, 'applications-list');
});
test('notices list', async ({ page }) => {
await page.goto('/notices');
await auditPage(page, 'notices-list');
});
test('appeals list', async ({ page }) => {
await page.goto('/appeals');
await auditPage(page, 'appeals-list');
});
test('404 error page', async ({ page }) => {
await page.goto('/nonexistent-page-for-a11y-test');
await auditPage(page, 'error-404');
});
Step 7: E2E — action effect verification
Files: tests/e2e/specs/actions.spec.ts
Replace fake UUID tests with real seed data and effect verification:
| Test | Verification |
|---|---|
|
Navigate to /applications/{expedited.id}/process → click Approve → |
|
POST /appeals/file with seed household → navigate to /appeals → verify table contains household reference |
|
Get cert_id from seed → POST /actions/interim-contact with real IDs → verify 200/302 → navigate to case detail → click activity tab → verify contact logged |
|
Same pattern as interim contact but with change report |
|
Same pattern — may need to create tracking record first |
For tests that require real seed data that may not be in the correct state, use test.skip() with a descriptive message.
Step 8: E2E — deny application workflow
Files: tests/e2e/specs/applications.spec.ts
Full deny workflow test:
test('deny application with reason', async ({ page }) => {
const app = applicationsList.find(a => a.expedited);
test.skip(!app, 'No expedited app');
await page.goto(`/applications/${app!.id}/process`);
await page.waitForLoadState('networkidle');
// Open deny modal
await page.click('button:has-text("Deny")');
const modal = page.locator('.modal, [role="dialog"]');
await expect(modal).toBeVisible({ timeout: 5_000 });
// Select denial reason
const select = modal.locator('select');
const options = await select.locator('option').allTextContents();
expect(options.length).toBeGreaterThan(1);
await select.selectOption({ index: 1 }); // First non-placeholder option
// Submit
const submitBtn = modal.locator('button:has-text("Confirm"), button[type="submit"]');
if (await submitBtn.isVisible()) {
await submitBtn.click();
await page.waitForLoadState('networkidle', { timeout: 10_000 });
// Should redirect or show confirmation — not crash
const content = await page.content();
expect(content.toLowerCase()).not.toContain('internal server error');
}
});
Files Touched
| File | Change |
|---|---|
|
Add PUT update test, negative expedited income test |
|
Add PDF happy path, resend test, invalid template 400 test |
|
Add PATCH alert update test |
|
Add resolve discrepancy, params 400, ABAWD 400, bob.smith 403 |
|
Add duplicate issuance 409, terminate 409, date validation 400, bob.smith 403 |
|
Add duplicate interim contact 409, invalid change_type 400 |
|
Add double-schedule 409, double-decide 409, invalid program 400 |
|
Add bob.smith 403 test |
|
Add bob.smith 403 test |
|
Add dark-theme project |
|
Add 4 missing page audits |
|
NEW — dark theme accessibility audits for all pages |
|
Replace fake UUID tests with real seed data + effect verification |
|
Add deny workflow test |
Verification
-
cargo xtask test --unit— all unit tests pass (521+) -
cargo xtask test— all integration tests pass (target: 210+) -
cargo xtask e2e— all E2E tests pass (target: 90+, including dark theme a11y) -
cargo clippy --all-targets — -D warnings— zero warnings -
Every service with role guards has at least one 403 test for the guarded role
-
Every service with state machine transitions has at least one 409/conflict test
-
Accessibility audits pass with zero critical violations in both light and dark themes
-
No test uses fake UUIDs (00000000-…) for action effect tests