Skip to content

[Testing] Zero test coverage for NotificationPreferencesScreen — toggle, quiet-hours, and all-disable paths #144

Description

@cybermax4200

Why this matters now

The notification system is v0.2-complete and directly tied to streak reminders, reward confirmations, and the prefsStore rehydration bug (Issue 8). NotificationPreferencesScreen is the only user-facing control for notification preferences, but it has no tests at all. Any regression in toggle persistence, quiet-hours validation, or the allEnabled master switch is invisible in CI.

Problem / What

src/screens/NotificationPreferencesScreen.tsx (243 lines) contains:

  • A master enable/disable toggle backed by prefsStore.setAllEnabled
  • Per-type toggles for each NOTIFICATION_TYPES value backed by prefsStore.toggleType
  • Quiet-hours from/to time pickers backed by prefsStore.setQuietHours
  • Inline validation (from < to, valid HH:MM format)

None of these interactions have a test file. The nearest coverage is prefsStore.test.ts (which tests only the store, not the screen).

Key Challenges

  • The screen imports @notifee/react-native indirectly via prefsStore.toggleType (which cancels notifications asynchronously). The mock in __mocks__ or rn-modules.ts must be extended.
  • Quiet-hours validation involves parsing time strings; edge cases (midnight wrap 22:00–07:00, identical from/to) must be tested.
  • The component uses TouchableOpacity switches rather than platform SwitchfireEvent.press is the right interaction method.

Acceptance Criteria

  • Test file src/__tests__/NotificationPreferencesScreen.test.tsx created.
  • Tests cover: master toggle enables/disables all notifications, per-type toggle persists to store, quiet-hours update validates and persists, invalid time input shows an error.
  • All tests pass in CI with npm test.

Relevant files / functions

  • src/screens/NotificationPreferencesScreen.tsx
  • src/store/prefsStore.ts
  • src/__tests__/__mocks__/rn-modules.ts — add notifee mock if absent

Out of scope

  • Integration testing with the actual notification delivery system.
  • Testing scheduleDailyStreakReminder (separate concern).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions