Integrate CognitiveAccessibilityAudit into CI pipeline
epic-cognitive-accessibility-wizard-ui-task-015 — Create a Dart test file (cognitive_accessibility_audit_test.dart) that runs the CognitiveAccessibilityAudit against all registered wizard and multi-step screens in the app. Add this test file to the CI test suite so it runs on every pull request. Configure the audit to fail CI with a non-zero exit code and a human-readable violation report when any high-severity rule is violated. Low-severity violations produce warnings only.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 6 - 158 tasks
Can start after Tier 5 completes
Implementation Notes
Define a const list `kWizardScreenRegistry` in a shared test helper (test/helpers/wizard_screen_registry.dart) containing widget builder functions for each wizard screen, injected with fake dependencies. In the audit test, iterate over kWizardScreenRegistry, pump each screen with `tester.pumpWidget`, call `CognitiveAccessibilityAudit.audit(tester)`, collect violations, then assert. Use a `StringBuffer` to accumulate the full report and print it once at the end of the test group with `debugPrint`. For CI integration, ensure the test file path is included in the `flutter test` command in the CI YAML — do not rely on `flutter test` discovering it automatically if test directories are filtered.
Use `addTearDown(tester.binding.setSurfaceSize(null))` to reset screen size between screens to avoid cross-screen layout contamination.
Testing Requirements
The test file itself IS the test artefact. Internal validation: write a meta-test that temporarily registers a deliberately broken wizard screen (one that violates a high-severity rule) into a test-only registry, runs the audit, and asserts that the test would fail. This prevents the audit from silently passing on an empty registry. Verify low-severity violations appear in debugPrint output (capture stdout in test).
Verify the report format contains 'Cognitive Accessibility Audit Report' header.
The WizardStateManager BLoC must guarantee that step transitions only occur on explicit user action, never automatically. Subtle reactive patterns in Bloc (e.g. stream listeners triggering add() calls) could inadvertently auto-advance the wizard, violating the core cognitive accessibility rule and creating a regression that is difficult to detect without dedicated tests.
Mitigation & Contingency
Mitigation: Write a dedicated unit test that subscribes to the BLoC stream and asserts no StepChanged event is emitted for 5 seconds after a state update, without an explicit user-sourced event being dispatched. Make this test part of the CI gate for the WizardStateManager.
Contingency: If an auto-advance regression is discovered post-integration, introduce a mandatory UserActionToken parameter on all step-transition events so the BLoC can structurally refuse transitions that do not originate from a user gesture handler.
The ConfirmBeforeSubmitScreen requires deep-linking back to specific wizard steps for corrections. Implementing bidirectional navigation within a multi-step wizard while preserving all previously entered state is architecturally non-trivial and may conflict with the existing StatefulShellRoute navigation setup described in the app architecture.
Mitigation & Contingency
Mitigation: Design the ConfirmBeforeSubmitScreen's back-navigation links to dispatch a GoToStep event on the WizardStateManager rather than using GoRouter's pop() chain. This keeps navigation state entirely in the BLoC and avoids coupling to the router's stack semantics.
Contingency: If BLoC-driven step navigation proves incompatible with the router, implement the correction flow as a dedicated sub-route that pre-populates its form from the WizardStateManager's current draft, then merges the edited field back into the draft on completion before returning to the confirm screen.
The CognitiveAccessibilityAudit utility must inspect live widget trees for violations such as icon-only buttons. Flutter's widget tree inspection APIs are available in test mode but have limitations in identifying semantic intent (e.g. distinguishing a decorative icon from a navigation button). False negatives could give a false sense of compliance.
Mitigation & Contingency
Mitigation: Augment the audit with a convention-based approach: require all navigation buttons to use a named wrapper widget (e.g. LabelledNavigationButton) that the audit can detect by type, rather than relying solely on widget-tree semantics analysis.
Contingency: If widget-tree detection proves insufficiently reliable, scope the CognitiveAccessibilityAudit to route-configuration analysis (verifying back navigation availability per route) and static analysis of wizard step count definitions via the CognitiveLoadRuleEngine, which provides deterministic results.
The InlineContextualHelpWidget sources content from a bundled JSON asset via the HelpContentRegistry. If help texts are missing for newly added screens or fields (a likely scenario as the 61-feature app grows), the widget silently shows nothing, degrading the accessibility experience without any visible failure.
Mitigation & Contingency
Mitigation: Integrate a CognitiveAccessibilityAudit check that verifies every registered (screenId, fieldId) pair that requests help has a corresponding entry in the HelpContentRegistry bundle. Run this check in CI as part of the audit report.
Contingency: Add a debug-mode overlay that highlights fields with missing help entries using a visible warning indicator, making coverage gaps immediately obvious to developers during local development before they reach CI.