Skip to content

fix: MMQA-1546 address PR review comments for perps e2e POM files#40661

Merged
racitores merged 12 commits intomainfrom
raci/fix-perps-comments
Mar 17, 2026
Merged

fix: MMQA-1546 address PR review comments for perps e2e POM files#40661
racitores merged 12 commits intomainfrom
raci/fix-perps-comments

Conversation

@racitores
Copy link
Copy Markdown
Contributor

@racitores racitores commented Mar 6, 2026

  • Replace hardcoded inline CSS selectors with named class properties using testId objects where possible
  • Extract shared position-related selectors and methods into PerpsPositionsBase to reduce duplication between PerpsTabPage and PerpsHomePage
  • Remove unused methods: waitForSubmitButtonEnabled, waitForOrderFormClosed (not used, untestable until consumed)
  • Remove flaky getPositionCardsCount pattern from both PerpsHomePage and PerpsTabPage
  • Extract inline selector literals (tutorial buttons, recent activity, balance actions, modify/close buttons) to named class properties
  • Order selectors and methods alphabetically in all POM files
  • Add JSDoc explaining window.location.hash SPA navigation approach
  • Convert searchInput from raw CSS to testId object format

Description

Open in GitHub Codespaces

Changelog

CHANGELOG entry:

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
Low risk: changes are confined to E2E test page objects and websocket mock utilities, but navigation/click behavior was adjusted to reduce flakiness and could affect existing perps specs.

Overview
Refactors Perps E2E page objects to remove hash-based SPA navigation and centralize shared position helpers in a new PerpsPositionsBase, with PerpsTabPage/PerpsHomePage now navigating via tab clicks and using waitForMultipleSelectors/waitUntil for more robust waits.

Updates market list/detail flows to navigate by clicking UI rows (including toast dismissal and safer mouse-move clicks), adds/renames small helper actions (e.g. generic percent preset click, submit waits for disappearance), and adjusts perps specs to follow the new navigation sequence.

Unifies WebSocket mock typing via a new shared test/e2e/websocket/types.ts (supporting function responses) and updates Solana/Perps/AccountActivity mock senders accordingly; also adds a new skipped web-socket-connection.spec.ts for future PerpsController integration.

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

@racitores racitores requested a review from a team as a code owner March 6, 2026 07:55
@metamaskbot metamaskbot added the team-qa QA team label Mar 6, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 6, 2026

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/perps (10 files, +412 -346)
  • 📁 test/
    • 📁 e2e/
      • 📁 page-objects/
        • 📁 pages/
          • 📁 perps/
            • 📄 perps-home-page.ts +96 -129
            • 📄 perps-market-detail-page.ts +79 -104
            • 📄 perps-market-list-page.ts +61 -33
            • 📄 perps-positions-base.ts +39 -0
            • 📄 perps-tab-page.ts +11 -49
      • 📁 tests/
        • 📁 perps/
          • 📁 mocks/
            • 📄 websocketDefaultMocks.ts +1 -14
            • 📄 helpers.ts +2 -14
            • 📄 perps-fixture-config.ts +1 -1
            • 📄 perps-home.spec.ts +7 -2
            • 📄 web-socket-connection.spec.ts +115 -0

🧪 @MetaMask/qa (5 files, +286 -315)
  • 📁 test/
    • 📁 e2e/
      • 📁 page-objects/
        • 📁 pages/
          • 📁 perps/
            • 📄 perps-home-page.ts +96 -129
            • 📄 perps-market-detail-page.ts +79 -104
            • 📄 perps-market-list-page.ts +61 -33
            • 📄 perps-positions-base.ts +39 -0
            • 📄 perps-tab-page.ts +11 -49

@github-actions github-actions bot added the size-M label Mar 6, 2026
@racitores racitores added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Mar 6, 2026
@racitores racitores changed the title fix: address PR review comments for perps e2e POM files fix: MMQA-2546 address PR review comments for perps e2e POM files Mar 6, 2026
@racitores racitores changed the title fix: MMQA-2546 address PR review comments for perps e2e POM files fix: MMQA-1546 address PR review comments for perps e2e POM files Mar 6, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 6, 2026

