high priority medium complexity testing pending testing specialist Tier 3

Acceptance Criteria

All specified test scenarios pass without failure or skip
Empty required field → completeness error: test asserts severity == error, ruleClass == 'completeness', and message references the field name
Populated required field → no completeness issue: test asserts empty issue list for that field
Value at threshold → no threshold warning: test asserts no issue emitted
Value below threshold → threshold warning: test asserts severity == warning, ruleClass == 'threshold', message includes actual and minimum
Null prior period → no anomaly issue: test asserts empty anomaly issue list regardless of current value
Value within anomaly tolerance → no anomaly warning
Value outside anomaly tolerance → anomaly warning with correct percentage in message
Mixed issues → sorted output: errors before warnings in ValidationResult
Empty report → ValidationResult with empty issues and isValid == true
Overall line coverage for the 357-bufdir-field-validation-service component reaches at least 90%
All test files are located under test/ mirroring the lib/ directory structure
Tests run in under 5 seconds total with no external dependencies (no Supabase, no network)

Technical Requirements

frameworks
flutter_test
Dart
data models
BufdirReportModel
BufdirReportSectionModel
ValidationIssue
ValidationResult
BufdirThresholdConfig
AnomalyConfig
BufdirFieldLabelMap
performance requirements
Full test suite for this component runs in under 5 seconds
security requirements
Test fixtures must not contain real personal data — use synthetic placeholder values only

Execution Context

Execution Tier
Tier 3

Tier 3 - 413 tasks

Can start after Tier 2 completes

Implementation Notes

Create a test helper file test/validation/validation_test_helpers.dart with factory functions: buildSection({Map fields, List requiredFieldKeys}), buildReport({List sections}), defaultThresholdConfig(), defaultAnomalyConfig(). This eliminates boilerplate across test files. For the orchestration service tests (bufdir_field_validation_service_test.dart), prefer real evaluator instances over fakes since this is the integration-level test file for the component — using real evaluators gives higher confidence. For individual evaluator test files, construct evaluators directly with minimal configs.

Use expect(result.issues, isEmpty) rather than expect(result.issues.length, 0) for readable failure messages. Avoid any async test patterns — all methods under test are synchronous.

Testing Requirements

Test file structure: test/validation/completeness_rule_evaluator_test.dart, test/validation/threshold_compliance_rule_evaluator_test.dart, test/validation/anomaly_detection_rule_evaluator_test.dart, test/validation/bufdir_field_validation_service_test.dart. Each file uses group() to organise related scenarios. Each test uses expect() with typed matchers (e.g., isA(), hasLength(1), equals('error')). Use setUp() for common fixtures (model builders, default configs).

No mocking frameworks required — use simple in-memory fakes or direct model construction. Run with: flutter test test/validation/. Aim for 100% scenario coverage as listed in the task description; 90% line coverage is the minimum gate.

Component
Bufdir Field Validation Service
service medium
Epic Risks (2)
medium impact medium prob scope

The exact minimum threshold values required by Bufdir guidelines (e.g., minimum participant counts per section) may not be formally documented in machine-readable form. If thresholds must be researched or negotiated during implementation, the validation service will be delayed and may launch with incomplete rules, reducing its effectiveness.

Mitigation & Contingency

Mitigation: Compile threshold rules from the Bufdir reporting guidelines PDF before sprint start. Store rules in a separate configuration file (not hardcoded in the service class) so they can be updated without a service rewrite. Treat unknown thresholds as 'no minimum' to avoid false errors.

Contingency: Launch with completeness and anomaly validation only, shipping threshold compliance rules as a follow-on config update once rules are confirmed with Bufdir. Flag this as a known limitation in the coordinator help text.

high impact low prob technical

BufdirPreviewService coordinates three async operations (fetch aggregated data, map structure, run validation). Race conditions or partial failures in this chain could produce an inconsistent preview model — e.g., a model with field values but no validation results — which would silently mislead coordinators into thinking the report is clean.

Mitigation & Contingency

Mitigation: Model the orchestration as a single BLoC/Cubit state machine with explicit states (Loading, Loaded, Error) and ensure validation is always run atomically after mapping, never in parallel. Write integration tests that simulate network failure at each step of the chain.

Contingency: If a partial failure state reaches production, detect it via the missing validation summary field in the preview model and show a full-screen error state rather than an incomplete preview, prompting the coordinator to retry.