high priority medium complexity testing pending testing specialist Tier 4

Acceptance Criteria

Integration tests cover both CSV and Excel export formats for Bufdir reporting
Test fixtures include a multi-level NHF org structure (org β†’ region β†’ chapter β†’ local branch) with at least 20 activity records spanning multiple levels
All required Bufdir column headers are validated for exact presence and ordering in both output formats
Date values are asserted to follow ISO 8601 or Bufdir-mandated format (dd.MM.yyyy) consistently
Numeric fields (hours, participant counts) are validated as correct types, not strings
Organisation unit names and IDs are correctly scoped per the selected hierarchy level in the export
Empty/null optional fields produce empty cells rather than 'null' or 'undefined' strings
Tests run successfully against a local Supabase test instance using the project's test database URL
Each test case is independently resettable β€” fixture teardown cleans inserted rows after each test
Tests fail with a descriptive message when a required column is missing or misplaced
Excel output (.xlsx) opens without warnings in LibreOffice Calc and Microsoft Excel
CSV output uses correct encoding (UTF-8 with BOM for Norwegian characters æøΓ₯)

Technical Requirements

frameworks
flutter_test
integration_test
apis
Supabase REST API (local test instance)
AdminExportService internal API
data models
Activity
Organisation
OrgHierarchy
UserRole
BufdirExportRecord
performance requirements
Full integration test suite completes in under 60 seconds on CI
Each individual test case completes in under 5 seconds
Fixture seed and teardown adds no more than 2 seconds per test
security requirements
Test database credentials must never be committed β€” use environment variables or flutter_test secrets
Fixture data must not contain real PII β€” use synthetic Norwegian names and org IDs
Tests must run only against a designated test Supabase project, not production

Execution Context

Execution Tier
Tier 4

Tier 4 - 323 tasks

Can start after Tier 3 completes

Implementation Notes

AdminExportService should be tested via its public interface (generateCsvExport(), generateExcelExport()) rather than internal methods. Fixture data should model the NHF org hierarchy faithfully: 12 landsforeninger β†’ 9 regioner β†’ 1400 lokallag (use a small representative subset of ~10 nodes). The Bufdir column structure must be treated as a contract β€” store expected column names as a const list in a shared test helper to avoid duplication across test files. For Excel validation, parse the .xlsx bytes using a Dart xlsx reader package; do not rely on visual inspection.

Ensure the local Supabase instance has RLS policies that match production for the admin role used in tests. If the export service uses Supabase Edge Functions, mock those at the HTTP boundary using a test server or Supabase local dev mode.

Testing Requirements

Integration tests only β€” no unit mocks for database layer. Use a local Supabase instance seeded with deterministic fixture data. Cover: (1) full CSV export for a 3-level org scope, (2) full Excel export for same scope, (3) filtered export by date range, (4) export with zero activities (empty state), (5) export with activities spanning multiple org levels. Assert exact column order, correct UTF-8 encoding, and absence of null string artifacts.

Use setUp/tearDown hooks to keep tests isolated. CI must provide a LOCAL_SUPABASE_URL and LOCAL_SUPABASE_ANON_KEY env var for the test runner.

Component
Admin Export Service
service medium
Epic Risks (4)
medium impact high prob technical

OrgHierarchyNavigator rendering NHF's full 1,400-chapter tree in a single widget may cause Flutter frame-rate drops below 60 fps on mid-range devices, making the navigator unusable for NHF national admins.

Mitigation & Contingency

Mitigation: Implement lazy expansion: only load immediate children on node expand rather than the full tree upfront. Use virtual scrolling for long sibling lists. Test with a synthetic 1,400-node dataset on a low-end Android device during development.

Contingency: If lazy expansion is insufficient, replace the tree widget with a paginated drill-down navigator (select level β†’ select child) that avoids rendering more than 50 nodes at a time.

medium impact medium prob dependency

Bufdir may update their required export column structure or file format during or after development. If the AdminExportService hardcodes the current Bufdir schema, any format change requires a code release rather than a config update.

Mitigation & Contingency

Mitigation: Drive the Bufdir column mapping from a configuration repository rather than hardcoded constants. Abstract column definitions into a named schema config so that format changes require only a config update and re-deployment without service logic changes.

Contingency: If Bufdir format changes post-launch, release a config update within one sprint. If the change is structural (new required sections), scope a targeted service update and communicate timeline to partner organisations.

high impact medium prob integration

Role transition side-effects in UserManagementService (e.g., certification expiry removing mentor from chapter listing, pause triggering coordinator notification) may interact with external services like HLF's website sync. Incomplete side-effect handling could leave the system in an inconsistent state.

Mitigation & Contingency

Mitigation: Model side-effects as explicit domain events published after the primary state change is persisted. Implement event handlers as idempotent operations so re-processing is safe. Write integration tests that assert all side-effects fire correctly for each role transition type.

Contingency: If a side-effect fails after the primary change is persisted, log the failure with full context and trigger a manual reconciliation alert to the on-call team. Provide an admin-accessible re-trigger action for failed side-effects.

medium impact medium prob scope

If AdminStatisticsService cache TTL is set too long, org_admin may see significantly stale KPI values (e.g., a mentor newly paused an hour ago still appears as active), undermining trust in the dashboard.

Mitigation & Contingency

Mitigation: Default cache TTL to 5 minutes with a manual refresh action on the dashboard. Implement cache invalidation triggered by UserManagementService write operations that affect counted entities.

Contingency: If staleness causes org admin complaints post-launch, reduce TTL to 60 seconds and introduce a real-time Supabase subscription for high-impact counters (paused mentors, expiring certifications).