high priority low complexity testing pending testing specialist Tier 3

Acceptance Criteria

Test file covers all 10 semantic ColorScheme roles (primary/onPrimary, secondary/onSecondary, surface/onSurface, error/onError, background/onBackground) against their intended background counterparts
Known WCAG reference pairs are tested with exact expected ratios: white (#FFFFFF) on #767676 = 4.50:1, black (#000000) on white = 21.0:1, black on #FFFFFF = 21.0:1
Boundary tests: a pair at exactly 4.5:1 has `pass` = true; a pair at 4.49:1 has `pass` = false; a pair at exactly 3.0:1 (large text threshold) has its own pass/fail test
Each test asserts both the numeric `contrastRatio` field (within ±0.01 tolerance) and the boolean `pass` field
Performance test: a loop of 1000 `ContrastRatioValidator.compute()` calls completes in under 100ms total (measured with Stopwatch)
Tests are grouped using flutter_test `group()` blocks: 'WCAG Reference Pairs', 'ColorScheme Roles', 'Boundary Cases', 'Performance'
All tests pass on both debug and release build configurations
Test file is located at `test/accessibility/contrast_ratio_validator_test.dart`
Zero test-only dependencies are added to production code — test helpers live only in the test directory

Technical Requirements

frameworks
flutter_test
apis
ContrastRatioValidator (from task-004)
ContrastSafeColorPalette (from task-012)
data models
ContrastSafePair (record)
ColorScheme (Material)
performance requirements
1000 validations must complete under 100ms as measured by Dart's Stopwatch in a test body
No I/O or async operations in any test — all validations are pure synchronous computations
security requirements
Test file must not include any real user credentials, API keys, or environment-specific values

Execution Context

Execution Tier
Tier 3

Tier 3 - 413 tasks

Can start after Tier 2 completes

Implementation Notes

Precompute the exact Color values needed for boundary tests offline: for a ratio of exactly 4.5:1, if background luminance = 1.0 (white), foreground luminance = (1.0 + 0.05) / 4.5 - 0.05 = 0.1833. Find the sRGB value whose WCAG relative luminance equals 0.1833 — this is approximately #767676. Use Flutter's `Color(0xFF767676)` for the 4.5:1 reference test. For 4.49:1, use `Color(0xFF777777)` which resolves to slightly below 4.5:1.

Document the mathematical derivation in a comment above the boundary test group. For the ColorScheme role tests, construct a standard Material 3 ColorScheme using `ColorScheme.fromSeed(seedColor: Colors.blue)` and verify that all 10 foreground/background pairings pass — this also serves as a regression test that the project's design tokens meet WCAG AA. The performance test should call `ContrastRatioValidator.compute(Colors.black, Colors.white)` in a loop (best case) to isolate pure computation time.

Testing Requirements

This task IS the testing requirement. Structure the test file with four `group()` blocks: (1) 'WCAG Reference Pairs' — 6+ hardcoded known pairs with exact expected ratios and pass booleans; (2) 'ColorScheme Roles' — iterate all 10 semantic role pairs from a test ColorScheme instance and assert all pass >= 4.5:1; (3) 'Boundary Cases' — construct Color pairs that resolve to exactly 4.5:1 and 4.49:1 using back-calculated luminance values, assert the correct pass/fail outcome; (4) 'Performance' — Stopwatch-based loop test for 1000 calls. Use `closeTo(expected, 0.01)` matcher for ratio assertions. Each test should be self-documenting with a descriptive string that includes the hex codes being tested.

Epic Risks (4)
medium impact high prob integration

Flutter's textScaleFactor behaviour differs between iOS and Android, and third-party widgets used across the app (date pickers, bottom sheets, chips) may not respect the per-role scale caps applied by the dynamic-type-scale-service, causing overflow in screens this epic cannot directly control.

Mitigation & Contingency

Mitigation: Enumerate all third-party widget usages that render text. For each, verify whether they honour the inherited DefaultTextStyle and MediaQuery.textScaleFactor or use hardcoded sizes. File issues with upstream packages and wrap non-compliant widgets in MediaQuery overrides scoped to the safe cap for that role.

Contingency: If upstream packages cannot be patched within the sprint, implement a global MediaQuery wrapper at the app root that clamps textScaleFactor to the highest per-role safe value (typically 1.6–2.0), accepting that users at extreme OS scales see a safe cap rather than full scaling for those widgets.

high impact medium prob dependency

The CI accessibility lint runner depends on the Dart CLI toolchain and potentially custom_lint or a bespoke Dart script. CI environments differ from local dev environments in Dart SDK version, pub cache configuration, and platform availability, risking intermittent CI failures that block all pull requests.

Mitigation & Contingency

Mitigation: Pin the Dart SDK version in the CI workflow configuration. Package the lint runner as a self-contained Dart script with all dependencies vendored or declared in a dedicated pubspec.yaml. Add a CI smoke test that runs the runner against a known-compliant fixture and a known-violating fixture to verify the exit codes are correct.

Contingency: If the custom runner proves too fragile, fall back to running dart analyze with the flutter-accessibility-lint-config rules as the sole CI gate, and schedule the custom manifest validation as a separate non-blocking advisory check until the runner is stabilised.

medium impact medium prob technical

Wrapping all interactive widgets with a 44 pt minimum hit area via HitTestBehavior.opaque may cause unintended tap interception in widgets where interactive elements are closely stacked, particularly in the expense type selector, bulk confirmation screen, and notification filter bar.

Mitigation & Contingency

Mitigation: Conduct integration testing of the touch target wrapper specifically in dense layout scenarios (expense selector, filter bars, bottom sheets with multiple buttons). Use the Flutter Inspector to visualise hit areas and confirm no overlaps. Pair with the interactive-control-spacing-system to ensure minimum 8 dp gaps between expanded hit areas.

Contingency: If overlapping hit areas cause mis-tap regressions in specific screens, allow the touch target wrapper to accept an explicit hitAreaSize parameter that can be reduced below 44 pt only in contexts where the interactive-control-spacing-system guarantees sufficient gap, with a mandatory code review flag for any such override.

high impact medium prob scope

The contrast-safe-color-palette must guarantee WCAG AA ratios for both light and dark mode token sets. Dark mode color derivation is non-trivial — simply inverting a light palette often produces pairs that pass in one mode but fail in the other, and the token manifest must encode both sets explicitly.

Mitigation & Contingency

Mitigation: Define both light and dark token sets explicitly in the accessibility-token-manifest rather than deriving one from the other programmatically. Run the contrast-ratio-validator against both sets as part of the token manifest generation process and include both in the CI lint runner's validation scope.

Contingency: If time pressure forces a dark mode deferral, ship with light mode only and add a prominent in-app notice. Gate dark mode colour tokens behind a feature flag until the full dual-palette validation is complete.