Write widget tests for ActivityTypeSelectionScreen
epic-activity-type-configuration-business-logic-task-009 — Write Flutter widget tests for ActivityTypeSelectionScreen covering: list renders all active types with correct resolved labels, tapping a type returns the correct ActivityType object with full metadata to the caller, loading state shows a CircularProgressIndicator, error state shows a retry option, and accessibility semantics are present on all interactive elements. Use flutter_test and a mocked Riverpod provider override.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 7 - 84 tasks
Can start after Tier 6 completes
Implementation Notes
Override the activityTypesProvider (or equivalent Riverpod provider) in each test's ProviderScope to return controlled AsyncValue states. For the tap callback test, pass a closure to the onSelected parameter that assigns to a nullable ActivityType local variable, then assert it equals the expected object after tester.tap() and tester.pump(). For semantics tests, call tester.ensureSemantics() before pumping then dispose SemanticsHandle in tearDown. For orientation tests, use tester.binding.setSurfaceSize() to simulate landscape dimensions.
Avoid testing internal implementation details — test observable behavior only (what is rendered, what callback is called).
Testing Requirements
Flutter widget tests using flutter_test. Wrap each test in a ProviderScope with explicit provider overrides returning AsyncValue.data(), AsyncValue.loading(), or AsyncValue.error() as needed. Use tester.pumpWidget() and tester.pumpAndSettle(). Use find.byType(), find.text(), and find.bySemanticsLabel() for assertions.
For tap tests, capture the callback argument using a local variable assigned in a closure passed to onSelected. Test semantics using tester.ensureSemantics() and tester.getSemantics(find.byType(ListTile)). No real network calls or database connections.
Metadata flag combination rules differ between organisations (e.g., Blindeforbundet honorarium thresholds, HLF mutual exclusion of km and transit). Encoding these as generic service-level validation may be insufficient, forcing organisation-specific branching inside the service that becomes unmaintainable as new organisations are onboarded.
Mitigation & Contingency
Mitigation: Model flag validation as a pure function that accepts an ActivityTypeMetadata object and an org configuration record, making org-specific rules data-driven rather than hardcoded. Establish the validation contract in the foundation epic so the service just delegates to the validator.
Contingency: Defer complex cross-flag validation to a lightweight edge function that can be updated without a mobile app release, accepting that initial validation in the mobile service layer is permissive and corrected server-side.
Blindeforbundet users rely on VoiceOver and JAWS. If the selection screen is built with non-semantic widgets that fail accessibility audit late in the sprint, a significant rework of the widget tree may be required, blocking the registration wizard integration.
Mitigation & Contingency
Mitigation: Build the selection screen against the project's established accessibility design tokens and semantics wrapper conventions from the start. Run Flutter's semantic tree inspector and a manual VoiceOver pass before marking any widget task complete.
Contingency: Wrap all tappable items in the project's SemanticsWrapperWidget and schedule a dedicated accessibility review session with a screen reader user from Blindeforbundet before the epic is closed.