-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: update notification date tests to be timezone agnostic #27925
test: update notification date tests to be timezone agnostic #27925
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
@@ -16,3 +16,4 @@ process.env.PUSH_NOTIFICATIONS_SERVICE_URL = | |||
process.env.PORTFOLIO_URL = 'https://portfolio.test'; | |||
process.env.METAMASK_VERSION = 'MOCK_VERSION'; | |||
process.env.ENABLE_CONFIRMATION_REDESIGN = 'true'; | |||
process.env.TZ = 'UTC'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if this actually has an impact in tests. Can I get other devs to test with/without this environment var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will keep this in the test environment for now. It does not impact any other tests.
Leaving a comment here for future devs: This can be taken out if necessary 😄
Builds ready [f52f2a8]
Page Load Metrics (1855 ± 65 ms)
Bundle size diffs
|
…-timezone-agnostic
Builds ready [2061144]
Page Load Metrics (1982 ± 120 ms)
Bundle size diffs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM and is passing. But I'm also no longer in Hawaii GMT-10 to test this for real.
Do you know if we have any devs in that timezone?
@gambinish I do not know of other developers in a different timezone, which makes this hard to test. I did some searching and the main culprit was the This is safe to merge, and we can keep an eye out if other devs or QA face this issue when running tests locally 😄 |
…-timezone-agnostic
@@ -9,7 +9,7 @@ import { | |||
describe('formatMenuItemDate', () => { | |||
beforeAll(() => { | |||
jest.useFakeTimers(); | |||
jest.setSystemTime(new Date('2024-06-07T09:40:00Z')); | |||
jest.setSystemTime(new Date(Date.UTC(2024, 5, 7, 9, 40, 0))); // 2024-06-07T09:40:00Z |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main culprit. We were setting the system time to a TZ specific date.
We have now changed this to a UTC (timezone agnostic) date. Hopefully this resolves issues that devs may face when running this test locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for doing that. LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Builds ready [6c9990d]
Page Load Metrics (1798 ± 92 ms)
Bundle size diffs
|
…-timezone-agnostic
Builds ready [2318281]
Page Load Metrics (1986 ± 104 ms)
Bundle size diffs
|
Description
A rare edge-case where unit tests locally (when in a different timezone) failed.
This updates the tests to use UTC dates and uses the UTC timezone.
NOTE - that these tests pass in CI and need to be tested locally by devs in different timezones.
Related issues
Fixes:
Manual testing steps
N/A - this has no impact on the extension, just tests.
You can try running this unit test locally to see if it passes.
Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist