Plan: 100% Integration & E2E Test Coverage

Status

Step Description Status

1

canopy-tanf integration tests (9 endpoints, new file)

Done (2026-04-09)

2

canopy-medicaid integration tests (7 endpoints, new file)

Done (2026-04-09)

3

canopy-snap missing endpoints (POST /determine, ABAWD, params, resolve discrepancy)

Done (2026-04-09)

4

canopy-appeals lifecycle endpoints (schedule, decision, withdraw, full IPV lifecycle)

Done (2026-04-09)

5

canopy-enrollment lifecycle endpoints (issue, list issuances, terminate)

Done (2026-04-09)

6

canopy-renewals lifecycle endpoints (get cert, interim contact, change report)

Done (2026-04-09)

7

canopy-notices generation and happy paths (POST /notices, resend, get by id, get pdf)

Done (2026-04-09)

8

canopy-reporting generation endpoints (POST fns-388, QC universe, CSV export)

Done (2026-04-09)

9

canopy-security remaining endpoints (get event/alert by id, update alert, archive)

Done (2026-04-09)

10

canopy-rules CRUD endpoints (list, get, update, delete rule-sets)

Done (2026-04-09)

11

canopy-applications missing endpoints (list, update, interview waive/complete)

Done (2026-04-09)

12

canopy-persons remaining endpoints (remove member, add asset/expense/address)

Done (2026-04-09)

13

canopy-verification SAVE adapter endpoints

Done (2026-04-09)

14

Strengthen weak assertions in existing integration tests

Done (2026-04-09)

15

E2E: fix weak patterns (.catch, waitForTimeout, permissive status lists)

Done (2026-04-09)

16

E2E: action effect verification with seed data

Done (2026-04-09)

17

E2E: multi-step workflow tests

Done (2026-04-09)

18

E2E: page content and tab content verification

Done (2026-04-09)

Branch: test/100-pct-coverage

Context

Phase 1 test coverage remediation brought the suite from ~107 to 403 tests. Subsequent work brought us to 521 unit tests, 115 integration tests, and 72 E2E tests (703 total). A 6-agent audit identified that only 59 of 137 endpoints (43%) have integration tests, and E2E tests rely on weak assertion patterns (.catch(() ⇒ false), permissive status lists, no action effect verification).

Two entire services (canopy-tanf, canopy-medicaid) have zero integration tests despite being fully implemented with 9 and 7 endpoints respectively. canopy-snap’s core endpoint (POST /determine) — the main SNAP eligibility determination — has no integration test. The appeals service has 18 endpoints but only 6 are tested; the entire appeal/IPV lifecycle (schedule → decision → withdraw) is uncovered.

This plan delivers 100% endpoint coverage with:

  • Every endpoint tested (happy path)

  • 404 for nonexistent resources

  • 400/409 for invalid/duplicate inputs where applicable

  • RBAC 401/403 for unauthenticated and wrong-role access

  • Strong assertions (assert_eq! with specific expected values, not is_string()/is_array())

Scope

In scope:

  • Integration tests for all 78 untested endpoints across 14 services

  • Sad-path tests (404, 400, 409) for every service

  • RBAC 403 tests for canopy-tanf and canopy-medicaid

  • Assertion strengthening for all existing integration tests

  • E2E weak pattern fixes (7 sites)

  • E2E action effect verification (5 tests)

  • E2E multi-step workflow tests (2 tests)

  • E2E page/tab content verification

Out of scope:

  • Stub services (canopy-exchange, canopy-caps, canopy-wic, canopy-portal) — no domain routes

  • Load/performance testing

  • canopy-web BFF integration tests — covered by E2E Playwright tests instead

  • New UI features (action form modals) — E2E tests use direct API calls for actions without UI

Design

All integration tests follow the established pattern in canopy-test-lib:

async fn setup() -> Option<TestClient> {
    if !canopy_test_lib::infrastructure_available().await {
        return None;
    }
    let c = TestClient::authenticated("http://localhost:{PORT}").await?;
    if !c.is_healthy().await {
        return None;
    }
    Some(c)
}

Every test uses strong assertions:

  • assert_eq!(data["field"], "expected_value") — not assert!(data["field"].is_string())

  • assert_eq!(resp.status(), 201) — not assert!(resp.status().is_success())

  • Specific field validation after creation (verify returned data matches input)

  • Lifecycle tests: create → mutate → verify mutation → verify final state

E2E tests replace weak patterns with Playwright best practices:

  • locator.or(otherLocator) instead of .catch(() ⇒ false) with logical OR

  • waitForSelector/waitForURL instead of waitForTimeout

  • expect([200, 302, 303]).toContain(status) — never accept 401/403/500

Steps

Step 1: canopy-tanf integration tests

Files: services/canopy-tanf/tests/tanf_test.rs (NEW), services/canopy-tanf/Cargo.toml

Add canopy-test-lib to [dev-dependencies]. Create tests/tanf_test.rs with the standard setup (port 8014).

Tests to implement:

Test Function Endpoint Assertion

post_determine_returns_determination

POST /v1/determine

Status 201, response has id, status, household_id

get_determination_returns_created

GET /v1/determinations/{id}

Status 200, fields match what was created

get_nonexistent_determination_returns_404

GET /v1/determinations/{fake_uuid}

Status 404

get_explanation_returns_text

GET /v1/determinations/{id}/explanation

Status 200, response has explanation content

get_work_requirements_returns_data

GET /v1/work-requirements/{person_id}

Status 200, response is array

log_work_activity_returns_201

POST /v1/work-requirements/{person_id}/activities

Status 201, response has id, activity_type

get_time_limits_returns_data

GET /v1/time-limits/{person_id}

Status 200, response has time limit fields

list_fti_audit_returns_array

GET /v1/fti-audit-log

Status 200, response is array

fti_audit_summary_returns_data

GET /v1/fti-audit-log/summary

Status 200, response has summary fields

get_fti_audit_entry_returns_404_for_fake

GET /v1/fti-audit-log/{fake_uuid}

Status 404

unauthenticated_returns_401

GET /v1/determinations (no token)

Status 401

The post_determine test requires a valid household and person in canopy-persons. Create test data via canopy-persons API first (POST person, POST household, POST income), then call canopy-tanf’s determine endpoint with the household_id.

Step 2: canopy-medicaid integration tests

Files: services/canopy-medicaid/tests/medicaid_test.rs (NEW), services/canopy-medicaid/Cargo.toml

Add canopy-test-lib to [dev-dependencies]. Create tests/medicaid_test.rs with the standard setup (port 8015).

Tests to implement:

Test Function Endpoint Assertion

post_determine_returns_determination

POST /v1/determine

Status 201, response has id, status, assigned_coa

get_determination_returns_created

GET /v1/determinations/{id}

Status 200, fields match creation

get_nonexistent_determination_returns_404

GET /v1/determinations/{fake_uuid}

Status 404

get_eligible_categories_returns_array

GET /v1/determinations/{id}/categories

Status 200, array of COA objects

get_explanation_returns_text

GET /v1/determinations/{id}/explanation

Status 200, has explanation content

list_fti_audit_returns_array

GET /v1/fti-audit-log

Status 200, response is array

fti_audit_summary_returns_data

GET /v1/fti-audit-log/summary

Status 200, has summary fields

get_fti_audit_entry_returns_404_for_fake

GET /v1/fti-audit-log/{fake_uuid}

Status 404

unauthenticated_returns_401

GET /v1/determinations (no token)

Status 401

The post_determine test requires a valid person with demographic data (age, income) to trigger CMD cascade evaluation. Create a person via canopy-persons with date_of_birth set to make them a child (age 3) for predictable COA assignment (child 1-5 at 149% FPL).

Step 3: canopy-snap missing endpoints

Files: services/canopy-snap/tests/snap_test.rs

Add tests to the existing file:

Test Function Endpoint Assertion

post_determine_returns_signed_determination

POST /v1/determine

Status 200/201, response has id, status, signature (JWS), household_id

get_determination_returns_created

GET /v1/determinations/{id} (happy path)

Status 200, status field matches, deductions object present

resolve_discrepancy_changes_status

PUT /v1/verification/discrepancies/{id}/resolve

Status 200, resolution_status == "resolved"

get_params_returns_current_parameters

GET /v1/params

Status 200, response has gross_income_limits, max_allotments

record_abawd_activity_returns_201

POST /v1/abawd/activity

Status 201, response has id, activity_type, hours

list_abawd_tracking_returns_array

GET /v1/abawd/tracking?person_id={id}

Status 200, array response

list_abawd_activities_returns_array

GET /v1/abawd/tracking/{id}/activities

Status 200, array response

The post_determine test is the most critical test in this plan. It requires: person with income (via canopy-persons), application (via canopy-applications), household composition. Create all prerequisite data via their respective service APIs, then call POST /v1/determine with the ApplicationContext. Assert the response includes a valid JWS signature (3 dot-separated parts), correct status (approved/denied based on income vs FPL), and non-zero benefit_amount if approved.

Step 4: canopy-appeals lifecycle endpoints

Files: services/canopy-appeals/tests/appeals_test.rs

Add lifecycle tests that chain operations on a single appeal:

Test Function Endpoint Assertion

get_filed_appeal_returns_200

GET /v1/appeals/{id} (happy path)

Status 200, status == "filed", program == "snap"

schedule_hearing_sets_date

PUT /v1/appeals/{id}/schedule

Status 200, hearing_date matches input, status == "scheduled"

record_decision_reversed

PUT /v1/appeals/{id}/decision

Status 200, decision == "reversed", decision_date present

record_decision_affirmed

PUT /v1/appeals/{id}/decision

Status 200, decision == "affirmed"

withdraw_appeal_changes_status

PUT /v1/appeals/{id}/withdraw

Status 200, status == "withdrawn"

clock_check_returns_200

POST /v1/internal/appeals/clock-check

Status 200

get_ipv_case_returns_200

GET /v1/ipv/cases/{id}

Status 200, fields match creation

schedule_adh_sets_date

PUT /v1/ipv/cases/{id}/schedule-adh

Status 200, adh_date present

send_notice_updates_status

PUT /v1/ipv/cases/{id}/send-notice

Status 200, notice_sent_date present

ipv_record_decision_sets_penalty

PUT /v1/ipv/cases/{id}/record-decision

Status 200, decision, penalty_months present

ipv_waiver_sets_waived

PUT /v1/ipv/cases/{id}/waiver

Status 200, waiver_signed == true

impose_disqualification_creates_record

PUT /v1/ipv/cases/{id}/impose-disqualification

Status 200/201, disqualification_start_date present

ipv_withdraw_changes_status

PUT /v1/ipv/cases/{id}/withdraw

Status 200, status == "withdrawn"

check_active_disqualification_returns_array

GET /v1/ipv/disqualifications/active?person_id={id}

Status 200, array response

Use a lifecycle pattern: file appeal → get → schedule → decide. For IPV: create referral → get → schedule ADH → send notice → decide → impose disqualification. Each step asserts the state transition is correct.

Step 5: canopy-enrollment lifecycle endpoints

Files: services/canopy-enrollment/tests/enrollment_test.rs

Test Function Endpoint Assertion

issue_benefits_returns_201

POST /v1/enrollments/{id}/issue

Status 201, benefit_month matches, amount present

list_issuances_returns_array

GET /v1/enrollments/{id}/issuances

Status 200, array with issued benefit

terminate_enrollment_changes_status

POST /v1/enrollments/{id}/terminate

Status 200, status == "terminated", terminated_reason present

duplicate_issuance_same_month_returns_409

POST /v1/enrollments/{id}/issue (same month twice)

Status 409

Create enrollment first (existing test), then chain: issue → list issuances → verify → terminate.

Step 6: canopy-renewals lifecycle endpoints

Files: services/canopy-renewals/tests/renewals_test.rs

Test Function Endpoint Assertion

get_active_certification_by_household

GET /v1/renewals/snap/certifications?household_id={id}

Status 200, array with created cert

get_certification_by_id

GET /v1/renewals/snap/certifications/{id}

Status 200, fields match creation

record_interim_contact_returns_201

POST /v1/renewals/snap/certifications/{id}/interim-contact

Status 201, contact_date present

create_change_report_returns_201

POST /v1/renewals/snap/certifications/{id}/change-report

Status 201, change_type == input value

Create certification first (existing test), extract id, then test lifecycle endpoints.

Step 7: canopy-notices generation and happy paths

Files: services/canopy-notices/tests/notices_test.rs

Test Function Endpoint Assertion

generate_notice_returns_201

POST /v1/notices

Status 201, id present, notice_type matches, household_id matches

get_notice_returns_created

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

Status 200, all fields from generation present

get_notice_pdf_returns_binary

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

Status 200, content-type contains "pdf"

resend_notice_returns_200

POST /v1/notices/{id}/resend

Status 200

Generate a notice first, then test get and resend. The PDF test requires that canopy-typst successfully renders the template, so use a known valid notice type (e.g., approval).

Step 8: canopy-reporting generation endpoints

Files: services/canopy-reporting/tests/reporting_test.rs

Test Function Endpoint Assertion

generate_fns388_returns_201

POST /v1/reporting/snap/fns-388

Status 201, report_month present

get_report_by_month

GET /v1/reporting/snap/fns-388/{month}

Status 200, report data present

get_nonexistent_report_returns_404

GET /v1/reporting/snap/fns-388/1999-01

Status 404

generate_qc_snapshot_returns_201

POST /v1/reporting/snap/qc-universe

Status 201

get_qc_universe_returns_data

GET /v1/reporting/snap/qc-universe/{date}

Status 200, data present

export_qc_csv_returns_csv

GET /v1/reporting/snap/qc-universe/{date}/csv

Status 200, content-type contains "csv"

Reporting endpoints require supervisor-level JWT. Use TestClient::authenticated_as("supervisor") or equivalent if available, otherwise use default auth which may already have supervisor role.

Step 9: canopy-security remaining endpoints

Files: services/canopy-security/tests/security_test.rs

Test Function Endpoint Assertion

get_event_by_id_returns_200

GET /v1/security/events/{id}

Status 200, id matches, event_type present

get_alert_by_id_returns_200

GET /v1/security/alerts/{id}

Status 200, id matches, severity_level present

update_alert_status_to_resolved

PATCH /v1/security/alerts/{id}

Status 200, status == "resolved"

list_archived_returns_array

GET /v1/security/archive

Status 200, array response

run_archive_returns_200

POST /v1/security/archive

Status 200, response has archived_count

Chain: list events → get first event by id → verify fields. For alerts: list alerts → get first → patch to resolved → verify resolved.

Step 10: canopy-rules CRUD endpoints

Files: services/canopy-rules/tests/rules_test.rs

Test Function Endpoint Assertion

list_rule_sets_returns_array

GET /v1/rule-sets

Status 200, array response

get_rule_set_returns_created

GET /v1/rule-sets/{id}

Status 200, name matches, content present

update_rule_set_changes_content

PUT /v1/rule-sets/{id}

Status 200, re-GET shows updated content

delete_rule_set_returns_success

DELETE /v1/rule-sets/{id}

Status 200 or 204, re-GET returns 404

get_nonexistent_rule_set_returns_404

GET /v1/rule-sets/{fake_uuid}

Status 404

delete_nonexistent_returns_404

DELETE /v1/rule-sets/{fake_uuid}

Status 404

Create a rule set first (existing test), then test get/update/delete.

Step 11: canopy-applications missing endpoints

Files: services/canopy-applications/tests/application_test.rs

Test Function Endpoint Assertion

list_applications_returns_array

GET /v1/applications

Status 200, array contains created app

update_application_changes_fields

PUT /v1/applications/{id}

Status 200, re-GET shows updated field

waive_interview_sets_flag

POST /v1/applications/{id}/interview/waive

Status 200, interview_waived == true, interview_waived_reason present

complete_interview_sets_timestamp

POST /v1/applications/{id}/interview/complete

Status 200, interview_completed_at is ISO 8601 string

get_nonexistent_application_returns_404

GET /v1/applications/{fake_uuid}

Status 404

Step 12: canopy-persons remaining endpoints

Files: services/canopy-persons/tests/persons_test.rs

Test Function Endpoint Assertion

remove_member_from_household

DELETE /v1/households/{hh_id}/members/{member_id}

Status 200/204, re-GET household shows reduced member count

add_asset_returns_201

POST /v1/persons/{id}/assets

Status 201, asset_type matches, value matches

add_expense_returns_201

POST /v1/persons/{id}/expenses

Status 201, expense_type matches, amount matches

add_address_returns_201

POST /v1/persons/{id}/addresses

Status 201, street matches, state matches

The list endpoints for these sub-resources already have tests. These tests add the missing POST/DELETE happy paths.

Step 13: canopy-verification SAVE adapter endpoints

Files: services/canopy-verification/tests/save_test.rs (NEW)

Test Function Endpoint Assertion

save_verify_returns_noop_data

POST /internal/v1/save/verify

Status 200, response has verification_status, case_number

save_additional_returns_noop_data

POST /internal/v1/save/additional-verification

Status 200, response has fields

save_verify_without_key_returns_401

POST /internal/v1/save/verify (no X-Service-Api-Key)

Status 401

save_additional_without_key_returns_401

POST /internal/v1/save/additional-verification (no key)

Status 401

Follow the IEVS test pattern in ievs_test.rs — use reqwest directly with X-Service-Api-Key header.

Step 14: Strengthen weak assertions in existing integration tests

Files: Multiple test files across services

Specific fixes:

File:Line Current Fix

rules_test.rs — evaluate response

assert!(eval_body.is_object())

assert!(eval_body.get("result").is_some())

rules_test.rs — invalid JDM

status == 400 || status == 422

assert_eq!(status, 400)

rules_test.rs — nonexistent

status == 404 || status == 500

assert_eq!(status, 404) — 500 is NEVER acceptable

persons_test.rs — create

assert!(body["id"].is_string())

assert!(uuid::Uuid::parse_str(body["id"].as_str().unwrap()).is_ok())

snap_test.rs — list determinations

assert!(dets.len() < 1000)

assert!(dets.is_array())

security_test.rs — summary

summary.is_array() || summary.is_object()

Assert the specific expected type

enrollment_test.rs — list

assert!(data.is_array())

assert_eq!(data.as_array().unwrap().len(), 0) for fresh household_id

All is_string() on UUIDs

assert!(data["id"].is_string())

Parse as UUID to validate format

Step 15: E2E — fix weak patterns

Files: tests/e2e/specs/dashboard.spec.ts, tests/e2e/specs/renewals.spec.ts, tests/e2e/specs/actions.spec.ts, tests/e2e/specs/applications.spec.ts, tests/e2e/lib/helpers.ts

File:Line Pattern Fix

dashboard.spec.ts:34

.catch(() ⇒ false) on both table and emptyState

Use await expect(table.or(emptyState)).toBeVisible()

renewals.spec.ts:13

.catch(() ⇒ false) on table/empty

Use await expect(table.or(empty)).toBeVisible()

actions.spec.ts:30

expect([200,302,303,401,403]).toContain

expect([200,302,303]).toContain — 401/403 means broken auth

actions.spec.ts:88

expect([200,401,403,404,500]).toContain

expect([200,404]).toContain — 500 is never acceptable

applications.spec.ts:82

if (!app) return

test.skip(!app, 'No application data')

applications.spec.ts:92

.catch(() ⇒ {}) on waitForLoadState

Remove catch — let timeout be a real failure

helpers.ts:13

waitForTimeout(150) after htmx

await page.locator('#search-results').waitFor()

Step 16: E2E — action effect verification

Files: tests/e2e/specs/actions.spec.ts

Replace smoke-only POST tests with seed-data-backed tests that verify effects. Use findApproved() from seed data to get a real household_id.

Test Verification

file_appeal_and_verify_in_list

POST /appeals/file with seed household → navigate to /appeals → expect(page.locator('table')).toContainText(householdId.substring(0,8))

approve_application_and_verify_redirect

