Widget and integration tests for reminder UI components
epic-assignment-follow-up-reminders-ui-task-009 — Write flutter_test widget tests for all three components covering: ReminderNotificationCard renders elapsed days and CTA correctly, dismiss and mark-read actions emit correct BLoC events, CoordinatorEscalationNotificationCard displays peer mentor name and acknowledgement button, escalation acknowledgement updates state, ReminderThresholdSettingsUI validates inputs and triggers save. Include golden tests for visual regression of the card designs. Run accessibility semantics assertions to enforce screen reader label presence.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 4 - 323 tasks
Can start after Tier 3 completes
Implementation Notes
Organise test files to mirror the source structure: test/widgets/reminder_notification_card_test.dart, coordinator_escalation_notification_card_test.dart, reminder_threshold_settings_ui_test.dart. For golden tests, use a dedicated goldens/ directory and a custom Flutter test configuration that pins the canvas size. When testing BLoC event emissions, use blocTest from bloc_test package's act/expect pattern — do not use raw StreamController assertions. For Riverpod tests, override providers using ProviderContainer or ProviderScope in the test widget tree.
For the elapsed days calculation, inject a fixed clock (DateTime.now override via a test utility) so the golden and assertion values are deterministic. Commit golden files to the repository; document the Flutter version used for golden generation in a comment at the top of each golden test file to prevent CI drift.
Testing Requirements
Use flutter_test for all widget tests. Use MockBloc (bloc_test package) for BLoC event assertions and Riverpod ProviderScope overrides for Riverpod provider injection. Golden tests use matchesGoldenFile() — generate goldens on a pinned Flutter version to avoid font rendering differences across environments. Semantics tests use tester.getSemantics(find.byType(...)) to assert label and liveRegion properties.
Structure tests in describe/group blocks per component. CI pipeline must run flutter test --coverage and fail if coverage drops below 90% for the three component files. Flakiness prevention: avoid timers or delays in widget tests; use fake async where timing matters.
The deep-link from the notification card to the assignment detail screen depends on the assignment detail route being stable and accepting an assignment ID parameter. If the routing contract is undocumented or changes during parallel development, the CTA will silently navigate to a fallback screen.
Mitigation & Contingency
Mitigation: Confirm the assignment detail route path and parameter contract with the team building or maintaining that screen before implementing the CTA. Add an integration test that asserts navigating from a mock notification card with a known assignment ID lands on the correct route.
Contingency: If the route is unstable, implement the deep-link as a late-bound string resolved from a central route registry, allowing the target route to be updated without changing the notification card.
Visually distinguishing escalation cards from standard reminder cards using colour alone fails WCAG 1.4.1 (use of colour). Blindeforbundet users relying on screen readers must receive equivalent contextual information through semantics, not just visual styling.
Mitigation & Contingency
Mitigation: Use both colour and an icon/label difference to distinguish card types. Add explicit Semantics widgets with descriptive labels ('Escalation alert: peer mentor has not responded') so screen readers announce the type without visual context.
Contingency: If accessibility review flags the distinction, add a text badge ('Escalation') alongside the visual treatment as a code-change-only fix with no schema or service impact.