Skip to content

test: fix flaky test Multichain API Connect wallet to the multichain dapp#38621

Merged
chloeYue merged 6 commits intomainfrom
fix-multichain-test
Dec 9, 2025
Merged

test: fix flaky test Multichain API Connect wallet to the multichain dapp#38621
chloeYue merged 6 commits intomainfrom
fix-multichain-test

Conversation

@chloeYue
Copy link
Copy Markdown
Contributor

@chloeYue chloeYue commented Dec 8, 2025

Description

The getSession() method in TestDappMultichain was flaky in CI, the method used a fixed driver.delay() which is unreliable because the element might appear before the JSON content is fully populated, so we have error SyntaxError: Unexpected end of JSON input. See failure log:

Screenshot 2025-12-08 at 10 51 22

The fix is to replace the fixed delay with a dynamic conditional wait that checks for valid JSON before parsing.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Check CI: test should pass and be stable

Screenshots/Recordings

Before

After

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.

Note

Replaces a fixed delay with a conditional wait that parses valid JSON before returning in getSession() to reduce flakiness.

  • Tests (e2e):
    • In test/e2e/page-objects/pages/test-dapp-multichain.ts:
      • Update getSession() to wait until #session-method-result-0 contains valid JSON before parsing, replacing driver.delay(veryLargeDelayMs).
      • Add explicit error if JSON parsing never succeeds.

Written by Cursor Bugbot for commit 434fabf. This will update automatically on new commits. Configure here.

@chloeYue chloeYue self-assigned this Dec 8, 2025
@chloeYue chloeYue requested a review from a team as a code owner December 8, 2025 10:34
@chloeYue chloeYue added e2e-test End to end test for the MetaMask extension flaky tests team-qa QA team no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed labels Dec 8, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 8, 2025

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.

@chloeYue chloeYue requested review from a team and jiexi and removed request for jiexi December 8, 2025 10:34
@metamaskbot
Copy link
Copy Markdown
Collaborator

✨ Files requiring CODEOWNER review ✨

🧪 @MetaMask/qa (1 files, +23 -2)
  • 📁 test/
    • 📁 e2e/
      • 📁 page-objects/
        • 📁 pages/
          • 📄 test-dapp-multichain.ts +23 -2

@github-actions github-actions Bot added the size-S label Dec 8, 2025
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [df9a3f5]
UI Startup Metrics (1229 ± 82 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup122999814488212771361
load101885112217210581146
domContentLoaded101284612167210511134
domInteractive21164562237
firstPaint4818211713859921081
backgroundConnect2121982459218231
firstReactRender4630130175177
getState3416138203790
initialActions104113
loadScripts807650101271846921
setupStore1172931218
numNetworkReqs86307629
BrowserifyPower User HomeuiStartup17901468225615318602056
load988835140610510601162
domContentLoaded975828139510210511155
domInteractive2415112122444
firstPaint58510212073809641169
backgroundConnect256173687133222612
firstReactRender42348374353
getState19514064970205260
initialActions103112
loadScripts786649117899853969
setupStore1383661332
numNetworkReqs68591161366108
WebpackStandard HomeuiStartup83271299055870933
load64256678653679735
domContentLoaded63756378253675732
domInteractive22164572241
firstPaint20080734134195632
backgroundConnect1265381329
firstReactRender61342374456158
getState24134783241
initialActions103112
loadScripts63456078053673730
setupStore1173151120
numNetworkReqs86336629
WebpackPower User HomeuiStartup15191225212516216601777
load765599102999860926
domContentLoaded757594101497850918
domInteractive28176083047
firstPaint323101943240296871
backgroundConnect3775748027114
firstReactRender49407755061
getState20914635848245310
initialActions101011
loadScripts754592101297848911
setupStore16105491537
numNetworkReqs67581081266102
FirefoxBrowserifyStandard HomeuiStartup13121109181612013861526
load107695014148811151258
domContentLoaded107594914148811141258
domInteractive67321833187132
firstPaint------
backgroundConnect42221192448103
firstReactRender3830138123853
getState1072741023
initialActions103022
loadScripts105193313908210891232
setupStore1053341121
numNetworkReqs86285724
BrowserifyPower User HomeuiStartup25081623328455730163200
load15781007235049220582249
domContentLoaded15781007234949220582248
domInteractive983596217477243
firstPaint------
backgroundConnect160251136204168328
firstReactRender523596115677
getState1408030245171211
initialActions515010336
loadScripts1475988218645019372126
setupStore695100913153350
numNetworkReqs68441161567112
WebpackStandard HomeuiStartup15721339201513516381930
load1266112614998413241454
domContentLoaded1266112614998413241454
domInteractive65292534182141
firstPaint------
backgroundConnect45201842550108
firstReactRender4535101104858
getState2672604415159
initialActions103122
loadScripts1241111014828112991421
setupStore175226261353
numNetworkReqs86356726
WebpackPower User HomeuiStartup28621821386358533013561
load19081128272553723752521
domContentLoaded19081127272453723742521
domInteractive1783112683151011060
firstPaint------
backgroundConnect1802812182442041039
firstReactRender5739128136184
getState1437932152178248
initialActions2028322
loadScripts18261112258851522992493
setupStore504114313327306
numNetworkReqs69451251669113
📊 Page Load Benchmark Results

Current Commit: df9a3f5 | Date: 12/8/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±77ms) 🟡 | historical mean value: 1.03s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 719ms (±94ms) 🟢 | historical mean value: 718ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 90ms (±163ms) 🟢 | historical mean value: 76ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 77ms 1000ms 1.75s 1.04s 1.75s
domContentLoaded 719ms 94ms 691ms 1.63s 732ms 1.63s
firstPaint 90ms 163ms 56ms 1.71s 84ms 1.71s
firstContentfulPaint 90ms 163ms 56ms 1.71s 84ms 1.71s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 20 Bytes (0%)

@chloeYue chloeYue changed the title test: fix flaky test test: fix flaky test Multichain API Connect wallet to the multichain dapp Dec 8, 2025
adonesky1
adonesky1 previously approved these changes Dec 8, 2025
Copy link
Copy Markdown
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

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

LGTM

DDDDDanica
DDDDDanica previously approved these changes Dec 8, 2025
@DDDDDanica
Copy link
Copy Markdown
Contributor

LGTM !

@chloeYue chloeYue enabled auto-merge December 8, 2025 15:47
pnarayanaswamy
pnarayanaswamy previously approved these changes Dec 8, 2025
@chloeYue chloeYue added this pull request to the merge queue Dec 8, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 8, 2025
@chloeYue chloeYue added this pull request to the merge queue Dec 8, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 8, 2025
@HowardBraham HowardBraham added this pull request to the merge queue Dec 8, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 8, 2025
@chloeYue chloeYue added this pull request to the merge queue Dec 9, 2025
github-merge-queue Bot pushed a commit that referenced this pull request Dec 9, 2025
…dapp (#38621)

<!--
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**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
The `getSession()` method in `TestDappMultichain` was flaky in CI, the
method used a fixed `driver.delay()` which is unreliable because the
element might appear before the JSON content is fully populated, so we
have error `SyntaxError: Unexpected end of JSON input`. See failure log:

<img width="1447" height="121" alt="Screenshot 2025-12-08 at 10 51 22"
src="https://github.com/user-attachments/assets/82fd4dc0-ff00-4db6-804c-acda0e4f8560"
/>

The fix is to replace the fixed delay with a dynamic conditional wait
that checks for valid JSON before parsing.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/38621?quickstart=1)

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: null

## **Related issues**

Fixes:

## **Manual testing steps**

Check CI: test should pass and be stable

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Replace fixed delay with a wait-and-parse loop in `getSession()` to
return parsed JSON and error if parsing never succeeds.
> 
> - **Tests (E2E)**
>   - `test/e2e/page-objects/pages/test-dapp-multichain.ts`:
> - Update `getSession()` to wait until `#session-method-result-0`
contains valid JSON, parse and return it, and throw a descriptive error
if parsing never succeeds.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
df9a3f5. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 9, 2025
@chloeYue chloeYue enabled auto-merge December 9, 2025 08:33
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [1f32cc9]
UI Startup Metrics (1266 ± 93 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1266107316289313241422
load104187113487910831158
domContentLoaded103586813437910771153
domInteractive21154862237
firstPaint4639311673799391106
backgroundConnect21819928513222237
firstReactRender43317284662
getState3517178203964
initialActions105112
loadScripts822660108473870937
setupStore1264251222
numNetworkReqs86306629
BrowserifyPower User HomeuiStartup18681590277014519242054
load106689514759811441184
domContentLoaded105788914479711381174
domInteractive251770102752
firstPaint55190146141710441173
backgroundConnect25219961697235539
firstReactRender47399684958
getState19814771574205254
initialActions103112
loadScripts847686123399931975
setupStore15105581436
numNetworkReqs70602032066102
WebpackStandard HomeuiStartup857709118371897959
load66056481161694780
domContentLoaded65555880660690774
domInteractive22164372340
firstPaint216102787153207678
backgroundConnect1264481330
firstReactRender57343884949177
getState2614110153049
initialActions105112
loadScripts65255380360685772
setupStore1073141120
numNetworkReqs86306629
WebpackPower User HomeuiStartup14501147181916315941730
load72059393393762900
domContentLoaded71458692592755892
domInteractive2615113132648
firstPaint27596922223231868
backgroundConnect60758112248553
firstReactRender48396655062
getState19314565074197276
initialActions102011
loadScripts71158392392750890
setupStore1483971336
numNetworkReqs6657102106697
FirefoxBrowserifyStandard HomeuiStartup12511081162511913271452
load102392113958410711220
domContentLoaded102291513958410711219
domInteractive53312193066116
firstPaint------
backgroundConnect3521202233790
firstReactRender37306163752
getState1065051023
initialActions102012
loadScripts100190613798110441192
setupStore1063241019
numNetworkReqs86255724
BrowserifyPower User HomeuiStartup25891597360958531103340
load1614962255754921322378
domContentLoaded1614955255754921322378
domInteractive10330109321875987
firstPaint------
backgroundConnect157211172190182429
firstReactRender573794136284
getState149631038101168237
initialActions2038423
loadScripts1531945238651520352303
setupStore5143307848250
numNetworkReqs70591201472114
WebpackStandard HomeuiStartup15501325199713716201875
load1250109714397013001365
domContentLoaded1250109714397013001365
domInteractive55281342780115
firstPaint------
backgroundConnect46221862746114
firstReactRender43349094657
getState208180321599
initialActions103122
loadScripts1224108113906712731337
setupStore147110141230
numNetworkReqs86265825
WebpackPower User HomeuiStartup27871836366857032463494
load18581163269151923422536
domContentLoaded18581162269151923422535
domInteractive218291186365951057
firstPaint------
backgroundConnect138211046195160369
firstReactRender60421351961119
getState1387836152167230
initialActions218123
loadScripts17961119262150122832490
setupStore3654327329151
numNetworkReqs71591211569118
📊 Page Load Benchmark Results

Current Commit: 1f32cc9 | Date: 12/9/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±38ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 716ms (±35ms) 🟢 | historical mean value: 734ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±11ms) 🟢 | historical mean value: 79ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 38ms 1.00s 1.32s 1.05s 1.32s
domContentLoaded 716ms 35ms 693ms 978ms 735ms 978ms
firstPaint 76ms 11ms 60ms 172ms 88ms 172ms
firstContentfulPaint 76ms 11ms 60ms 172ms 88ms 172ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 20 Bytes (0%)

@chloeYue chloeYue added this pull request to the merge queue Dec 9, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 9, 2025
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [434fabf]
UI Startup Metrics (1258 ± 76 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1258105614587613141357
load102587011636410671110
domContentLoaded101986811556310601103
domInteractive21165172139
firstPaint47280117737810041095
backgroundConnect21519626513222240
firstReactRender4331106124672
getState3316116173460
initialActions104112
loadScripts81166792360852888
setupStore1174751118
numNetworkReqs86337630
BrowserifyPower User HomeuiStartup18651626229311919492023
load107490312899311541209
domContentLoaded106489512769311451200
domInteractive25175782644
firstPaint548106129742310791192
backgroundConnect24820271199230578
firstReactRender48387155060
getState19114234831210253
initialActions104112
loadScripts853687106391926998
setupStore14103241525
numNetworkReqs69581911767103
WebpackStandard HomeuiStartup775673102650800852
load59953874546643682
domContentLoaded59453173947634678
domInteractive19144671839
firstPaint25098684175204650
backgroundConnect1153981329
firstReactRender51311593250136
getState22115282738
initialActions102112
loadScripts59153073746631676
setupStore953341016
numNetworkReqs86316629
WebpackPower User HomeuiStartup15031222217217116211807
load73960699191794917
domContentLoaded73259998390787907
domInteractive26175792650
firstPaint30099897218267750
backgroundConnect68862813643555
firstReactRender524210685367
getState19714340244217283
initialActions105112
loadScripts72859798190779904
setupStore15104471433
numNetworkReqs67571131166101
FirefoxBrowserifyStandard HomeuiStartup12961103167511613891479
load105994614088611031199
domContentLoaded105894614088611021199
domInteractive64331803184133
firstPaint------
backgroundConnect41201612545101
firstReactRender38297783959
getState1062531015
initialActions102112
loadScripts103393113908010791174
setupStore1064241019
numNetworkReqs86275724
BrowserifyPower User HomeuiStartup26131572351555430583245
load1666931233950621032271
domContentLoaded1666931233950621012271
domInteractive12330108424671988
firstPaint------
backgroundConnect147221058169174261
firstReactRender5838180186093
getState1427829852178248
initialActions217123
loadScripts1595915232048120192236
setupStore524108312540242
numNetworkReqs7037114136998
WebpackStandard HomeuiStartup15511287307920716031831
load12641109269416813011442
domContentLoaded12631109269316813011442
domInteractive57261873679139
firstPaint------
backgroundConnect46191772947123
firstReactRender41338794252
getState167195251426
initialActions103112
loadScripts12361066266916612711410
setupStore145128161240
numNetworkReqs86286725
WebpackPower User HomeuiStartup28091804403058132583581
load18721135302652623442551
domContentLoaded18711135302652623442551
domInteractive2423012553821111062
firstPaint------
backgroundConnect146191125200169369
firstReactRender5637119146092
getState1367026445163224
initialActions203122
loadScripts18001119287250922912491
setupStore554112316327254
numNetworkReqs71331381770116
📊 Page Load Benchmark Results

Current Commit: 434fabf | Date: 12/9/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±53ms) 🟡 | historical mean value: 1.06s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 728ms (±50ms) 🟢 | historical mean value: 738ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±11ms) 🟢 | historical mean value: 79ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 53ms 1.02s 1.33s 1.09s 1.33s
domContentLoaded 728ms 50ms 704ms 999ms 759ms 999ms
firstPaint 77ms 11ms 60ms 176ms 84ms 176ms
firstContentfulPaint 77ms 11ms 60ms 176ms 84ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.59 KiB (0.03%)
  • ui: -49 Bytes (0%)
  • common: 145 Bytes (0%)

@chloeYue chloeYue enabled auto-merge December 9, 2025 10:44
@chloeYue chloeYue added this pull request to the merge queue Dec 9, 2025
Merged via the queue into main with commit 48114ab Dec 9, 2025
333 of 335 checks passed
@chloeYue chloeYue deleted the fix-multichain-test branch December 9, 2025 15:42
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 9, 2025
@metamaskbot metamaskbot added the release-13.14.0 Issue or pull request that will be included in release 13.14.0 label Dec 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

e2e-test End to end test for the MetaMask extension flaky tests no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-13.14.0 Issue or pull request that will be included in release 13.14.0 size-S team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants