high priority low complexity testing pending testing specialist Tier 2

Acceptance Criteria

Tests exist for all five payload subtypes: reminder, expiry, scenario, pause, system — each deserializes from a fixture JSON map to the correct concrete type
Roundtrip test: for each subtype, `payload.toJson()` produces a map that is deep-equal to the original fixture map used in `fromJson`
Tests verify that missing optional fields in payload JSON do not throw and produce null (or default) values on the model
Tests verify that explicitly null optional fields are handled identically to missing fields
NotificationType.fromString (or equivalent) correctly maps all valid string values to enum cases
NotificationType.fromString throws or returns a fallback for unknown string values — behavior is tested explicitly
Notification.copyWith test: changing each field produces a new object with only that field changed, all other fields preserved
Notification.copyWith with no arguments returns an object equal to the original
Branch coverage for Notification and all NotificationPayload subclasses is ≥ 90% as reported by `flutter test --coverage`
All tests pass with `flutter test` without warnings

Technical Requirements

frameworks
flutter_test
data models
Notification
NotificationPayload
ReminderPayload
ExpiryPayload
ScenarioPayload
PausePayload
SystemPayload
NotificationType
performance requirements
All unit tests complete within 5 seconds total
security requirements
Test fixtures must not contain real user data or PII

Execution Context

Execution Tier
Tier 2

Tier 2 - 518 tasks

Can start after Tier 1 completes

Implementation Notes

Write inline JSON fixture maps as `const Map` at the top of each test group — this makes tests self-documenting and avoids file loading overhead. For the roundtrip test, use `expect(model.toJson(), equals(fixtureMap))` with deep equality. For copyWith, test both the changed-field case and the identity case (no args). For enum parsing, test every valid string and at least one unknown string.

If the model uses a factory constructor with a type discriminator field (e.g., `'type': 'reminder'`), ensure the discriminator logic is exercised for each branch. Coverage gaps are most common in error/fallback branches — make sure unknown enum values and malformed optional fields are explicitly tested.

Testing Requirements

Pure unit tests using flutter_test (no WidgetTester needed). Organize tests in `test/features/notifications/domain/notification_model_test.dart`. Use a `fixtures/` map or inline factory helpers for JSON construction — do not rely on file I/O. Group tests by: (1) NotificationType enum parsing, (2) each payload subtype deserialization, (3) roundtrip fidelity per subtype, (4) null/missing field handling, (5) copyWith correctness.

Run `flutter test --coverage` and verify ≥ 90% branch coverage on the model files. No mocking frameworks needed — these are pure data class tests.

Component
Notification Domain Model
data low
Epic Risks (3)
high impact medium prob technical

Supabase Realtime channels on mobile networks can drop silently. If reconnection logic is flawed, users miss notifications without knowing it, undermining the audit-trail guarantee.

Mitigation & Contingency

Mitigation: Implement exponential-backoff reconnection with a maximum of 5 retries; expose a channel-status stream to the BLoC so it can trigger a full-fetch fallback when the channel reconnects after a gap.

Contingency: If Realtime reliability proves insufficient in production, fall back to polling the repository every 60 seconds as a background supplement to the Realtime channel.

high impact medium prob security

Coordinator and org-admin RLS expansions require joining user_roles and org_memberships tables. An incorrect policy could expose notifications to wrong users or block legitimate access entirely.

Mitigation & Contingency

Mitigation: Write dedicated RLS integration tests for each role (peer mentor, coordinator, org admin) using separate Supabase test projects. Review policies with the security checklist before merging.

Contingency: If an RLS defect is discovered post-deployment, disable the expanded-scope policy and revert to user-scoped-only access while a corrected migration is prepared and tested.

medium impact medium prob integration

JSONB payload structure may vary across notification types created by different Edge Functions (reminder, expiry, scenario, pause). Missing or renamed fields will cause runtime parse failures.

Mitigation & Contingency

Mitigation: Define a canonical NotificationPayload union type in a shared schema document. Each Edge Function must validate its payload against this schema before inserting. Add fallback parsing with default values in the domain model.

Contingency: Wrap all payload parsing in try/catch and log malformed payloads to a monitoring channel; render a generic notification item rather than crashing when the payload cannot be parsed.