You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(api): pin the clock in the notification silence route test - #1650
Makes the notification silence route test deterministic. It compared a computed expiry against Date.now() taken a moment later, so on a loaded machine it saw 1799999 instead of 1800000 and failed an unrelated push gate. The test now pins the clock.
✨ Added
vi.useFakeTimers() in beforeEach of app/api/notification-silence.test.ts.
vi.setSystemTime(new Date('2026-03-01T12:00:00Z')) in beforeEach. Fixes the clock for each test.
vi.useRealTimers() in afterEach. Restores real timers after each test.
🔧 Changed
Notification silence route tests now run with a pinned clock. This removes timing dependence in expiry checks that compared a computed value with a later Date.now() call.
🐛 Fixed
Flaky expiry assertion. On a loaded machine, a later Date.now() could return a value 1 ms ahead, producing 1799999 instead of 1800000. Pinned time prevents this.
Diff: 1 file, +3/-0 in app/api/notification-silence.test.ts.
Concerns:
Verify that vi.useRealTimers() runs even when a test throws. It runs in afterEach, so it does.
Verify no other test in this file depends on real elapsed time (e.g., setTimeout waits). Fake timers stop them unless advanced.
Verify silenceStore.resetSilencesForTests() and resetSuppressionForTests() do not await real timers.
Check for the same non-deterministic Date.now() pattern in sibling notification test files.
No actionable comments were generated in the recent review.
Walkthrough
The notification-silence tests now enable fake timers and set the system time to 2026-03-01T12:00:00Z for each test. Teardown restores real timers.
Change: Other
Merge Risk: Minimal · up to b851f
This is a test-only change that makes the notification silence test deterministic. It has no production behavior impact, and no merge-blocking risk remains.
Pre-merge checks: 2
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between e384795 and b851f59.
Files selected for processing: 1
app/api/notification-silence.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
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
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.
Makes the notification silence route test deterministic. It compared a computed expiry against
Date.now()taken a moment later, so on a loaded machine it saw 1799999 instead of 1800000 and failed an unrelated push gate. The test now pins the clock.✨ Added
vi.useFakeTimers()inbeforeEachofapp/api/notification-silence.test.ts.vi.setSystemTime(new Date('2026-03-01T12:00:00Z'))inbeforeEach. Fixes the clock for each test.vi.useRealTimers()inafterEach. Restores real timers after each test.🔧 Changed
Date.now()call.🐛 Fixed
Date.now()could return a value 1 ms ahead, producing1799999instead of1800000. Pinned time prevents this.Diff: 1 file, +3/-0 in
app/api/notification-silence.test.ts.Concerns:
vi.useRealTimers()runs even when a test throws. It runs inafterEach, so it does.setTimeoutwaits). Fake timers stop them unless advanced.silenceStore.resetSilencesForTests()andresetSuppressionForTests()do not await real timers.Date.now()pattern in sibling notification test files.