Builds ready [39cd291]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account30027334628317346
total30027334628317346
Confirm Txconfirm_tx6101607461171661126117
total6101607461171661126117
Bridge User Actionsbridge_load_page24021426718248267
bridge_load_asset_picker18015220519195205
bridge_search_token72471073912737739
total1144112011762111561176
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14961249178311415621722
load1255105715429813041428
domContentLoaded1248103015389812991418
domInteractive3218140242691
firstPaint183731388183222388
backgroundConnect23220227815241256
firstReactRender21134462236
initialActions106124
loadScripts103483013349710791210
setupStore1465161525
numNetworkReqs312297202282
Power User HomeuiStartup19841632274016620592232
load11591047168313711541546
domContentLoaded11391031163312711411495
domInteractive3420116193383
firstPaint1767442478239337
backgroundConnect30226239431312370
firstReactRender23164772438
initialActions104113
loadScripts92581313881239191290
setupStore1683551827
numNetworkReqs67331704355167
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2192172201220220
srpButtonToSrpForm9591100395100
confirmSrpToPwForm22212202222
pwFormToMetricsScreen15151601516
metricsToWalletReadyScreen17161701717
doneButtonToHomeScreen64459574356669743
openAccountMenuToAccountListLoaded290528992908329072908
total3964387241068840164106
Onboarding New WalletcreateWalletToSocialScreen2192192190219219
srpButtonToPwForm11310312910120129
createPwToRecoveryScreen888088
skipBackupToMetricsScreen35343613636
agreeButtonToOnboardingSuccess16151611616
doneButtonToAssetList54250061542562615
total9348951015469551015
Asset DetailsassetClickToPriceChart12210413814132138
total12210413814132138
Solana Asset DetailsassetClickToPriceChart78777917979
total78777917979
Import Srp HomeloginToHomeScreen1979191020656020032065
openAccountMenuAfterLogin524174135674
homeAfterImportWithNewWallet25422365266912326372669
total46404318498822647434988
Send TransactionsopenSendPageFromHome23123472734
selectTokenToSendFormLoaded20172422024
reviewTransactionToConfirmationPage8468448481847848
total88988090410889904
SwapopenSwapPageFromHome58486886568
fetchAndDisplaySwapQuotes269126882693226922693
total275327452757527572757
🌐 Dapp Page Load Benchmarks

Current Commit: 39cd291 | Date: 3/6/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±48ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 730ms (±61ms) 🟢 | historical mean value: 734ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 92ms (±128ms) 🟢 | historical mean value: 83ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 48ms 1.01s 1.44s 1.07s 1.44s
domContentLoaded 730ms 61ms 705ms 1.29s 750ms 1.29s
firstPaint 92ms 128ms 64ms 1.36s 92ms 1.36s
firstContentfulPaint 92ms 128ms 64ms 1.36s 92ms 1.36s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 5 Bytes (0%)
  • common: 20 Bytes (0%)

@racitores racitores enabled auto-merge March 6, 2026 08:29
@racitores racitores mentioned this pull request Mar 6, 2026
7 tasks
- Replace hardcoded inline CSS selectors with named class properties
  using testId objects where possible
- Extract shared position-related selectors and methods into
  PerpsPositionsBase to reduce duplication between PerpsTabPage
  and PerpsHomePage
- Remove unused methods: waitForSubmitButtonEnabled,
  waitForOrderFormClosed (not used, untestable until consumed)
- Remove flaky getPositionCardsCount pattern from both
  PerpsHomePage and PerpsTabPage
- Extract inline selector literals (tutorial buttons, recent activity,
  balance actions, modify/close buttons) to named class properties
- Order selectors and methods alphabetically in all POM files
- Add JSDoc explaining window.location.hash SPA navigation approach
- Convert searchInput from raw CSS to testId object format

