Skip to content
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

Conversation

Prithpal-Sooriya
Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Oct 17, 2024

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.

Open in GitHub Codespaces

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

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

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.

@github-actions github-actions bot added the team-notifications Notifications team label Oct 17, 2024
@@ -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';
Copy link
Contributor Author

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?

Copy link
Contributor Author

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 😄

@metamaskbot
Copy link
Collaborator

Builds ready [f52f2a8]
Page Load Metrics (1855 ± 65 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint16782121185213063
domContentLoaded16602111182412460
load16782122185513565
domInteractive248351199
backgroundConnect984332411
firstReactRender49124862612
getState45913167
initialActions01000
loadScripts12051599133910651
setupStore115924168
uiStartup18652344205214067
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [2061144]
Page Load Metrics (1982 ± 120 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint50026511881386185
domContentLoaded16492395192820297
load165727511982249120
domInteractive26248735828
backgroundConnect9326537034
firstReactRender54162922713
getState4210404622
initialActions01000
loadScripts11721757141516378
setupStore1397292612
uiStartup184536472227381183
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Contributor

@gambinish gambinish left a 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?

@Prithpal-Sooriya Prithpal-Sooriya marked this pull request as ready for review October 22, 2024 08:35
@Prithpal-Sooriya Prithpal-Sooriya requested a review from a team as a code owner October 22, 2024 08:35
@Prithpal-Sooriya
Copy link
Contributor Author

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 jest.setSystemTime was not taking a timezone agnostic date. Now that we are constructing and testing with UTC dates, I'm hoping this issue will be resolved.

This is safe to merge, and we can keep an eye out if other devs or QA face this issue when running tests locally 😄

@@ -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
Copy link
Contributor Author

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.

Copy link
Contributor

@mathieuartu mathieuartu left a 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!

Copy link
Contributor

@matteoscurati matteoscurati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@metamaskbot
Copy link
Collaborator

Builds ready [6c9990d]
Page Load Metrics (1798 ± 92 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15192484179118187
domContentLoaded15112189174713264
load15192521179819292
domInteractive137436178
backgroundConnect9298516230
firstReactRender47198883718
getState499202412
initialActions01000
loadScripts10841580127910249
setupStore1188342512
uiStartup171030102010254122
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Oct 22, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [2318281]
Page Load Metrics (1986 ± 104 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint27522851827535257
domContentLoaded15862274196120699
load159922891986216104
domInteractive169942209
backgroundConnect96926209
firstReactRender47209973014
getState487232311
initialActions01000
loadScripts11491727143817885
setupStore1695452412
uiStartup178527322217249119
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Merged via the queue into develop with commit 528f2f5 Oct 22, 2024
76 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the test/update-notification-date-tests-to-be-timezone-agnostic branch October 22, 2024 14:03
@github-actions github-actions bot locked and limited conversation to collaborators Oct 22, 2024
@metamaskbot metamaskbot added the release-12.7.0 Issue or pull request that will be included in release 12.7.0 label Oct 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.7.0 Issue or pull request that will be included in release 12.7.0 team-notifications Notifications team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants