[No QA] Fix flaky date preset tests in SearchUIUtilsTest#83809
Conversation
The two date preset intersection tests used LAST_MONTH preset which resolves relative to the real system clock via getDateRangeForPreset(). The hardcoded expected dates assumed LAST_MONTH = January 2026, which was only true when run in February 2026. Freeze the clock with jest.useFakeTimers/setSystemTime to make these tests deterministic. Co-authored-by: Krishna <Krishna2323@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
|
@MelvinBot move it out of draft state |
|
@Krishna2323 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
PR has been marked as ready for review. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
Krishna2323
left a comment
There was a problem hiding this comment.
LGTM! 🎉
The fix is minimal, correct, follows established repo patterns, and no other files are at risk.
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.28-0 🚀
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.30-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.30-3 🚀
|
Explanation of Change
Two tests in
SearchUIUtilsTest.ts(should intersect date preset with additional constraints instead of overwritingandshould intersect date preset end limit with additional constraints) useCONST.SEARCH.DATE_PRESETS.LAST_MONTHwhich resolves relative to the real system clock viagetDateRangeForPreset(). The expected values were hardcoded assuming "last month" = January 2026, which was only true when tests ran in February 2026. On any other month, the tests fail.This PR wraps the two flaky tests in a
describeblock withjest.useFakeTimers()/jest.setSystemTime()to freeze the clock to February 2026, makingLAST_MONTHalways resolve to January 2026. This follows the same pattern used in 10+ other test files in this repo.Fixed Issues
$ #83808
PROPOSAL: #83808 (comment)
Tests
npm test -- tests/unit/Search/SearchUIUtilsTest.ts --no-coverageOffline tests
N/A — this is a test-only change with no runtime behavior.
QA Steps
[No QA]
This is a test-only fix (no production code changes). The flaky tests now pass deterministically regardless of what month CI runs.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A — test-only change
Android: mWeb Chrome
N/A — test-only change
iOS: Native
N/A — test-only change
iOS: mWeb Safari
N/A — test-only change
MacOS: Chrome / Safari
N/A — test-only change