Co-authored-by: Ramon AC <racitores@users.noreply.github.com>
@racitores racitores force-pushed the raci/fix-perps-comments branch from 39cd291 to c3e94f6 Compare March 6, 2026 13:25
@racitores racitores requested a review from a team as a code owner March 6, 2026 13:25
@github-actions github-actions bot added size-L and removed size-M labels Mar 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 6, 2026

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

metamaskbotv2 bot commented Mar 6, 2026

Builds ready [b90d329]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account29826234635335346
total29826234635335346
Confirm Txconfirm_tx6020596060924760456092
total6020596060924760456092
Bridge User Actionsbridge_load_page24822827516256275
bridge_load_asset_picker20811128772278287
bridge_search_token74070579834748798
total1196109112788312641278
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14361174193411614901632
load1202100114359612621375
domContentLoaded119598214299512491367
domInteractive2918102182683
firstPaint1487139470207248
backgroundConnect21219426314213250
firstReactRender2112159152232
initialActions106123
loadScripts99978912369410521172
setupStore1576481725
numNetworkReqs312294192282
Power User HomeuiStartup2222165311123121621332519
load11831043186517611771660
domContentLoaded11681037184117211591655
domInteractive38191712837104
firstPaint183701518164228323
backgroundConnect47426185511067322465
firstReactRender25164972639
initialActions106113
loadScripts95282715961629451392
setupStore1784881938
numNetworkReqs74362224971170
🧭 User Journey Benchmarks

⚠️ Missing data: chrome/browserify/userJourneyTransactions

BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2192182201220220
srpButtonToSrpForm9896101299101
confirmSrpToPwForm23232302323
pwFormToMetricsScreen16161701717
metricsToWalletReadyScreen18171801818
doneButtonToHomeScreen63061067627623676
openAccountMenuToAccountListLoaded2939291129591929532959
total3947389740003639514000
Onboarding New WalletcreateWalletToSocialScreen2182172191218219
srpButtonToPwForm1051011083107108
createPwToRecoveryScreen888088
skipBackupToMetricsScreen36343813638
agreeButtonToOnboardingSuccess17161811718
doneButtonToAssetList52147158640542586
total90986096334923963
Asset DetailsassetClickToPriceChart12811213912139139
total12811213912139139
Solana Asset DetailsassetClickToPriceChart79778127981
total79778127981
Import Srp HomeloginToHomeScreen1992192320444420052044
openAccountMenuAfterLogin47454814848
homeAfterImportWithNewWallet2505244325995725412599
total4587444547229446394722
🌐 Dapp Page Load Benchmarks

Current Commit: b90d329 | Date: 3/6/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±40ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 739ms (±38ms) 🟢 | historical mean value: 741ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 81ms (±12ms) 🟢 | historical mean value: 83ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 40ms 1.02s 1.35s 1.08s 1.35s
domContentLoaded 739ms 38ms 717ms 1.02s 768ms 1.02s
firstPaint 81ms 12ms 60ms 180ms 88ms 180ms
firstContentfulPaint 81ms 12ms 60ms 180ms 88ms 180ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 5 Bytes (0%)
  • common: 20 Bytes (0%)

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 6, 2026

Builds ready [a16bd81]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account29327332720297327
total29327332720297327
Confirm Txconfirm_tx6091606461111861036111
total6091606461111861036111
Bridge User Actionsbridge_load_page26723031227276312
bridge_load_asset_picker20611633776232337
bridge_search_token73270978429742784
total1205111713449412921344
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup13921161194012914471604
load1172964162211412351360
domContentLoaded1165956161611312281349
domInteractive2816115192575
firstPaint2346614512682131158
backgroundConnect20818733718212237
firstReactRender18113951928
initialActions109114
loadScripts975771142211110321164
setupStore1272341320
numNetworkReqs312297212291
Power User HomeuiStartup2845169912692222824019542
load12251066176514812571562
domContentLoaded12031054175613812351484
domInteractive3620161213676
firstPaint223811474215263377
backgroundConnect7902651006015113834473
firstReactRender27176792944
initialActions105114
loadScripts983853154613510121267
setupStore18664102035
numNetworkReqs84362254694198
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2242192315226231
srpButtonToSrpForm1001001000100100
confirmSrpToPwForm24232512525
pwFormToMetricsScreen17161911819
metricsToWalletReadyScreen18171911919
doneButtonToHomeScreen63761967422633674
openAccountMenuToAccountListLoaded2941293129581029492958
total3958394139831739633983
Onboarding New WalletcreateWalletToSocialScreen2162152171217217
srpButtonToPwForm1071031092109109
createPwToRecoveryScreen888088
skipBackupToMetricsScreen36353713637
agreeButtonToOnboardingSuccess16161701617
doneButtonToAssetList5975906067606606
total9809759844984984
Asset DetailsassetClickToPriceChart1063215047142150
total1063215047142150
Solana Asset DetailsassetClickToPriceChart83769788197
total83769788197
Import Srp HomeloginToHomeScreen20691825234218522152342
openAccountMenuAfterLogin473468125468
homeAfterImportWithNewWallet2374233024384023682438
total44164188463716644874637
Send TransactionsopenSendPageFromHome23173052530
selectTokenToSendFormLoaded21182742127
reviewTransactionToConfirmationPage8508468574850857
total90088193522902935
SwapopenSwapPageFromHome28193673236
fetchAndDisplaySwapQuotes268926882690126902690
total271527092724627202724
🌐 Dapp Page Load Benchmarks

Current Commit: a16bd81 | Date: 3/6/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±40ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 732ms (±37ms) 🟢 | historical mean value: 741ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 80ms (±10ms) 🟢 | historical mean value: 83ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 40ms 1.02s 1.34s 1.06s 1.34s
domContentLoaded 732ms 37ms 710ms 1.02s 748ms 1.02s
firstPaint 80ms 10ms 64ms 164ms 88ms 164ms
firstContentfulPaint 80ms 10ms 64ms 164ms 88ms 164ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 5 Bytes (0%)
  • common: 20 Bytes (0%)

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 10, 2026

Builds ready [3a2dbbe]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2622592673263267
total2622592673263267
Confirm Txconfirm_tx6099602062247661346224
total6099602062247661346224
Bridge User Actionsbridge_load_page23621826419243264
bridge_load_asset_picker15613817617170176
bridge_search_token70969473618725736
total1104107611402611301140
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14401200174810714741664
load1190100814309112181372
domContentLoaded1181100314178912131364
domInteractive291793192683
firstPaint183681435204213360
backgroundConnect21519737421219245
firstReactRender21135372137
initialActions2010225
loadScripts98480512178810131170
setupStore1474461724
numNetworkReqs362792182785
Power User HomeuiStartup34221904143582892279712613
load12451049200815512741569
domContentLoaded12221041196614712441540
domInteractive41202563636119
firstPaint214841986222256379
backgroundConnect11772741090323105297075
firstReactRender26185172938
initialActions107113
loadScripts1002825169313610271294
setupStore1674071833
numNetworkReqs1175528946126233
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2202182211221221
srpButtonToSrpForm93929419394
confirmSrpToPwForm21212202222
pwFormToMetricsScreen15151601516
metricsToWalletReadyScreen16161601616
doneButtonToHomeScreen62258864826647648
openAccountMenuToAccountListLoaded2924290729451729382945
total3903383439584739523958
Onboarding New WalletcreateWalletToSocialScreen2222202241222224
srpButtonToPwForm1091071122111112
createPwToRecoveryScreen889089
skipBackupToMetricsScreen36353713737
agreeButtonToOnboardingSuccess16161601616
doneButtonToAssetList59950476194645761
total99089311469210381146
Asset DetailsassetClickToPriceChart12410514114136141
total12410514114136141
Solana Asset DetailsassetClickToPriceChart75737827678
total75737827678
Import Srp HomeloginToHomeScreen2007187121249520912124
openAccountMenuAfterLogin563389216889
homeAfterImportWithNewWallet24602362267211624902672
total4446432345418645104541
Send TransactionsopenSendPageFromHome20162741927
selectTokenToSendFormLoaded321848134548
reviewTransactionToConfirmationPage85584487713854877
total90489191913913919
SwapopenSwapPageFromHome723613341110133
fetchAndDisplaySwapQuotes267926752682326802682
total2751271428104227922810
🌐 Dapp Page Load Benchmarks

Current Commit: 3a2dbbe | Date: 3/10/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±42ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 730ms (±38ms) 🟢 | historical mean value: 729ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 80ms (±12ms) 🟢 | historical mean value: 82ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 42ms 1.02s 1.34s 1.07s 1.34s
domContentLoaded 730ms 38ms 708ms 1.01s 760ms 1.01s
firstPaint 80ms 12ms 64ms 180ms 96ms 180ms
firstContentfulPaint 80ms 12ms 64ms 180ms 96ms 180ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -197 Bytes (0%)
  • ui: 154.02 KiB (1.84%)
  • common: 5.74 KiB (0.05%)

Copy link
Copy Markdown
Member

@seaona seaona left a comment

Choose a reason for hiding this comment

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

Added a couple of comments

Comment on lines +79 to +82
await this.driver.waitForSelector(this.addFundsButton);
const addFundsElement = await this.driver.findElement(this.addFundsButton);
await this.driver.scrollToElement(addFundsElement);
await this.driver.clickElement(this.addFundsButton);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could avoid all these code, and just clickEment, that should handle any logic needed

Suggested change
await this.driver.waitForSelector(this.addFundsButton);
const addFundsElement = await this.driver.findElement(this.addFundsButton);
await this.driver.scrollToElement(addFundsElement);
await this.driver.clickElement(this.addFundsButton);
await this.driver.clickElement(this.addFundsButton);

