Implement session-lock guard for report screen
epic-structured-post-session-report-screen-task-001 — Build the fill-after-session enforcement logic that prevents the post-session report screen from opening while an activity session is still active. Query the active session state from the activity repository and display an informative blocking UI if the session is ongoing. This guard must be integrated at the route level so no navigation path bypasses it.
Acceptance Criteria
Technical Requirements
Implementation Notes
Implement the guard as a GoRouter `redirect` callback on the report route, not inside the screen widget. The callback should be async (GoRouter supports async redirects via a `FutureOr
The blocking screen should use the app's standard design tokens (colors, typography, spacing) from the existing token system — do not hardcode values. Ensure the back button calls `context.go(...)` rather than `Navigator.pop()` to stay within GoRouter's navigation stack.
Testing Requirements
Write unit tests for the guard logic function in isolation (mock activity repository, test all ActivityStatus enum values). Write widget tests for the BlockingScreen widget (verify text content, button labels, and tap navigation). Write a GoRouter integration test using `GoRouter.optionURLReflectsImperativeAPIs` and a test router setup to verify the redirect fires correctly. Cover: blocked state, allowed state, loading state, and error/retry state.
Use `flutter_test` with `WidgetTester` and a mock activity repository.
End-to-end integration tests that span Flutter UI → Supabase → RLS → storage are inherently flaky in CI due to network timing, test database state, and Supabase cold-start latency. Flaky tests erode confidence and slow the release pipeline.
Mitigation & Contingency
Mitigation: Use a dedicated Supabase test project with seeded org and user fixtures. Wrap all E2E tests in retry logic with a fixed seed and tear-down hooks. Keep E2E tests in a separate test suite that runs on-demand rather than on every PR, with unit and widget tests as the primary CI gate.
Contingency: If E2E tests remain unreliable, replace the Supabase calls in integration tests with a verified fake (in-memory repository implementations) and promote the real Supabase tests to a nightly scheduled run rather than blocking PR merges.
Health status, course interest, and assistive device fields contain personal health data. If any logger, analytics event, or crash reporter captures field values — through automated error serialisation or developer-added debug logs — the feature could violate GDPR and Blindeforbundet's data processor agreement.
Mitigation & Contingency
Mitigation: Audit all log statements in the report feature's code paths before the epic is marked done. Apply a PII-safe logging wrapper that strips field values from any serialised form state before it reaches the logger. Add a CI lint rule that flags direct logger calls within report-related files.
Contingency: If PII is found in logs post-launch, immediately disable the affected logging call and rotate any credentials that were exposed. Notify the data protection officer and document the incident per GDPR Article 33 requirements.