Write widget tests for ContactCardWidget and PeerMentorCardWidget
epic-contact-list-management-ui-components-task-011 — Write Flutter widget tests using flutter_test covering: ContactCardWidget renders name, role badge, org label, and truncated notes correctly; onTap triggers the navigation callback with the correct contact ID; PeerMentorCardWidget renders all mentor-specific fields; availability and certification status chips display correct colors; both cards meet minimum touch target size. Use mock fixtures from task-001. Run under the golden test baseline for visual regression checks.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
For touch target size assertion: use tester.getSize(find.byType(ContactCardWidget)) and assert width >= 48 and height >= 48. For callback verification: use a bool flag or a captured-value variable — avoid Mockito unless already in the project dependencies. For golden tests: establish baselines on first run with --update-goldens; commit PNG baselines to the repo under test/goldens/. For color chip assertions: use tester.widget
Ensure OrgLabels are injected via the widget constructor or a test-scoped provider override — do not rely on a real Supabase call.
Testing Requirements
Use flutter_test WidgetTester for all tests. Organize tests in two describe blocks: contact_card_widget_test.dart and peer_mentor_card_widget_test.dart. Each file must have: (1) a 'renders correctly' group with field-level assertions, (2) an 'interaction' group with tap callback verification, (3) an 'accessibility' group checking touch target size via tester.getSize(), (4) a 'golden' group generating PNG baselines with matchesGoldenFile. Use the mock fixture factory from task-001 to construct test data.
Do not use real Supabase connections. Wrap widgets in MaterialApp with the project theme to ensure design tokens resolve correctly.
Design token color values used in role badges, certification status indicators, and availability chips may not meet the WCAG 2.2 AA contrast ratio of 4.5:1 when rendered against card backgrounds, requiring rework after accessibility review and potentially blocking acceptance sign-off.
Mitigation & Contingency
Mitigation: Run the contrast-ratio-validator on every new token combination during widget development. Enforce the CI accessibility lint runner on all PRs touching visualization components, and validate against the contrast-safe-color-palette before finalizing card designs.
Contingency: If contrast failures are found late, adjust token values in the design token theme centrally — since all widgets consume design tokens rather than hardcoded colors, all affected widgets will be corrected by a single token update without per-widget changes.
The ContactViewSwitcher is required for Barnekreftforeningen but must not appear for other organizations. If the organization labels provider does not yet expose a reliable feature flag for this widget, it may render universally or be conditionally hidden in an inconsistent way, breaking the role-specific layout contract.
Mitigation & Contingency
Mitigation: Implement view switcher visibility as a constructor parameter on ContactListScreen injected from a provider, defaulting to hidden. Document the integration point for the org labels provider so the flag can be wired without changing the widget's API.
Contingency: If org labels integration is delayed beyond this epic, use a feature flag constant keyed to the Barnekreftforeningen organization ID as a temporary gate, with a tracked issue to replace it with the runtime labels provider before general release.