Write unit tests for BenefitCalculationResult
epic-benefit-calculator-foundation-task-006 — Write comprehensive unit tests for BenefitCalculationResult: verify all typed fields serialize and deserialize correctly via toJson/fromJson round-trips, test equality and hashCode with identical and differing instances, verify copyWith produces a new instance with only specified fields changed, and confirm toString produces a human-readable representation. Use flutter_test with no external dependencies.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 1 - 540 tasks
Can start after Tier 0 completes
Implementation Notes
Import only 'package:flutter_test/flutter_test.dart' and the model file. Use const constructors where possible in test fixtures for clarity. Define a single canonical 'baseline' instance at the top of the test file and derive variants from it via copyWith to keep tests DRY. For the JSON round-trip, assert field-by-field after deserialization rather than equality on the whole map to produce clear failure messages.
Ensure the test file mirrors the model file path (e.g., test/models/benefit_calculation_result_test.dart). Register the test file in the CI test suite.
Testing Requirements
Pure unit tests using flutter_test. Group tests into four describe blocks: (1) JSON serialization/deserialization round-trips covering all fields individually and as a complete object, (2) equality and hashCode with identical instances, single-field differences, and null-vs-value differences, (3) copyWith with full override, partial override, and no override, (4) toString format validation using contains/matches checks. Aim for 100% branch coverage of the model class. No mocks or fakes required — instantiate BenefitCalculationResult directly.
Supabase organisation configuration table may not yet have the five multiplier columns, requiring a migration. If the migration is not coordinated with other teams touching the same table, schema conflicts could delay delivery.
Mitigation & Contingency
Mitigation: Add multiplier columns in a dedicated, non-destructive ALTER TABLE migration script. Review the organisation config table schema with the backend team before writing the migration. Use nullable columns with defaults so existing rows are unaffected.
Contingency: If the migration cannot be deployed in time, stub the repository to return hardcoded default multiplier values from a local config file, allowing parallel development. Swap in the real Supabase fetch once the migration is live.
The ActivitySummaryAggregator depends on activity records already persisted in the database. For newly onboarded peer mentors with no activity history, the aggregator will return zero counts, which could make the calculator appear broken on first use.
Mitigation & Contingency
Mitigation: Design the pre-fill value object to distinguish between 'no data yet' and 'zero activities'. The calculator input panel should display empty inputs (not zero) when no history exists, with placeholder text guiding the user to enter values manually.
Contingency: If the distinction cannot be surfaced cleanly in the UI timeline, fall back to always showing empty inputs and document the manual-entry path as the primary UX until activity data accumulates.