Skip to content

Commit e0db3ef

Browse files
authored
fix: flaky test Test Snap Get Locale test snap_getLocale functionality (#25648)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR fixes the snap test for get locale. The problem is that there is a race condition where, after changing the language, we click on the account menu and to the Snaps option, while metamask is being on a loading state, making that the click take no effect as the component re-renders after the click, and the subsequent element cannot be found. An additional problem is that whenever we change locale, the loading spinner appears not only once but twice, meaning that there are 2 re-renders (see video). This seems an issue in the app level and should also be fixed there. I've opened an issue for that [here](#25651). See actions and error and also check screenshot below: ``` [driver] Called 'clickElement' with arguments [{"text":"Dansk","tag":"option"}] [driver] Called 'waitForSelector' with arguments ["[data-testid=\"account-options-menu-button\"]"] [driver] Called 'clickElement' with arguments ["[data-testid=\"account-options-menu-button\"]"] [driver] Called 'clickElement' with arguments [{"text":"Snaps","tag":"div"}] [driver] Called 'waitForSelector' with arguments [{"text":"Oversættelses Eksempel Snap"}] Failure on testcase: 'Test Snap Get Locale test snap_getLocale functionality', for more information see the artifacts tab in CI TimeoutError: Waiting for element to be located By(xpath, //*[contains(text(), "Oversættelses Eksempel Snap")]) ``` - ci error https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/90228/workflows/f19f6577-350b-42d4-a99c-93667540dec6/jobs/3343510 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25648?quickstart=1) ## **Related issues** Fixes: #25650 ## **Manual testing steps** 1. Check ci. Note: thanks to the quality gate, this test is run multiple times in ci in this branch ## **Screenshots/Recordings** ![Screenshot from 2024-07-03 10-06-51](https://github.com/MetaMask/metamask-extension/assets/54408225/4c9ebe33-1fe1-498d-84f5-b6d4f30a7be5) I've added a delay so we can see the behaviour more clearly: see how a spinner appears twice, so the app re-renders x2 times https://github.com/MetaMask/metamask-extension/assets/54408225/b30dae1a-26f0-4133-a0a0-51c3d3017228 ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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.
1 parent 6849c72 commit e0db3ef

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/e2e/snaps/test-snap-get-locale.spec.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ describe('Test Snap Get Locale', function () {
8888
);
8989

9090
// click on the global action menu
91-
await driver.waitForSelector(
92-
'[data-testid="account-options-menu-button"]',
93-
);
9491
await driver.clickElement(
9592
'[data-testid="account-options-menu-button"]',
9693
);
@@ -115,10 +112,12 @@ describe('Test Snap Get Locale', function () {
115112
// try to select dansk from the list
116113
await driver.clickElement({ text: 'Dansk', tag: 'option' });
117114

115+
// there are 2 re-renders which cause flakiness (issue #25651)
116+
// the delay can be removed once the issue is fixed in the app level
117+
await driver.delay(1000);
118+
await driver.assertElementNotPresent('.loading-overlay');
119+
118120
// click on the global action menu
119-
await driver.waitForSelector(
120-
'[data-testid="account-options-menu-button"]',
121-
);
122121
await driver.clickElement(
123122
'[data-testid="account-options-menu-button"]',
124123
);

0 commit comments

Comments
 (0)