Skip to content

chore: convert setTimeouts to waitForNextUpdate cp-13.25.0#41308

Merged
Jwhiles merged 3 commits into
mainfrom
fix-flaky-tests
Mar 27, 2026
Merged

chore: convert setTimeouts to waitForNextUpdate cp-13.25.0#41308
Jwhiles merged 3 commits into
mainfrom
fix-flaky-tests

Conversation

@Jwhiles

@Jwhiles Jwhiles commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

Updates a test to use waitForNextUpdate rather than setTimeout, as setTimeout seemed to be causing some inconsistent results.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

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

Low Risk
Test-only changes that update async waiting semantics; low product risk, with minor risk of altering test reliability if the new waitFor assertions are too permissive or timing-sensitive.

Overview
Refactors useMerklRewards.test.ts to remove setTimeout/act-based async flushing and instead wait on specific state transitions via renderHook’s waitFor.

Cleans up teardown logic (dropping the extra microtask flush) and makes the geoblocked case explicitly synchronous since the query is disabled.

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

@github-actions

Copy link
Copy Markdown
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.

@metamaskbotv2

metamaskbotv2 Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/metamask-earn (1 files, +50 -67)
  • 📁 ui/
    • 📁 components/
      • 📁 app/
        • 📁 musd/
          • 📁 hooks/
            • 📄 useMerklRewards.test.ts +50 -67

@Jwhiles Jwhiles marked this pull request as ready for review March 27, 2026 14:10
nickewansmith
nickewansmith previously approved these changes Mar 27, 2026
seaona
seaona previously approved these changes Mar 27, 2026
DDDDDanica
DDDDDanica previously approved these changes Mar 27, 2026
@Jwhiles Jwhiles dismissed stale reviews from DDDDDanica, seaona, and nickewansmith via 6b12a13 March 27, 2026 14:19
@github-actions github-actions Bot added size-M and removed size-S labels Mar 27, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread ui/components/app/musd/hooks/useMerklRewards.test.ts
@metamaskbotv2

metamaskbotv2 Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
Builds ready [6b12a13]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2862812924288292
total2862812924288292
Confirm Txconfirm_tx611961106133861226133
total611961106133861226133
Bridge User Actionsbridge_load_page24619630337266303
bridge_load_asset_picker27325528612281286
bridge_search_token80574488851834888
total1299126013353613351335
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Chrome Browserify Startup Standard HomeuiStartup15031305180610415591689
load1237104514509312951409
domContentLoaded1229104014429212871393
domInteractive3118113232797
firstPaint190721278143248370
backgroundConnect21519041425219254
firstReactRender22135162335
initialActions105113
loadScripts103084312188810831192
setupStore1363661623
numNetworkReqs393185163780
Chrome Browserify Startup Power User HomeuiStartup4808213214974209857027706
load13261122192714613701649
domContentLoaded13011107188013213351545
domInteractive42212493242100
firstPaint24486613105311399
backgroundConnect171728011836186228193564
firstReactRender27186262938
initialActions1016214
loadScripts1091910162012111321332
setupStore1665081831
numNetworkReqs29213352471329394
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2202182232221223
srpButtonToSrpForm98969919899
confirmSrpToPwForm23232412424
pwFormToMetricsScreen16161701717
metricsToWalletReadyScreen17171701717
doneButtonToHomeScreen59753567956645679
openAccountMenuToAccountListLoaded293729262945829422945
total3910385939925139493992
Onboarding New WalletcreateWalletToSocialScreen2182182180218218
srpButtonToPwForm1191101287125128
createPwToRecoveryScreen888088
skipBackupToMetricsScreen40374324043
agreeButtonToOnboardingSuccess16161701717
doneButtonToAssetList5185155213521521
total9149129152915915
Asset DetailsassetClickToPriceChart926412425118124
total926412425118124
Solana Asset DetailsassetClickToPriceChart845712626101126
total845712626101126
Import Srp HomeloginToHomeScreen2337226924848723132484
openAccountMenuAfterLogin55486155861
homeAfterImportWithNewWallet1533388231990122732319
total40482756532899646125328
Send TransactionsopenSendPageFromHome30253433034
selectTokenToSendFormLoaded27213342933
reviewTransactionToConfirmationPage1159964132413712901324
total12391063142314313821423
SwapopenSwapPageFromHome1156619247147192
fetchAndDisplaySwapQuotes269226862699526942699
total2814276529205828342920
🌐 Dapp Page Load Benchmarks

Current Commit: 6b12a13 | Date: 3/27/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.02s (±38ms) 🟡 | historical mean value: 1.03s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 717ms (±35ms) 🟢 | historical mean value: 728ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 84ms (±11ms) 🟢 | historical mean value: 85ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.02s 38ms 995ms 1.31s 1.05s 1.31s
domContentLoaded 717ms 35ms 694ms 985ms 733ms 985ms
firstPaint 84ms 11ms 72ms 172ms 92ms 172ms
firstContentfulPaint 84ms 11ms 72ms 172ms 92ms 172ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 5 Bytes (0%)
  • common: 20 Bytes (0%)

@chloeYue chloeYue changed the title chore: convert setTimeouts to waitForNextUpdate chore: convert setTimeouts to waitForNextUpdate cp-13.25.0 Mar 27, 2026
@sonarqubecloud

Copy link
Copy Markdown

@metamaskbotv2

metamaskbotv2 Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
Builds ready [014f0f8]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account31629233315322333
total31629233315322333
Confirm Txconfirm_tx6065603460892360866089
total6065603460892360866089
Bridge User Actionsbridge_load_page24422925711257257
bridge_load_asset_picker21313026649256266
bridge_search_token78575383531806835
total1271113614169613291416
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Chrome Browserify Startup Standard HomeuiStartup14871230179110615361697
load1227101914638912681387
domContentLoaded1217100614578812591379
domInteractive3016124212685
firstPaint246711302240248471
backgroundConnect21118726214218234
firstReactRender21145052229
initialActions105113
loadScripts102282912578610611184
setupStore1363461624
numNetworkReqs393190153880
Chrome Browserify Startup Power User HomeuiStartup4895224213244217357719043
load13561148207414614001668
domContentLoaded13301124201114013691648
domInteractive47223064640137
firstPaint250871283149307403
backgroundConnect181830010120188828294998
firstReactRender29187583145
initialActions108114
loadScripts1114917172613211411378
setupStore1764082133
numNetworkReqs2478342571292353
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2182182190219219
srpButtonToSrpForm94939519595
confirmSrpToPwForm22212202222
pwFormToMetricsScreen16151611616
metricsToWalletReadyScreen16151711617
doneButtonToHomeScreen53752654910542549
openAccountMenuToAccountListLoaded31322927351921731823519
total40233819433919241164339
Onboarding New WalletcreateWalletToSocialScreen2202182232221223
srpButtonToPwForm1161091288124128
createPwToRecoveryScreen889089
skipBackupToMetricsScreen41404104141
agreeButtonToOnboardingSuccess16161601616
doneButtonToAssetList51548854823522548
total9099039165916916
Asset DetailsassetClickToPriceChart97881056103105
total97881056103105
Solana Asset DetailsassetClickToPriceChart917210612101106
total917210612101106
Import Srp HomeloginToHomeScreen2380231124625524252462
openAccountMenuAfterLogin53465965859
homeAfterImportWithNewWallet1130296233997323012339
total35702720482297346994822
Send TransactionsopenSendPageFromHome492277206277
selectTokenToSendFormLoaded34284043640
reviewTransactionToConfirmationPage999783121418312121214
total1083852131820113141318
SwapopenSwapPageFromHome1157916129124161
fetchAndDisplaySwapQuotes268426812688226852688
total2787276028092228082809
🌐 Dapp Page Load Benchmarks

Current Commit: 014f0f8 | Date: 3/27/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±40ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 740ms (±37ms) 🟢 | historical mean value: 726ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 87ms (±14ms) 🟢 | historical mean value: 85ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 40ms 1.02s 1.33s 1.09s 1.33s
domContentLoaded 740ms 37ms 714ms 1.00s 770ms 1.00s
firstPaint 87ms 14ms 68ms 204ms 104ms 204ms
firstContentfulPaint 87ms 14ms 68ms 204ms 104ms 204ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 99 Bytes (0%)
  • ui: 104 Bytes (0%)
  • common: 426 Bytes (0%)

@Jwhiles Jwhiles requested a review from DDDDDanica March 27, 2026 15:49
@Jwhiles Jwhiles enabled auto-merge March 27, 2026 15:53
@Jwhiles Jwhiles added this pull request to the merge queue Mar 27, 2026
Merged via the queue into main with commit 667cb0f Mar 27, 2026
96 checks passed
@Jwhiles Jwhiles deleted the fix-flaky-tests branch March 27, 2026 16:14
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2026
@metamaskbot metamaskbot added the release-13.26.0 Issue or pull request that will be included in release 13.26.0 label Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.26.0 Issue or pull request that will be included in release 13.26.0 size-M team-earn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants