Appearance
ADR-251: Centralized Accessibility Matcher and 80 Percent Coverage Gate
NOTE
Amended by ADR-2530. The 80 percent gate measured only the files named in coverage.include. Coverage is now measured over all web source with a ratchet floor, and the files named here keep their 80 percent thresholds.
- Status: Accepted
- Date: 2026-08-02
- Authors: @fderuiter
- Deciders: @fderuiter
1. Context & Problem Statement
Maintaining strict Web Content Accessibility Guidelines (WCAG) 2.1 Compliance is a fundamental business requirement for patient-facing (eCOA/ePRO) clinical software platforms. Previously, our custom toBeAccessible testing matcher (which wraps axe-core) was coupled tightly to the main clinical dashboard web application (apps/web). This structure led to duplicate testing configurations, fragmented implementations in the patient portal (apps/subject-portal), and lack of automated enforcement gates.
Additionally, our frontend continuous integration (CI) pipelines lacked enforced code coverage thresholds, introducing risks of regression and code quality fragmentation. We need a clean, unified engineering pattern to centralize testing utilities and enforce an 80% code coverage threshold in CI to guarantee quality assurance and accessibility compliance under system requirement PRD-SYS-001.
2. Decision Drivers & Constraints
- Maintainability & DRY Principle: Testing assertions should not be copy-pasted across isolated frontend applications.
- WCAG 2.1 Compliance Enforcement: Guardrails must ensure that both professional portal and patient portal widgets are strictly audited for screen-readers, contrast ratio, and layout (PRD-SYS-001).
- Standardized Code Quality: Aligning frontend test suites with the existing 80% coverage standard enforced on the backend.
- Developer Velocity: Centralized matchers must be easily importable with zero boilerplate.
3. Options Considered
Option 1: Fragmented Testing Setups (Status Quo)
Keep custom testing setup files separately configured inside each application workspace, running independent coverage checks without rigid gating rules.
- Pros:
- ✅ Quick setup for individual applications.
- Cons:
- ❌ Severe duplicate configurations across
apps/webandapps/subject-portal. - ❌ Lack of uniform accessibility criteria or global rulesets.
- ❌ No automated mechanism blocks pull requests with low-quality or untested code.
- ❌ Severe duplicate configurations across
Option 2: Shared Testing Package with Enforced Gating (Selected)
Extract custom Jest/Vitest matchers (e.g. toBeAccessible) to a shared workspace package (packages/ui), expose them globally, and configure rigid Vitest coverage threshold gates requiring 80% coverage for lines, functions, branches, and statements.
- Pros:
- ✅ Perfect architectural separation of concerns (dry utility package).
- ✅ Guarantees 80% test coverage gate is automatically executed in CI.
- ✅ Allows easy global extension of WCAG rules across all current and future portals.
- Cons:
- ❌ Minor build config orchestration required via
pnpmworkspaces.
- ❌ Minor build config orchestration required via
4. Decision Outcome
Chosen Option: Option 2 (Option A). By packaging the custom toBeAccessible matcher within packages/ui and distributing it as a shared dependency, we eliminate configuration fragmentation. Incorporating a mandatory Vitest 80% coverage gate guarantees that all newly authored components and routes are thoroughly validated, keeping our platform compliant with PRD-SYS-001.
5. Consequences & Trade-offs
- Positive Impact:
- Standardized accessibility testing setup across all client modules.
- Fail-closed gates in CI block any contributions failing to maintain coverage or containing accessibility violations.
- Negative Impact / Technical Debt:
- Workspace packages have slight compile/resolve overhead during developer bootstrap.
- Mitigation Strategy:
- Pre-configured scripts automate bootstrapping via
pnpmworkspace hooks.
- Pre-configured scripts automate bootstrapping via
6. Implementation & Verification
- Affected Repositories / Services:
packages/ui: Centralized thetoBeAccessiblematcher and updated public entrypoints (packages/ui/accessibility-matcher.js,packages/ui/index.js).apps/web: Replaced local matcher setup with shared package imports inapps/web/tests/setup.jsandapps/web/vitest.config.js.apps/subject-portal: Standardized configuration inapps/subject-portal/tests/setup.jsandapps/subject-portal/vite.config.jsto importtoBeAccessiblefrom@cadence/ui.package.json& individual config files: Configured the Vitest coverage thresholds.
- Verification Plan:
- Running
pnpm run testexecutes unified unit tests verifying coverage meets the 80% statement, branch, and function thresholds. - Running
uv run python scripts/validate_adrs.pyvalidates the format, requirements mapping, and chronology of this ADR.
- Running