high priority medium complexity infrastructure pending testing specialist Tier 5

Acceptance Criteria

CognitiveAccessibilityAudit exposes a static `audit(WidgetTester tester)` method returning `List<AuditViolation>`
AuditViolation is a typed Dart class with fields: ruleId (String), severity (AuditSeverity enum: high/low), description (String), widgetLocation (String)
Rule 1 — single-action-per-screen: reports high severity when more than one primary action button (AppButton with isPrimary: true) is found on the current screen
Rule 2 — labelled back/cancel present: reports high severity when no widget with Semantics label containing 'back' or 'cancel' (case-insensitive) is found on non-root screens
Rule 3 — choice count: reports high severity when a widget subtree contains more than 5 selectable options (Radio, Checkbox, or custom choice widgets) visible simultaneously
Rule 4 — confirm-before-submit gate: reports high severity when a route whose name contains 'wizard' or 'submit' does not include a ConfirmBeforeSubmitScreen widget in its widget tree
Rule 5 — inline help on text inputs: reports low severity when an AppTextField widget is found without a sibling InlineContextualHelpWidget in its parent subtree
Each rule check is independently callable as a named method for granular testing
CognitiveAccessibilityAudit is located at lib/utils/cognitive_accessibility_audit.dart

Technical Requirements

frameworks
Flutter
flutter_test
performance requirements
Full audit of a single screen's widget tree must complete in under 100ms
Audit must not trigger any layout rebuilds or side effects on the tested widget tree
security requirements
Audit utility must only be compiled into test and debug builds — exclude from release profile using assert guards or kDebugMode checks
ui components
AppButton
AppTextField
InlineContextualHelpWidget
ConfirmBeforeSubmitScreen

Execution Context

Execution Tier
Tier 5

Tier 5 - 253 tasks

Can start after Tier 4 completes

Implementation Notes

Implement CognitiveAccessibilityAudit as a pure Dart utility class (no Flutter rendering dependency) that receives a WidgetTester and uses `tester.widgetList` and `tester.getSemantics` for tree traversal. Use Finder composition (`find.byType`, `find.bySemanticsLabel`) to locate widgets without coupling to internal widget keys. Model AuditSeverity as a Dart enum with values high and low. For Rule 3 (choice count), define a const `kMaxChoicesPerScreen = 5` in the class to make the threshold configurable in tests.

For Rule 4 (confirm gate), check via `find.byType(ConfirmBeforeSubmitScreen).evaluate().isNotEmpty` scoped to wizard routes. Annotate the class with `@visibleForTesting` to communicate intent and prevent accidental production use.

Testing Requirements

Unit tests for each of the 5 rules in isolation using flutter_test: for each rule, construct a minimal widget tree that (a) passes the rule and (b) violates the rule, assert correct AuditViolation output. Test that AuditViolation.severity is AuditSeverity.high for rules 1–4 and AuditSeverity.low for rule 5. Test the combined `audit()` method with a widget tree containing multiple simultaneous violations and verify all are reported. Test that a clean wizard screen with all rules satisfied returns an empty list.

Component
Cognitive Accessibility Audit Utility
infrastructure medium
Dependencies (4)
Write Flutter widget tests verifying that PlainLanguageErrorDisplay emits correct Semantics labels, that liveRegion announcements fire on error state change, and that the two-part layout renders correctly for both short and long messages. Include golden tests for visual regression. Verify WCAG 2.2 AA contrast ratios for error text against background using the ContrastRatioValidator. epic-cognitive-accessibility-wizard-ui-task-007 Write widget tests for InlineContextualHelpWidget covering tap-to-expand, tap-to-collapse, Semantics hint transitions, and the null-key hide behaviour. Verify that focus does not jump unexpectedly when the widget expands. Run golden tests for collapsed and expanded visual states. Confirm touch target size meets WCAG 2.2 minimum 44x44dp requirement. epic-cognitive-accessibility-wizard-ui-task-010 Write bloc_test unit tests covering all state transitions: normal step progression, pause mid-wizard, resume from draft, submission event, and error edge cases such as advancing past the last step. Mock the WizardDraftRepository. Achieve at least 90% branch coverage on the BLoC. epic-cognitive-accessibility-wizard-ui-task-004 Write integration tests for ConfirmBeforeSubmitScreen verifying that the Confirm action fires WizardSubmitted, the Go Back action returns to the previous step with field values preserved, and that the screen is fully navigable by screen reader without any unlabelled interactive elements. Check that the screen does not appear if the user navigates back from it using the device back button. epic-cognitive-accessibility-wizard-ui-task-013
Epic Risks (4)
high impact medium prob technical

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.

medium impact medium prob integration

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.

medium impact medium prob technical

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.

low impact high prob scope

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.