high priority high complexity testing pending testing specialist Tier 9

Acceptance Criteria

Peer mentor flow integration test: app launches as peer mentor, navigates to stats screen via bottom nav, taps '30 days' time window, asserts KPI cards update to reflect the 30-day mock data values, asserts chart re-renders for the new time window
Coordinator flow integration test: app launches as coordinator, stats screen shows aggregated chapter data from mock, taps first peer mentor row, drill-down screen renders that peer mentor's name and data, tapping back returns to coordinator screen, previously selected time window is still active
Role-scoping security test: a mock peer mentor session attempts to access coordinator stats screen route directly; test asserts redirect fires and coordinator data is never rendered
Cross-user isolation test: coordinator's mock data includes two chapters; a second out-of-scope chapter's peer mentor is present in mock Supabase response but must not appear in the coordinator's list — test asserts they are absent
All integration tests run against mocked Supabase (no live network); mock responses are defined as fixtures in a `test/fixtures/` directory
Integration tests run successfully in CI (GitHub Actions or equivalent) without device-specific flakiness — use `flutter test integration_test/` with a simulator/emulator target
Each test is independent and can be run in isolation; shared setup is in `setUpAll`/`setUp` helpers, not implicit test ordering
Total integration test suite execution time is under 3 minutes on CI

Technical Requirements

frameworks
Flutter
flutter_test
integration_test package
Riverpod (ProviderScope overrides)
mockito or mocktail
apis
Mocked Supabase client (via dependency injection or ProviderScope override)
data models
UserSession
PeerMentorStats
CoordinatorStats
Chapter
TimeWindow
KPISummary
performance requirements
Each individual integration test scenario completes within 30 seconds on a standard CI runner
Mocked Supabase responses return within 10ms to avoid artificial test slowness
security requirements
Role-scoping bypass attempt must be explicitly tested and confirmed to fail
Mock fixtures must not contain real user PII — use synthetic test data only
ui components
PeerMentorStatsScreen
CoordinatorStatsScreen
TimeWindowSelector
StatsSummaryCards
ActivityChartWidget
PeerMentorStatsList

Execution Context

Execution Tier
Tier 9

Tier 9 - 22 tasks

Can start after Tier 8 completes

Implementation Notes

The most common source of flakiness in Flutter integration tests is `pumpAndSettle` timing out on long animations or infinite loading states — add explicit `Duration` timeouts and assert intermediate states (e.g., shimmer renders before data) rather than waiting for a fully settled state. Structure the `FakeSupabaseClient` to support per-test response configuration via a `setResponse(table, filter, response)` API to avoid a single monolithic mock that couples all tests. For the role-scoping security test, override the auth provider to return a `peer_mentor` role, then attempt to push the coordinator route via `GoRouter.of(context).go('/stats/coordinator')` and assert the redirect destination. Use `addTearDown` in each test to reset any shared provider state.

Document the fixture JSON schema in a comment at the top of each fixture file so future maintainers know the expected shape.

Testing Requirements

Use the `integration_test` Flutter package for all tests in this task — these run on a real device or simulator, not a headless widget tester. Structure tests in `integration_test/stats_dashboard_integration_test.dart`. Use `WidgetTester.pumpAndSettle()` after navigation actions to wait for async state resolution. Mock Supabase by overriding the Supabase client provider in the root `ProviderScope` with a `FakeSupabaseClient` that returns fixture JSON.

Define fixture files in `test/fixtures/stats/` (peer_mentor_stats_30d.json, coordinator_stats_chapter_a.json, etc.). Write three top-level `group()` blocks: 'Peer mentor stats flow', 'Coordinator drill-down flow', 'Role-scoping security'. Each group contains 3–5 focused `testWidgets` scenarios. CI configuration should run integration tests in a separate job using `flutter test integration_test/ -d `.

Component
Coordinator Stats Screen
ui high
Epic Risks (4)
high impact high prob technical

fl_chart renders chart elements on a Canvas, making individual bars and data points invisible to the Flutter Semantics tree by default. Without explicit Semantics wrappers, VoiceOver and TalkBack users receive no chart information, violating the WCAG 2.2 AA requirement mandated by all three partner organizations.

Mitigation & Contingency

Mitigation: Wrap the fl_chart widget in a Semantics node with a dynamically generated textual description of the chart data (e.g., 'Bar chart: January 12, February 8, March 15 sessions'). Implement a collapsible data table alternative beneath the chart that screen readers can navigate row by row. Validate with VoiceOver on iOS and TalkBack on Android before the epic is marked complete.

Contingency: If fl_chart's Canvas rendering cannot be made accessible within the epic timeline, ship the chart hidden from the Semantics tree with ExcludeSemantics and promote the data table alternative to first-class UI so screen reader users have full access to the information. Log a tech-debt item to revisit native chart accessibility in a future sprint.

medium impact medium prob scope

Coordinators managing up to 5 chapters (NHF requirement) require the PeerMentorStatsList to display chapter affiliation labels for each row. With large chapter lists and many peer mentors, the list could become overwhelming and cause layout overflow or scrolling performance issues on lower-end Android devices.

Mitigation & Contingency

Mitigation: Implement chapter filtering as a segmented control above the list so coordinators can scope the list to one chapter at a time. Use ListView.builder (lazy rendering) rather than a Column of all rows. Profile scroll performance on a low-end Android device (Pixel 4a equivalent) with 50 peer mentors in scope during development.

Contingency: If multi-chapter display causes unacceptable performance, ship with single-chapter scope as the default view and a chapter switcher dropdown, deferring the combined cross-chapter list to a follow-up sprint.

low impact low prob technical

Summary cards and the chart widget rebuilding simultaneously on provider state change could cause a visible jank frame on slower devices, degrading perceived quality especially since this screen is intended to feel motivating and polished for gamification purposes.

Mitigation & Contingency

Mitigation: Use AnimatedSwitcher with a short fade transition (150ms) on the stats cards and chart so that data replacement feels intentional rather than jarring. Profile with Flutter DevTools on a mid-range device and ensure no frame exceeds 16ms during a time-window switch.

Contingency: If animation introduces complexity that delays delivery, ship without animation and use a loading skeleton (shimmer effect) during re-fetch instead, which is simpler and equally effective at masking the data swap.

high impact low prob security

If the role-based screen dispatch is misconfigured, a peer mentor could navigate to the coordinator stats screen and see aggregated chapter data for all peer mentors, which is a data privacy violation and a compliance risk for all three organizations.

Mitigation & Contingency

Mitigation: Implement role guard at the router level using an existing role-route-guard component so the coordinator screen route is unreachable for peer mentor roles. Add a widget test that mounts the coordinator screen with a peer mentor session token and asserts that the guard redirects to the no-access screen.

Contingency: If a bypass is found in QA, add a secondary in-screen role assertion in the coordinator screen's initState that throws an AuthorizationException and navigates to the error screen, ensuring defence in depth regardless of router configuration.