Build ExportProgressIndicator stateless UI widget
epic-bufdir-report-export-foundation-task-011 — Implement the export progress indicator as a stateless Flutter widget showing step-by-step export progress: querying data, aggregating, generating file, uploading, and ready. Widget takes a current ExportStep enum and optional percentage value, renders an animated progress bar with step labels, and displays an error state with retry option. Accessible via semantics labels for screen readers. Zero service dependencies for isolated development and testing.
Acceptance Criteria
Technical Requirements
Implementation Notes
Declare ExportStep as a Dart enum in a shared types file so both the widget and the BLoC/Riverpod state can import it without circular dependencies. Use implicit animations (AnimatedContainer width driven by a 0.0–1.0 fraction computed from currentStep.index / (ExportStep.values.length - 1)) to avoid managing AnimationController in a StatelessWidget. For the step labels, use a ListView.builder or a Row with Expanded children — not hardcoded widths. Apply design tokens via Theme.of(context).extension
Ensure the Semantics node uses liveRegion: true so screen readers announce state changes without user focus. The retry button should only appear in the error state; guard with a conditional in the build method rather than opacity tricks to avoid accessibility pitfalls.
Testing Requirements
Write flutter_test widget tests covering all 6 ExportStep states (including error). Verify Semantics tree contains correct label strings for each state. Pump animation frames and assert progress bar width matches expected fraction. Test that onRetry is called exactly once when retry button is tapped.
Test with percentage = null and percentage = 0.0/0.5/1.0. Run golden tests for visual regression. Target 100% branch coverage of the widget's build method.
NHF's three-level hierarchy (national / region / chapter) with 1,400 chapters may have edge cases such as chapters belonging to multiple regions, orphaned nodes, or missing parent links in the database. Incorrect scope expansion would silently under- or over-report activities, which could invalidate a Bufdir submission.
Mitigation & Contingency
Mitigation: Obtain a full hierarchy fixture export from NHF before implementation begins. Write exhaustive unit tests covering boundary cases: single chapter, full national roll-up, chapters with no activities, and chapters assigned to multiple regions. Validate resolver output against a known-good manual count.
Contingency: If hierarchy data quality is too poor for automated resolution at launch, implement a manual scope override in the coordinator UI that allows the coordinator to explicitly select org units from a tree picker, bypassing the resolver.
The activity_type_configuration table may not cover all activity types currently in use, leaving a subset unmapped at launch. Bufdir submissions with unmapped categories will be incomplete and may be rejected by Bufdir.
Mitigation & Contingency
Mitigation: Run a query against production activity data before implementation to enumerate all distinct activity type IDs. Cross-reference with Bufdir's published category schema (request from Norse Digital Products). Flag every gap as a known issue and build the warning surface into the preview panel.
Contingency: Implement a fallback 'Other' category bucket for unmapped types and surface a prominent warning in the export preview requiring coordinator acknowledgement before proceeding. Log unmapped types for post-launch cleanup.
Supabase RLS policies on generated_reports and the storage bucket must enforce strict org isolation. A misconfigured policy could allow a coordinator from one organisation to read another organisation's export files, creating a serious data breach with GDPR implications.
Mitigation & Contingency
Mitigation: Write RLS integration tests that attempt cross-org reads with explicitly different JWT tokens and assert that all attempts return empty sets or 403 errors. Include RLS policy review in the pull request checklist. Use Supabase's built-in policy tester during development.
Contingency: If a policy gap is discovered post-deployment, immediately revoke all signed URLs for affected exports, audit the access log for unauthorised reads, and issue a coordinated disclosure to affected organisations per GDPR breach notification requirements.