test(cron): cover send-alerts route end-to-end#37
Merged
NewCoder3294 merged 1 commit intoJun 9, 2026
Merged
Conversation
Add behavior tests for the send-alerts cron handler, matching the co-located mocking style of the existing sync-news and validate-cameras cron tests. Covers: auth gate, no-subscribers and no-incidents zero-send paths, severity + neighborhood recipient selection, send dedup, persisted sent/failed status records, last_sent_at updates, the 50-email per-run cap, and the response counters. Time is frozen; Supabase and the email sender are mocked at their boundaries. No production code changed.
NewCoder3294
approved these changes
Jun 9, 2026
NewCoder3294
left a comment
Owner
There was a problem hiding this comment.
Reviewed for safety/security and test impact. This is test-only, mocks external boundaries, does not change runtime code or secrets handling, and the relevant test/typecheck commands pass locally. Non-blocking: consider changing Closes #20 to Refs #20 if #20 should keep tracking remaining cron-route coverage.
Contributor
Author
|
Thanks for the review. I changed the reference from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds behavior tests for the
send-alertscron route (apps/web/app/api/cron/send-alerts/route.ts). Scoped to that one route, matching the co-located mocking style of the existingsync-newsandvalidate-camerascron tests. No production code is changed; this is a single new test file.Refs #20.
Note: the issue mentions zero cron-route tests, but the repo already has tests for
sync-newsandvalidate-cameras. This PR follows their patterns rather than introducing new shared abstractions, and focuses onsend-alerts.Behaviors protected
no_subscribersresponseno_recent_incidentsresponsesentrecord and updatelast_sent_atfailedrecord and surface the error in the responseAssertions are on real outputs (response bodies, the persisted
alert_sendsrows,alert_subscriptionsupdate patches, and actual recipient/subject selection), not just that mocks were called. Time is frozen via fake timers; Supabase and the email sender are mocked at their boundaries.Verification
Lint note
Repo-wide lint could not be run: the repository currently has no functional ESLint configuration (
next lintdrops into the interactive "configure ESLint" setup on a clean checkout). I did not change the lint configuration in this PR. Flagging it in case it is useful to address separately.