medium priority high complexity testing pending testing specialist Tier 7

Acceptance Criteria

Test file compiles and runs in CI without flakiness across 5 consecutive runs
Test seeds a deterministic Supabase session with at least 3 validation warnings and 1 anomaly before navigating to BufdirPreviewScreen
Validation banner is found via widget key and its warning count label matches the seeded data exactly
Diff panel opens on tap and prior-period data rows are rendered; at least one threshold-exceeded row has its highlight color verifiable via widget inspection
Diff panel dismisses correctly and focus returns to the preview screen (no navigation stack artifacts)
Export button tap triggers the warning dialog; dialog title and body text match expected strings
Acknowledging the dialog navigates to the export screen and the session object passed as route argument contains the same period and report ID as the seeded session
Test runs in under 30 seconds on a standard CI device/emulator
All finders use semantic labels or widget keys — no positional index finders
Test cleans up seeded Supabase rows in tearDown to prevent cross-test contamination

Technical Requirements

frameworks
Flutter
flutter_test
integration_test
BLoC
apis
Supabase REST API (seeding test data)
BufdirPreviewService (mock or real)
data models
BufdirReportSession
BufdirFieldRowData
BufdirReportSectionData
BufdirDiffEntry
performance requirements
Full test suite completes within 30 seconds on emulator
No memory leaks: dispose all BLoC instances in tearDown
security requirements
Use a dedicated test Supabase project or row-level security scoped test user — never seed production data
API keys for the test environment must be sourced from --dart-define, not committed to source
ui components
BufdirPreviewScreen
BufdirValidationBanner
BufdirDiffPanel
BufdirExportWarningDialog

Execution Context

Execution Tier
Tier 7

Tier 7 - 84 tasks

Can start after Tier 6 completes

Implementation Notes

Seed data should include: (1) a BufdirReportSession row with status='draft', a known period_id, and at least 3 fields with validationState='warning' and 1 with validationState='anomaly'; (2) a prior-period snapshot row with at least one field exceeding the configured threshold percentage so the diff highlight logic is exercised. Use a custom FlutterDriver or IntegrationTestWidgetsFlutterBinding. Wrap the entire screen under test in a ProviderScope/BlocProvider with real Supabase client pointed at the test project. If BufdirPreviewService uses Riverpod, override the provider with ProviderContainer in the test harness.

For the diff panel highlight assertion, read the BoxDecoration color from the widget tree using tester.widget(find.byKey(diffRowKey)).decoration. Avoid pumping with Duration.zero — use pumpAndSettle to let animations complete. CI must set the SUPABASE_TEST_URL and SUPABASE_TEST_ANON_KEY env vars.

Testing Requirements

This IS the integration test. Use the flutter integration_test package (not flutter_test unit tests). Seed data via Supabase client in setUpAll. Structure the test as a single sequential testWidgets call covering the entire user journey to avoid ordering issues.

Use pumpAndSettle with a timeout after each async action. Assert widget states via Finder + expect(find.byKey(...), findsOneWidget). Add a separate short unit test file verifying the session state object equality after dialog acknowledgement using a mock navigator observer. Target: 100% branch coverage of the happy path and the 'user dismisses dialog' cancellation path.

Component
Bufdir Report Preview Screen
ui high
Epic Risks (3)
medium impact medium prob integration

The preview screen must pass period, scope, and aggregation session state to the Bufdir Report Export screen via navigation arguments. If the export screen's navigation argument schema is not yet finalized when this epic begins, the handoff will require rework — potentially after TestFlight is already in use by coordinators.

Mitigation & Contingency

Mitigation: Define the shared BufdirExportNavigationArgs Dart class jointly with the Bufdir Report Export feature team before this epic starts. Store it in a shared models package both features depend on. Treat the class as an API contract with a minor-version bump policy.

Contingency: If the export screen's argument schema changes after the preview screen is implemented, the BufdirPreviewService session state model can be adapted with a compatibility shim. The preview screen itself requires only a one-line navigation call change.

medium impact low prob technical

The period diff view loads prior-period data on demand and renders it inline with the current report. On a large report (many sections, many fields) combined with slow Supabase connectivity, the diff overlay could block the UI or produce a janky re-render that degrades the coordinator experience during the pre-submission review.

Mitigation & Contingency

Mitigation: Load prior-period data in a background Riverpod FutureProvider that starts prefetching when the preview screen mounts (not when the user taps the diff toggle). Show a shimmer placeholder on each field row's prior-period column while loading. Cache prior-period data in BufdirPreviewRepository using the same local cache as current-period data.

Contingency: If diff view performance is unacceptable on TestFlight devices, disable the toggle for the initial TestFlight release and ship the diff view in the following sprint after profiling the Supabase query plan and adding an appropriate Postgres index on the prior-period data table.

high impact medium prob scope

The full preview screen will be reviewed by coordinators on TestFlight who will cross-reference it against their physical Bufdir reporting forms. Any section ordering difference or label mismatch discovered during UAT will require a fix before the feature can be signed off, potentially delaying the entire Bufdir reporting pipeline.

Mitigation & Contingency

Mitigation: Conduct a pre-TestFlight alignment review with at least one coordinator from NHF and one from HLF using a static screenshot of the preview screen layout. Obtain written sign-off on section order and field labels before distributing to the full test group of 5-8 people.

Contingency: If label mismatches are found during TestFlight UAT, update BufdirReportStructureMapper constants and rebuild. Since the mapper is a pure Dart class with no persisted state, corrections are deployed in the next TestFlight build with no database migration required.