Repository navigation
test: fix flaky test waitForBrowserAlert when alert is already open - #47538
LeVinhGithub wants to merge 8 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [266550f] [reused from 0df0258]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 2 warn · 🔴 2 fail)
Bundle Size Diffs
|
|
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. |
Builds ready [3597709] [reused from 0df0258]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 2 warn · 🔴 2 fail)
Bundle Size Diffs
|
Builds ready [79cec7f]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 4 warn · 🔴 2 fail)
Bundle Size Diffs
|
Builds ready [cbb1d30] [reused from ded204d]
⚡ Performance Benchmarks (Total: 🟢 5 pass · 🟡 5 warn · 🔴 3 fail)
Bundle Size Diffs
|
Builds ready [0074b47] [reused from e231b08]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 3 warn · 🔴 3 fail)
Bundle Size Diffs
|
Builds ready [87afc74] [reused from feb5d41]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 0 warn · 🔴 4 fail)
Bundle Size Diffs
|
Builds ready [49f4a1d]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 4 warn · 🔴 3 fail)
Bundle Size Diffs
|
|
Builds ready [4e22ca4] [reused from 2338170]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 5 warn · 🔴 2 fail)
Bundle Size Diffs
|



Description
The bip-44 snap test sometimes fails on Firefox when an error alert is already open on the Test Snaps window.
Flake type: Race Conditions on Driver/Helpers Functions
Root cause:
Entropy source with ID "invalid" not found.Solution:
CI job: https://github.com/MetaMask/metamask-extension/actions/runs/41403846072/job/125143429438
Slack: https://consensys.slack.com/archives/CTQAGKY5V/p1793625768240179?thread_ts=1793607378.989589&cid=CTQAGKY5V
Changelog
CHANGELOG entry: null
Manual testing steps
yarn start:test:mv2.can pop up bip-44 snap and get private key resultpasses, including the invalid entropy alertEntropy source with ID "invalid" not found.Screenshots/Recordings
Before
CI failure screenshot (
test-failure-screenshot-1.png, Window 1 — MetaMask full-screen home page): ShowsAccount 1(0x5CfE7...6a7e1) with25 ETHonLocalhost 8545. Window 2 (Test Snapsdapp page) has no screenshot becauseDriver.verboseReportOnFailurecalledawait this.driver.getTitle()on Window 2 while the browser alert (Entropy source with ID "invalid" not found.) was actively open, throwingUnexpectedAlertOpenError: Unexpected alert dialog detected. Performed handler "ignore".After
No product UI change. When
waitForBrowserAlertcallsgetTitle()while the expected browser alert is already open on the focused window, it verifies the alert text directly instead of failing withUnexpectedAlertOpenError.Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Changes are limited to E2E WebDriver helper behavior; no production extension code is affected.
Overview
Fixes flaky bip-44 (and related snap) E2E runs on Firefox when a browser alert is already open before
waitForBrowserAlertruns.waitForBrowserAlertnow treatsUnexpectedAlertOpenErrorfrom an initialgetTitle()the same as when window switching hits an open alert: a sharedverifyUnexpectedAlertErrorhelper validates the alert message (Firefox via direct alert access, other browsers via error text parsing) and completes the wait instead of failing early.The duplicate inline handling in the cross-window wait loop is replaced with that helper. On Firefox, a text mismatch from the direct alert read is re-thrown rather than logged and treated as success when the alert cannot be read another way.
Reviewed by Cursor Bugbot for commit 4e22ca4. Bugbot is set up for automated code reviews on this repo. Configure here.