*/
async clickLearnBasics(): Promise<void> {
await this.driver.clickElement({ testId: 'perps-learn-basics' });
async waitForBalanceSection(timeout?: number): Promise<void> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are we passing an optional timeout here? Is this needed? I don't see it used anywhere 🤔


/** Base route for Perps market detail. Append encoded symbol, e.g. PERPS_MARKET_DETAIL_ROUTE + '/AVAX' */
export const PERPS_MARKET_DETAIL_ROUTE = '#/perps/market';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could we move the perps-fixture-config.ts file out from the generic fixtures folder?
That folder is used for the general setup of the fixtures, not for a specific test setup.
The file perps-fixture-config.ts just has a specific fixture config which could go either in helpers or directly in the e2e file

...getConfig(this.test?.fullTitle()),
},
async ({ driver }: { driver: Driver }) => {
await loginWithoutBalanceValidation(driver);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could we use loginWithBalanceValidation? that is the preferred method to avoid race conditions

async waitForPositionsSection(): Promise<void> {
await this.driver.waitForSelector(this.perpsPositionsSection);
async checkPageIsLoaded(): Promise<void> {
await this.driver.waitForSelector(this.perpsTabView);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

for checking the page is loaded, could we wait for multiple selectors to make it more robust? (it's a general convention)
Example:

await this.driver.waitForMultipleSelectors([
    this.accountMenuButton,
    this.threeDotMenuButton,
]);

async clickShort(): Promise<void> {
await this.driver.clickElement(this.shortCtaButton);
async clickPercentPreset25(): Promise<void> {
await this.driver.clickElement(this.percentPreset25);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

instead of having a specific method like this, could we pass a percentage in the param, so then we could re-use this for other percentages?

Image

async clickPercentPreset25(): Promise<void> {
await this.driver.clickElement(this.percentPreset25);
async clickSubmitOrder(): Promise<void> {
await this.driver.clickElement(this.submitOrderButton);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

here we possibly want this as well (if it takes long, then we can pass a custom timeout here ie

Suggested change
await this.driver.clickElement(this.submitOrderButton);
await this.driver.clickElementAndWaitToDisappear(this.submitOrderButton, 10000);

timeout,
});
async waitForPageLoaded(): Promise<void> {
await this.driver.waitForSelector(this.marketDetailPage);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

for following the conventions could we rename this to checkPageIsLoaded and also use multiple selectors to ensure the page is fully loaded? `waitForMultipleSelectorsà

* Waits for the market list view to be visible.
*/
async waitForPageLoaded(): Promise<void> {
await this.driver.waitForSelector(this.marketListView);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same: for following the conventions could we rename this to checkPageIsLoaded and also use multiple selectors to ensure the page is fully loaded? `waitForMultipleSelectorsà

import { PerpsHomePage } from '../../page-objects/pages/perps/perps-home-page';
import { getConfig } from './helpers';

async function waitForWebsocketConnections(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could we rename this for clarity

waitForPerpsWebsocketConnections

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 12, 2026

Builds ready [bbec66d]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account29027232722280327
total29027232722280327
Confirm Txconfirm_tx6058601460882660726088
total6058601460882660726088
Bridge User Actionsbridge_load_page22921124412231244
bridge_load_asset_picker28326929814296298
bridge_search_token7617557665766766
total1300124613523813131352
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup15551296184712016381759
load12931059153211013761478
domContentLoaded12861055152411013691470
domInteractive2917106202589
firstPaint177711123127243300
backgroundConnect22520630213228242
firstReactRender20124662136
initialActions107124
loadScripts1077851130111011561256
setupStore1483861627
numNetworkReqs362785173379
Power User HomeuiStartup57172218170962957632213346
load12961143176213113381576
domContentLoaded12771135171112213021538
domInteractive39182113932141
firstPaint1998660796258362
backgroundConnect2383295143322796303011078
firstReactRender27185163038
initialActions107112
loadScripts1052923147011210771297
setupStore1565871724
numNetworkReqs1447726641155237
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2192172201220220
srpButtonToSrpForm96959719797
confirmSrpToPwForm23232302323
pwFormToMetricsScreen16151701617
metricsToWalletReadyScreen17161811818
doneButtonToHomeScreen64760668330668683
openAccountMenuToAccountListLoaded293129252940729402940
total3937390139873339553987
Onboarding New WalletcreateWalletToSocialScreen2182172191218219
srpButtonToPwForm1071071070107107
createPwToRecoveryScreen888088
skipBackupToMetricsScreen37363813738
agreeButtonToOnboardingSuccess16151601616
doneButtonToAssetList49947752718503527
total88486290716888907
Asset DetailsassetClickToPriceChart77441272985127
total77441272985127
Solana Asset DetailsassetClickToPriceChart1093516752165167
total1093516752165167
Import Srp HomeloginToHomeScreen2325224624226423362422
openAccountMenuAfterLogin513366125366
homeAfterImportWithNewWallet2384233524645724642464
total4734465348548648544854
Send TransactionsopenSendPageFromHome25173262832
selectTokenToSendFormLoaded412555125355
reviewTransactionToConfirmationPage1332901157426115241574
total1406979167926715881679
SwapopenSwapPageFromHome1217018042161180
fetchAndDisplaySwapQuotes270026922708727072708
total2827277728935228872893
🌐 Dapp Page Load Benchmarks

Current Commit: bbec66d | Date: 3/12/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±45ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 742ms (±41ms) 🟢 | historical mean value: 742ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 82ms (±12ms) 🟢 | historical mean value: 84ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 45ms 1.02s 1.38s 1.09s 1.38s
domContentLoaded 742ms 41ms 714ms 1.04s 765ms 1.04s
firstPaint 82ms 12ms 68ms 192ms 92ms 192ms
firstContentfulPaint 82ms 12ms 68ms 192ms 92ms 192ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 28.42 KiB (0.54%)
  • ui: 120.27 KiB (1.43%)
  • common: 79.11 KiB (0.7%)

Copy link
Copy Markdown

@cursor cursor bot left a comment

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.

@sonarqubecloud
Copy link
Copy Markdown

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 16, 2026

Builds ready [5599513]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account359266503107475503
total359266503107475503
Confirm Txconfirm_tx6039596561456160626145
total6039596561456160626145
Bridge User Actionsbridge_load_page25319031743273317
bridge_load_asset_picker25823627918276279
bridge_search_token76374179022789790
total1275123913413812891341
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup13651117192611914141558
load1126923158010311611302
domContentLoaded1119917157210311531295
domInteractive281599202382
firstPaint184591242181203276
backgroundConnect19117324113193219
firstReactRender19124961930
initialActions104123
loadScripts94674813881019801118
setupStore1274151420
numNetworkReqs393191173183
Power User HomeuiStartup63352579155352878711514970
load14131224184213414351707
domContentLoaded13891213180212114131668
domInteractive41211953138111
firstPaint244961320149318377
backgroundConnect2254322128422826309011051
firstReactRender26176162735
initialActions104123
loadScripts1142980153311311651409
setupStore18886112132
numNetworkReqs22912436458265328
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2232182336222233
srpButtonToSrpForm93929519595
confirmSrpToPwForm22222202222
pwFormToMetricsScreen16151601616
metricsToWalletReadyScreen16161601616
doneButtonToHomeScreen62158866626629666
openAccountMenuToAccountListLoaded2922289929441629352944
total3904386539342539113934
Onboarding New WalletcreateWalletToSocialScreen2192182201220220
srpButtonToPwForm1101081132113113
createPwToRecoveryScreen989099
skipBackupToMetricsScreen38374013940
agreeButtonToOnboardingSuccess17161701717
doneButtonToAssetList5205125307530530
total91287494526919945
Asset DetailsassetClickToPriceChart754598188798
total754598188798
Solana Asset DetailsassetClickToPriceChart1096417048164170
total1096417048164170
Import Srp HomeloginToHomeScreen2393232025489024432548
openAccountMenuAfterLogin52396185861
homeAfterImportWithNewWallet2276218423686623272368
total4730465648406447484840
Send TransactionsopenSendPageFromHome24242502425
selectTokenToSendFormLoaded30243953139
reviewTransactionToConfirmationPage1152728150830614711508
total1210783155630015241556
SwapopenSwapPageFromHome1058614022122140
fetchAndDisplaySwapQuotes2692268127191526982719
total2797276728412928212841
🌐 Dapp Page Load Benchmarks

Current Commit: 5599513 | Date: 3/16/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±49ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 731ms (±69ms) 🟢 | historical mean value: 737ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 93ms (±135ms) 🟢 | historical mean value: 88ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 49ms 1.01s 1.43s 1.05s 1.43s
domContentLoaded 731ms 69ms 708ms 1.36s 745ms 1.36s
firstPaint 93ms 135ms 64ms 1.43s 92ms 1.43s
firstContentfulPaint 93ms 135ms 64ms 1.43s 92ms 1.43s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 15.35 KiB (0.29%)
  • ui: 130.96 KiB (1.56%)
  • common: 10.85 KiB (0.1%)

Copy link
Copy Markdown
Member

@seaona seaona left a comment

Choose a reason for hiding this comment

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

Added a couple non-blocking comments but can be addressed in subsequent PRs

async clickSearchButton(): Promise<void> {
await this.driver.clickElement(this.perpsExploreMarketsRow);
async navigateToPerpsHome(): Promise<void> {
await this.driver.waitForSelector(this.accountOverviewPerpsTab);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is not needed, the clickElement already does this for you

await this.driver.clickElement(this.submitOrderButton);
async navigateToMarket(symbol: string): Promise<void> {
const marketRowTestId = `market-row-${symbol.replaceAll(':', '-')}`;
await this.driver.waitForSelector({ testId: marketRowTestId });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is not needed, the clickElement does this for you

*/
async navigateToMarketList(): Promise<void> {
await this.driver.waitForSelector(this.exploreMarketsRow);
await this.driver.clickElementSafe(this.toastCloseButton, 1500);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it would be interesting to know when this toast appears and when it doesn't, to have full control of the expects

@racitores racitores added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit 32bebbf Mar 17, 2026
344 of 346 checks passed
@racitores racitores deleted the raci/fix-perps-comments branch March 17, 2026 14:35
@github-actions github-actions bot locked and limited conversation to collaborators Mar 17, 2026
@metamaskbot metamaskbot added the release-13.24.0 Issue or pull request that will be included in release 13.24.0 label Mar 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-13.24.0 Issue or pull request that will be included in release 13.24.0 size-L team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants