Skip to content

Neither the newsletter nor the search route has a test #63

Description

@royalpinto007

Both public routes ship untested:

  • app/api/newsletter/route.ts has no route.test.ts
  • app/api/search/route.ts has no route.test.ts

Other routes do have them, so the pattern to follow already exists in the repo (app/api/posts/route.test.ts, app/api/teams/waitlist/route.test.ts).

Newsletter is the one that worries me. It has real branching that nothing exercises: a new subscriber, an address that already exists, an address that previously unsubscribed, and reuse of an existing unsubscribe_token. Any of those regressing is silent, and the failure mode is either a missing welcome email or a duplicate one.

This pairs with the two rate limiting issues, since those need tests anyway. Doing them together is less work than doing them separately.

Acceptance

  • app/api/newsletter/route.test.ts covers new, existing, and previously unsubscribed addresses
  • app/api/search/route.test.ts covers the short-query early return and a normal query
  • Both pass under vitest

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions