test: Fix flakiness caused by display of newly switched to network modal #28625
+6
−0
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.
Description
This PR fixes the flakiness seen, for example, in https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/111818/workflows/f974462c-8208-4189-8592-928b21f0cfde/jobs/4189413/tests
See this screenshot:
The test failure error is:
ElementClickInterceptedError: Element <div class="mm-box selectable-list-item-wrapper"> is not clickable at point (866,482) because another element <div class="popover-bg"> obscures it
So the test is attempting to clikc the "Import tokens" button in the opened menu behind the "You are now using Binance" modal, but the Import Tokens button cannot be clicked because the modal intercepts the click
So there is a race condition whereby the test assumes that no modal will interfere with the click, and the test will pass if the click can occur before the modal is rendered, but it will fail the the click is attempted after the modal is rendered.
Prior to the PR in question (#28575) there was no menu, and the "Import tokens" button could be clicked directly. The PR added the menu and move "Import tokens" into that menu, so now the test has to wait for that menu to open before the "Import tokens" button can be clicked, exacerbating the race condition.
That new network modal should not be shown in that scenario
this is the logic that controls whether that network modal should be shown:
(I think that is what folks are above referring to as the "Got it" modal)
Meanwhile, in fixture-builder.js we have:
So for any test that sets the network to something other than those four networks, !isNetworkUsed will evaluate to true, which will result in that modal being shown.
Related issues
Fixes:
Manual testing steps
e2e tests should
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist