End-to-end integration test for full pause workflow
epic-peer-mentor-pause-management-core-workflows-task-014 — Implement an end-to-end integration test covering the complete pause and reactivation journey: peer mentor activates pause via PauseActivationScreen → PauseManagementService persists record → PauseNotificationService dispatches in-app and push notifications → coordinator receives notification → coordinator views CoordinatorPauseRosterScreen with updated mentor status → mentor reactivates → roster updates. Use flutter_test integration_test package with a Supabase test project. Verify all state transitions and UI updates are consistent.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 7 - 84 tasks
Can start after Tier 6 completes
Implementation Notes
The biggest risk in this test is Realtime subscription timing — the coordinator's roster update depends on a Supabase Realtime channel message arriving and the BLoC re-rendering the widget. Use a retry loop with pumpAndSettle() rather than a fixed sleep to handle variable network latency. Structure the test as a single testWidgets block with named checkpoints (pause_submitted, notification_visible, roster_updated, reactivated) so that failure messages identify exactly which checkpoint failed. Use a dedicated test Supabase project with a schema that mirrors production, managed via migration files.
Store test user credentials in a .env.test file loaded via flutter_dotenv — add this file to .gitignore immediately. For TestFlight compatibility, ensure the integration_test runner is included in the iOS build target before submitting.
Testing Requirements
Integration test using the integration_test package targeting a dedicated Supabase test project. Create a test helper (e.g., TestSupabaseClient) that seeds a peer mentor user, a coordinator user, and their chapter association before each test, then deletes them in tearDown. Use WidgetTester.pumpAndSettle() with a timeout to wait for async UI updates after Supabase writes. Assert both the database state (direct Supabase query in the test) and the UI state (finder-based assertions) at each checkpoint.
Run on iOS Simulator via TestFlight build target. Include a smoke test that verifies the app reaches the home screen before running the full workflow, to fail fast on configuration errors.
Concurrent status transitions (e.g., coordinator and automated scheduler both attempting to update the same mentor's status simultaneously) may produce race conditions or inconsistent state in the database, leading to audit log gaps or incorrect notifications.
Mitigation & Contingency
Mitigation: Implement all status transitions as atomic Postgres RPC functions with optimistic locking (version column or updated_at check). Use database-level constraints rather than application-level guards as the final enforcement point.
Contingency: Add a compensation job that reconciles status and log table consistency on each nightly scheduler run, surfacing any discrepancies to coordinator dashboards.
The coordinator-to-mentor assignment relationship may not always be 1:1 or may be stale (coordinator reassigned after a pause was set), causing notifications to be sent to the wrong coordinator or not sent at all.
Mitigation & Contingency
Mitigation: Query the assignment relationship at notification dispatch time rather than caching it at pause creation time. Add a fallback to notify the chapter administrator if no active coordinator assignment exists.
Contingency: Log all undeliverable notification attempts with the originating mentor ID so administrators can manually follow up, and surface undelivered notification counts on the coordinator dashboard.
The CoordinatorPauseRosterScreen may load slowly for coordinators managing large rosters with many concurrent certification expiry queries, degrading usability on low-bandwidth mobile connections.
Mitigation & Contingency
Mitigation: Use a single Supabase RPC that joins mentor status, certification expiry, and assignment data in one query rather than N+1 individual calls. Implement pagination with a configurable page size and skeleton loading states.
Contingency: Add an offline cache of the last-fetched roster state using Riverpod with SharedPreferences, ensuring coordinators can at minimum view stale data when connectivity is poor.