fix: Update and fix e2e tests to handle the presence of the offscreen document under MV3#24675
fix: Update and fix e2e tests to handle the presence of the offscreen document under MV3#24675
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. |
test/e2e/accounts/common.ts
Outdated
There was a problem hiding this comment.
switchToOrOpenDapp attempts "an unusually fast switchToWindowWithTitle, just 1 second" and if that fails, then calls openDapp. The problem the switchToWindowWithTitle assumes that there will be a window other than the offscreen document present. It seems that openDapp fails if the drivers current window is the offscreen document. The change in this file ensures that, for this e2e test, the extension window is selected first and then the dapp can be opened from there.
test/e2e/helpers.js
Outdated
There was a problem hiding this comment.
This is needed for the update to test/e2e/json-rpc/switchEthereumChain.spec.js, which can be seen below
1021d45 to
584a572
Compare
| @@ -53,13 +53,8 @@ describe('Switch Ethereum Chain for two dapps', function () { | |||
| await driver.clickElement('.request-queue-toggle'); | |||
|
|
|||
There was a problem hiding this comment.
This file assumed that window handles at certain indices would always map to the dapps that are opened. The problem is that the offscreen document can actually be one of the window handles at those indices, The solution is to return the new handle with the openDapp call, and then use that handle to select the right windows for the opened dapps
| @@ -33,28 +33,25 @@ describe('Full-size View Setting @no-mmi', function () { | |||
| await unlockWallet(driver); | |||
| await toggleFullSizeViewSetting(driver); | |||
| await openDapp(driver); | |||
There was a problem hiding this comment.
This file assumed that window handles at certain indices would always map to the dapp and popup window, but again the offscreen document can be at one of these indices.
The solution, which maintains what this test was actually testing, is to update it to compare window handles before and after the user action being tested, and to make an assertion against the new window handle
| @@ -176,8 +176,7 @@ describe('Editing Confirm Transaction', function () { | |||
| }); | |||
There was a problem hiding this comment.
Instead of selecting window handles by assumed indices, which could end up switching to the offscreen window, this file switches to windows based on title
| WINDOW_TITLES, | ||
| } = require('../../helpers'); | ||
| const FixtureBuilder = require('../../fixture-builder'); | ||
|
|
There was a problem hiding this comment.
Instead of selecting window handles by assumed indices, which could end up switching to the offscreen window, this file switches to windows based on title
| @@ -509,8 +509,9 @@ class Driver { | |||
| } | |||
|
|
|||
| async openNewPage(url) { | |||
There was a problem hiding this comment.
This change is needed to support the changes in switchEthereumChain.spec.js (which can be seen above)
| return await this.driver.getAllWindowHandles(); | ||
| } | ||
|
|
||
| async waitUntilXWindowHandles(x, delayStep = 1000, timeout = this.timeout) { |
There was a problem hiding this comment.
Under MV3, there will always be 1 more window handle than previously assumed, so this is a global fix for waitUntilXWindowHandles, to accomodate the MV3 offscreen document
Builds ready [584a572]
Page Load Metrics (1365 ± 698 ms)
Bundle size diffs
|
Builds ready [f896bed]
Page Load Metrics (1357 ± 679 ms)
Bundle size diffs
|
… openDappAndSwitchChain
|
The |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #24675 +/- ##
========================================
Coverage 67.42% 67.42%
========================================
Files 1289 1289
Lines 50241 50241
Branches 13014 13014
========================================
Hits 33871 33871
Misses 16370 16370 ☔ View full report in Codecov by Sentry. |
Builds ready [4e31e06]
Page Load Metrics (650 ± 481 ms)
Bundle size diffs
|
I was unable to repro this locally, and it didn't occur again after multiple re-runs on CI (two on this branch and two on another branch I pushed up). There probably is some flakiness here, but it is hard to recreate, even on CI. I am going to merge and then we can observe if this flake happens again, as we will have this test running more frequently once merge. |
|
Missing release label release-11.16.6 on PR. Adding release label release-11.16.6 on PR and removing other release labels(release-11.18.0), as PR was cherry-picked in branch 11.16.6. |
Description
Our MV3 builds add a "Offscreen Document" to our extension. This means that when our e2e tests call
driver.getAllWindowHandles(), a new window is included in the list (the window for the offscreen document). This PR updates the e2e tests to handle this change. Comments are left on each file to explain why the change was needed.Related issues
Fixes: #21496
Manual testing steps
Any of the test files modified in this PR should pass when run locally with MV3 builds
Pre-merge author checklist
Pre-merge reviewer checklist