Skip to content

NotificationsService has no unit tests: only the gateway spec exists #1085

Description

@nanaf6203-bit

NotificationsService has no unit tests: only the gateway spec exists

Labels / Complexity: testing · Medium Complexity — Medium

Problem

src/notifications/ has exactly one spec — notifications.gateway.spec.ts. The module's core, NotificationsService (which creates, delivers, and persists notifications across email/SMS/in-app channels), is untested. The SMS channel also carries the in-memory rate limiter (#55) whose behavior needs pinning before it is migrated. A regression in delivery selection or persistence ships silently.

Why this is architecturally hard

  1. Channel selection is the test design. Notifications fan out to multiple channels based on user prefs; tests must pin which channels fire for which preferences.
  2. Persistence + delivery are separate concerns. Tests should cover the Prisma write path (via test/database or mocks) and the transport dispatch (via transport stubs) independently.
  3. The rate limiter must be pinned. With Input validation and sanitization #55 migrating the SMS rate limit, tests written now freeze the current window semantics so the migration cannot change them.

Acceptance criteria

  • Unit tests cover notification creation, channel selection, persistence, and delivery dispatch.
  • SMS rate-limit behavior (window, cap, reset) is pinned by tests.
  • Tests run in CI via npm test; the PR reports coverage via npm run test:cov.

Out of scope

The rate-limit durability migration (#55); notification behavior changes.

Getting started

  • src/notifications/notifications.service.ts — the core to cover
  • src/notifications/notifications.gateway.spec.ts — the existing spec style

Commands: npm test, npm run test:cov.

Good first files to read: src/notifications/notifications.service.ts, src/notifications/notifications.gateway.spec.ts.

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