Plan: 100% Test Coverage — Supplemental (Sad Paths, Dark Theme, RBAC)

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:

  1. Zero 409 tests — no state machine violation or uniqueness constraint is tested anywhere.

  2. Zero input validation 400 tests — date range inversions, invalid enum values, missing required fields.

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

  4. 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. 5 pages lack accessibility audits — /applications list, /notices list, /appeals list, 404 error page.

  6. 5 endpoints lack happy-path tests — PUT applications, PATCH security alert, resolve discrepancy, resend notice, notice PDF with real data.

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

update_application_changes_channel

PUT /v1/applications/{id}

Status 200, re-GET shows updated submission_channel

get_generated_notice_pdf_returns_binary

GET /v1/notices/{id}/pdf (happy path)

Generate notice → GET /pdf → status 200, content-type contains "pdf" or "octet-stream"

resend_notice_returns_200

POST /v1/notices/{id}/resend

Generate notice → resend → status 200

update_alert_to_resolved

PATCH /v1/security/alerts/{id}

List alerts → pick first → PATCH with {"status": "resolved"} → status 200, status == "resolved"

resolve_discrepancy_changes_status

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

duplicate_issuance_same_month_returns_conflict

Create enrollment → issue April → issue April again

Second issue returns 409 or 400

terminate_already_terminated_returns_conflict

Create enrollment → terminate → terminate again

Second terminate returns 409 or 400

schedule_already_scheduled_hearing_returns_conflict

File appeal → schedule hearing → schedule again

Second schedule returns 404 (handler checks "not in pending status")

decide_already_decided_appeal_returns_conflict

File appeal → schedule → decide → decide again

Second decide returns 404 (handler checks status)

withdraw_already_withdrawn_appeal_returns_conflict

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

enrollment_start_after_end_returns_400

start_date=2027-04-01, end_date=2026-04-01

400 or 422

snap_params_household_size_zero_returns_400

GET /v1/params?household_size=0

400

snap_abawd_tracking_no_filter_returns_400

GET /v1/abawd/tracking (no person_id or household_id)

400

snap_invalid_resolution_status_returns_400

PUT /v1/verification/discrepancies/{id}/resolve with resolution_status: "invalid"

400

notices_invalid_template_key_returns_400

POST /v1/notices with template_key: "nonexistent_template"

400

renewals_invalid_change_type_returns_400

POST change-report with change_type: "invalid_type"

400 or 422

appeals_invalid_program_returns_400

POST /v1/appeals with program: "nonexistent"

400 or 422

applications_negative_expedited_income_returns_400

POST /v1/applications with gross_monthly_income_cents: -1

400 or accept (business logic may not validate)

tanf_determine_zero_household_returns_400

POST /v1/determine with household_size: 0

400 or 500 (rules engine may reject)

medicaid_determine_negative_age_returns_400

POST /v1/determine with age: -1

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

require_eligibility_specialist_or_above — bob.smith (caseworker) should get 403

canopy-tanf

POST /v1/determine

require_eligibility_specialist_or_above — bob.smith should get 403

canopy-medicaid

POST /v1/determine

require_eligibility_specialist_or_above — bob.smith should get 403

canopy-enrollment

POST /v1/enrollments

require_eligibility_specialist_or_above — bob.smith should get 403

canopy-persons

POST /v1/persons

require_caseworker_or_above — bob.smith should succeed (caseworker is valid); test unauthenticated only

canopy-appeals

POST /v1/appeals

require_caseworker_or_above — bob.smith should succeed; test unauthenticated only

canopy-notices

POST /v1/notices

require_caseworker_or_above — bob.smith should succeed; test unauthenticated only

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

approve_application_creates_determination

Navigate to /applications/{expedited.id}/process → click Approve → waitForURL(/cases/) → navigate to case detail → click determination tab → verify content contains "ELIGIBLE" or "INELIGIBLE" or "Pending"

file_appeal_appears_in_list

POST /appeals/file with seed household → navigate to /appeals → verify table contains household reference

interim_contact_with_real_certification

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

change_report_with_real_certification

Same pattern as interim contact but with change report

abawd_activity_with_real_tracking

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

services/canopy-applications/tests/application_test.rs

Add PUT update test, negative expedited income test

services/canopy-notices/tests/notices_test.rs

Add PDF happy path, resend test, invalid template 400 test

services/canopy-security/tests/security_test.rs

Add PATCH alert update test

services/canopy-snap/tests/snap_test.rs

Add resolve discrepancy, params 400, ABAWD 400, bob.smith 403

services/canopy-enrollment/tests/enrollment_test.rs

Add duplicate issuance 409, terminate 409, date validation 400, bob.smith 403

services/canopy-renewals/tests/renewals_test.rs

Add duplicate interim contact 409, invalid change_type 400

services/canopy-appeals/tests/appeals_test.rs

Add double-schedule 409, double-decide 409, invalid program 400

services/canopy-tanf/tests/tanf_test.rs

Add bob.smith 403 test

services/canopy-medicaid/tests/medicaid_test.rs

Add bob.smith 403 test

tests/e2e/playwright.config.ts

Add dark-theme project

tests/e2e/specs/accessibility.spec.ts

Add 4 missing page audits

tests/e2e/specs/accessibility-dark.spec.ts

NEW — dark theme accessibility audits for all pages

tests/e2e/specs/actions.spec.ts

Replace fake UUID tests with real seed data + effect verification

tests/e2e/specs/applications.spec.ts

Add deny workflow test

Verification

  1. cargo xtask test --unit — all unit tests pass (521+)

  2. cargo xtask test — all integration tests pass (target: 210+)

  3. cargo xtask e2e — all E2E tests pass (target: 90+, including dark theme a11y)

  4. cargo clippy --all-targets — -D warnings — zero warnings

  5. Every service with role guards has at least one 403 test for the guarded role

  6. Every service with state machine transitions has at least one 409/conflict test

  7. Accessibility audits pass with zero critical violations in both light and dark themes

  8. No test uses fake UUIDs (00000000-…​) for action effect tests

Documentation Updates

  • docs/modules/ROOT/pages/plans/test-coverage-100-pct.adoc — mark all steps complete

  • .claude/docs/testing.md — update test counts

  • CHANGELOG.adoc — entry under == Unreleased

Edit this page · default