high priority medium complexity testing pending testing specialist Tier 6

Acceptance Criteria

BenefitCalculationService unit tests cover: zero sessions input returns zero for all metrics, maximum allowed session count returns correct capped values, fractional hour inputs round correctly, all formula branches produce expected numeric results
BenefitCalculatorBLoC unit tests cover: initial state is BenefitCalculatorInitial, InputChanged event triggers BenefitCalculatorLoading then BenefitCalculatorSuccess, invalid input triggers BenefitCalculatorFailure, reset event returns to initial state
CalculatorInputPanel widget tests verify: validation error text appears when value exceeds maximum, error clears when valid value entered, stepper increment/decrement buttons update displayed value, input field rejects non-numeric characters
BenefitMetricTile widget tests verify: compact mode renders label and value only, expanded mode renders label, value, and description, tap on tile toggles between compact and expanded if interactive
Integration test for share flow: mock RepaintBoundary PNG capture returns a non-null Uint8List, share_plus SharePlus.share is called with the captured image path, share button returns to enabled state after share completes
Overall line coverage ≥ 80% measured by `flutter test --coverage` across all five component files
All tests pass in CI without flakiness across 3 consecutive runs
No test directly imports platform channel code — all platform interactions mocked via dependency injection or MethodChannel mock

Technical Requirements

frameworks
Flutter
flutter_test
BLoC (flutter_bloc)
bloc_test
apis
share_plus (mocked)
performance requirements
Full test suite completes within 60 seconds on CI (GitHub Actions standard runner)
No individual test takes longer than 5 seconds
security requirements
Test fixtures must not contain real PII — use synthetic names and values only
ui components
CalculatorInputPanel (widget under test)
BenefitMetricTile (widget under test)
BenefitResultsCard (widget under test)
BenefitCalculatorScreen (integration widget under test)

Execution Context

Execution Tier
Tier 6

Tier 6 - 158 tasks

Can start after Tier 5 completes

Implementation Notes

Use bloc_test's blocTest() for all BLoC tests — it handles async event processing and state sequence assertions cleanly. For the PNG capture integration test, wrap the RepaintBoundary key in a testable abstraction (e.g., ScreenCaptureService) so the real RenderRepaintBoundary.toImage() call can be swapped with a stub returning a fake Uint8List. For share_plus, inject a ShareService wrapper around SharePlus.share() — this avoids MethodChannel mocking complexity. Widget tests should pump with pumpAndSettle() after interactions that trigger animations.

Coverage: focus on branching logic in BenefitCalculationService (formula edge cases) and BLoC event handlers — these have the highest defect risk. Avoid testing framework internals (e.g., do not test that BlocProvider.of() works).

Testing Requirements

Three test layers required: (1) Unit tests in test/unit/ for BenefitCalculationService and BenefitCalculatorBLoC using bloc_test's blocTest() helper for BLoC state sequence assertions; (2) Widget tests in test/widget/ for CalculatorInputPanel, BenefitMetricTile, and BenefitResultsCard using WidgetTester and pumpWidget with a stub BLoC; (3) Integration-level widget test in test/integration/ for BenefitCalculatorScreen share flow using a MockSharePlus injected via a service locator or constructor injection. Run `flutter test --coverage` and generate lcov report. Fail the CI step if coverage drops below 80%. Use mocktail for all mocks — avoid mockito code generation overhead.

Component
Benefit Calculator Screen
ui low
Epic Risks (3)
high impact medium prob technical

The RepaintBoundary PNG capture approach for sharing the results card may produce blurry or oversized images on high-DPI devices, or may silently fail on certain Android OEM configurations that restrict off-screen rendering. A failed share would break one of the core use cases (recruitment tool).

Mitigation & Contingency

Mitigation: Implement the capture using the established screenshot-capture-utility pattern already present in the Wrapped summary feature (component 542-screenshot-capture-utility). Test on a range of iOS and Android devices including Samsung and Huawei OEM builds during development. Set explicit pixel ratio (3.0) when calling toImage() to guarantee resolution.

Contingency: If image capture fails on a platform, the BenefitShareService falls back to sharing the plain-text summary only, with a user-facing message explaining the image could not be generated. This ensures the share flow never fully blocks.

high impact medium prob technical

Implementing full WCAG 2.2 AA compliance for the results card and metric tiles — including live regions, focus management, and semantic labels that read naturally in Norwegian — requires deep familiarity with Flutter semantics APIs. Gaps may only surface during screen reader testing on physical devices, late in the sprint.

Mitigation & Contingency

Mitigation: Use the existing semantics-wrapper-widget (606) and live-region-announcer (608) components from the accessibility feature rather than implementing custom semantics. Assign screen reader testing on a physical iPhone with VoiceOver as a mandatory acceptance gate, not an afterthought. Write widget tests using Flutter's AccessibilityGuideline matchers early in development.

Contingency: If screen reader issues are found late, the pure semantic markup approach (no Canvas numbers, all Semantics wrappers) limits the blast radius to label text corrections. Escalate to the accessibility feature team for a pairing session to resolve complex focus management issues.

medium impact low prob integration

The BenefitResultsCard must match the Wrapped design language used in the annual summary feature. If design tokens or widget patterns are inconsistent between the two features, the results card will look out of place and undermine the intended emotional impact for sharing.

Mitigation & Contingency

Mitigation: Review the existing Wrapped summary screen (529-wrapped-summary-screen) and stat card widget (530-stat-card-widget) implementations before building the results card. Reuse design tokens from the existing design-token-theme (200) system. Involve the designer in a review of the results card mock-up against the Wrapped language before implementation begins.

Contingency: If design parity issues are discovered post-implementation, isolate visual adjustments to the BenefitResultsCard widget. The feature's business logic and accessibility compliance are unaffected by visual polish changes.