Click Approve on process page → expect(page).toHaveURL(/\/cases\//) → verify no "Internal Server Error"

deny_application_with_reason

Open modal → select reason → submit → verify redirect → verify no error

interim_contact_records_successfully

POST with real cert_id from seed → expect(response.status()).toBe(302) or 200

change_report_submits_successfully

POST with real cert_id from seed → verify redirect or success response

Step 17: E2E — multi-step workflow tests

Files: tests/e2e/specs/workflow.spec.ts (NEW)

Test Steps

search_to_case_detail_all_tabs

Search for seed person last name → click result → verify URL is /cases/{id} → click each of 6 tabs → verify each tab panel loads content (not empty, not error)

application_to_determination

Navigate to /applications → find expedited app → navigate to process page → verify heading "Process Application" → verify Approve/Deny buttons → verify Rules Engine Result section visible

Step 18: E2E — page content and tab content verification

Files: tests/e2e/specs/case-detail.spec.ts, tests/e2e/specs/dashboard.spec.ts, tests/e2e/specs/applications.spec.ts

Test Assertion

Dashboard stat card labels

Verify labels contain "Pending", "Renewals" or equivalent — not just numeric check

Case detail summary bar content

After loading, verify .card contains program badge text (e.g., "SNAP"), status text, household size

Household tab has member data

After clicking household tab, verify #tabpanel contains table or member card — not just .toBeVisible()

Income tab has column headers

After clicking income tab, verify headings like "Earned" or "Unearned" or "Source"

Determination tab shows result

After clicking determination tab, verify "ELIGIBLE" or "INELIGIBLE" or "No determination" text

Applications list table headers

Navigate to /applications → verify table has headers: "Case", "Status", "Expedited"

Files Touched

File Change

services/canopy-tanf/tests/tanf_test.rs

NEW — 11 integration tests

services/canopy-tanf/Cargo.toml

Add canopy-test-lib, uuid, serde_json to dev-dependencies

services/canopy-medicaid/tests/medicaid_test.rs

NEW — 9 integration tests

services/canopy-medicaid/Cargo.toml

Add canopy-test-lib, uuid, serde_json to dev-dependencies

services/canopy-snap/tests/snap_test.rs

Add 7 tests (determine, ABAWD, params, resolve)

services/canopy-appeals/tests/appeals_test.rs

Add 14 lifecycle tests (appeal + IPV)

services/canopy-enrollment/tests/enrollment_test.rs

Add 4 lifecycle tests (issue, issuances, terminate)

services/canopy-renewals/tests/renewals_test.rs

Add 4 lifecycle tests (get cert, interim contact, change report)

services/canopy-notices/tests/notices_test.rs

Add 4 tests (generate, get, pdf, resend)

services/canopy-reporting/tests/reporting_test.rs

Add 6 tests (generate fns-388, QC universe, CSV)

services/canopy-security/tests/security_test.rs

Add 5 tests (get event/alert, update alert, archive)

services/canopy-rules/tests/rules_test.rs

Add 6 CRUD tests + fix 2 weak assertions

services/canopy-applications/tests/application_test.rs

Add 5 tests (list, update, interview, 404)

services/canopy-persons/tests/persons_test.rs

Add 4 tests (remove member, add asset/expense/address)

services/canopy-verification/tests/save_test.rs

NEW — 4 SAVE adapter tests

Multiple existing test files

Fix ~8 weak assertions (Step 14)

tests/e2e/specs/dashboard.spec.ts

Fix .catch pattern, add label assertions

tests/e2e/specs/renewals.spec.ts

Fix .catch pattern

tests/e2e/specs/actions.spec.ts

Fix permissive status lists, add effect verification

tests/e2e/specs/applications.spec.ts

Fix silent skip, add list table test

tests/e2e/lib/helpers.ts

Replace waitForTimeout with waitForSelector

tests/e2e/specs/workflow.spec.ts

NEW — 2 multi-step workflow tests

tests/e2e/specs/case-detail.spec.ts

Add tab content assertions

Verification

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

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

  3. cargo xtask e2e — all E2E tests pass (target: 82+)

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

  5. Every service endpoint appears in at least one integration test

  6. No test contains || true, .catch(() ⇒ false), or accepts status 500 as valid

  7. No test uses bare is_string()/is_array() without also checking content

Documentation Updates

  • .claude/docs/testing.md — update test counts and coverage status

  • CHANGELOG.adoc — entry under == Unreleased

  • This plan file — mark each step complete as work progresses

Edit this page · default