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

fix: flaky test Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx should queue send tx after switch network confirmation and transaction should target the correct network after switch is confirmed #27352

Merged
merged 15 commits into from
Sep 26, 2024

Conversation

seaona
Copy link
Contributor

@seaona seaona commented Sep 24, 2024

Description

There is a race condition with window management that makes this test fail quite often. The test performs these actions and there are different behaviors happening, depending on the build:

  1. Action: trigger a network switch -> this opens a new dialog window (we have 4)
  2. Action: trigger a send -> we are still with the network switch window open
  3. Action: we click switch network -> this closes the dialog (now we have 3 windows for a brief moment - if this is fast, like in webpack, it fails with the error Error: waitUntilXWindowHandles timed out polling window handles. Expected: 3, Actual: 4)
  4. A new dialog is open automatically -> now we have 4 windows again, but the dialog handle ids are different
  5. Sometimes this dialog is closed and then a new one is open
  6. We switch to the dialog, but often the context is invalidated as we are switching to either 1 or 4 or 5

Extra Notes:
This PR fixes the flakiness of waiting for 3 windows by adding a delay. This won't fix the root cause of the 2 new identified issues, but after re-runs has proven to stabilize the test

Screenshot from 2024-09-26 11-26-34

Open in GitHub Codespaces

Related issues

Fixes: #27387

Manual testing steps

  1. Check ci
  2. Run test locally yarn test:e2e:single test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js --browser=chrome

Screenshots/Recordings

Problem in FF and Webpack, see how popup is open and closed, and then a new popup is open with the transaction.

ff-dialog-open-close.mp4

Problem in Webpack, where tx does not open after the change networks

webpack-send-tx-not-appear.mp4

Problem Webpack, see how popup is open and closed, and then a new popup is open with the transaction.

webpack-2-txs.mp4

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.

@seaona seaona requested a review from a team as a code owner September 24, 2024 07:11
@seaona seaona self-assigned this Sep 24, 2024
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.

@seaona seaona added team-extension-platform flaky tests area-qa Relating to QA work (Quality Assurance) labels Sep 24, 2024
@@ -51,17 +49,15 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () {
await driver.findClickableElement({ text: 'Connect', tag: 'button' });
await driver.clickElement('#connectButton');

await driver.delay(regularDelayMs);

await switchToNotificationWindow(driver);
Copy link
Contributor Author

@seaona seaona Sep 24, 2024

Choose a reason for hiding this comment

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

removed deprecated method and using the correct one (no need to add the delay)

@@ -80,9 +76,6 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () {
css: 'p',
});

// Wait for the first dapp's connect confirmation to disappear
await driver.waitUntilXWindowHandles(2);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need to add this, as we handle the close window into the `clickElementAndWaitForWindowToClose

Copy link

sonarcloud bot commented Sep 26, 2024

// Wait for switch confirmation to close then tx confirmation to show.
await driver.waitUntilXWindowHandles(3);
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 point is where test breaks in webpack: if the next dialog window is opened really fast, this condition is never met


// Wait for switch confirmation to close then tx confirmation to show.
await driver.waitUntilXWindowHandles(3);
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 point is where test breaks in webpack: if the next dialog window is opened really fast, this condition is never met

@metamaskbot
Copy link
Collaborator

Builds ready [c1e9a64]
Page Load Metrics (1739 ± 85 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint32525071680368177
domContentLoaded15352353171417182
load15502406173917785
domInteractive14238505325
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Contributor

@chloeYue chloeYue left a comment

Choose a reason for hiding this comment

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

Looks good for me the fix ! Thanks !

@seaona seaona merged commit 1ee0cbd into develop Sep 26, 2024
107 checks passed
@seaona seaona deleted the flaky-dapp-rqs-windows branch September 26, 2024 17:14
@github-actions github-actions bot locked and limited conversation to collaborators Sep 26, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Sep 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-qa Relating to QA work (Quality Assurance) flaky tests release-12.6.0 Issue or pull request that will be included in release 12.6.0 team-extension-platform
Projects
Archived in project
4 participants