Skip to content

test(mailer): add test coverage for 'disabled' mode #1122

@losolio

Description

@losolio

Summary

The mailer library recently added a 'disabled' mode that activates when SMTP configuration is missing in production. This mode needs test coverage.

Changes requiring test updates

Breaking change in createMailerFromEnv

  • Old behavior: Threw an error when SMTP config missing in production
  • New behavior: Returns 'disabled' mode with a warning

Tests at lines 204-246 in libs/mailer/src/mailer.test.ts expect a thrown error but the new code will not throw.

New 'disabled' mode behavior (not yet tested)

  1. Sending email in disabled mode - should log a warning and not attempt to send
  2. Verifying SMTP connection in disabled mode - should return true (no connection to verify)
  3. Creating mailer from env in production without SMTP - should create mailer with mode: 'disabled'

Files affected

  • libs/mailer/src/mailer.ts (lines 81-86, 145-155)
  • libs/mailer/src/mailer.test.ts (tests to add/update)

Acceptance criteria

  • Update existing tests that expect thrown error for missing SMTP config
  • Add test for send() in disabled mode (logs warning, returns early)
  • Add test for verify() in disabled mode (returns true)
  • Add test for createMailerFromEnv() in production without SMTP config (creates disabled mode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions