Skip to content

Conversation

@seaona
Copy link
Member

@seaona seaona commented Sep 1, 2025

Description

As a follow-up of this PR, which separated the logic for setting up the Websocket, from the test steps, now this PR separates the logic for handling mocked wss requests from the setup websocket server.

This means that now we can pass an array of websocket mocks.

Note, that the websocket mocks are different from the regular Http mocks, they look like this:

export interface WebSocketMessageMock {
  messageIncludes: string | string[];
  response: object;
  delay?: number;
  logMessage?: string;
}

and the logic for handling the mocks is also different, as we are handling this in our local websocket server. Meaning:

  1. From Mocktt default mocks --> we check if we need a Websocket Solana server, if so, we re-route any wss to the local wss
  2. We setup the local Websocket server
  3. We add 'onMessage' listeners to intercept the requests we want to mock, and we send back the desired response

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.

@metamaskbot metamaskbot added the team-qa QA team label Sep 1, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 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.

@github-actions github-actions bot added the size-M label Sep 1, 2025
@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

🧪 @MetaMask/qa (2 files, +10 -9)
  • 📁 test/
    • 📁 e2e/
      • 📄 helpers.js +8 -7
      • 📄 mock-e2e.js +2 -2

ethConversionInUsd,
monConversionInUsd,
manifestFlags,
withSolanaWebSocket = false,
Copy link
Member Author

Choose a reason for hiding this comment

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

In the first part of the refactor, the Websocket mock logic was joint with the Websocket setup.
As a second stage of this refactor, we now separate the 2, allowing flexibility

@seaona seaona added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Sep 1, 2025
@seaona seaona self-assigned this Sep 1, 2025
localWebSocketServer = LocalWebSocketServer.getServerInstance();
localWebSocketServer.start();
// All specs use the same ws mocks.
// If we need custom ws mocks we can expand logic for supporting custom ws mocks like with http
Copy link
Member Author

Choose a reason for hiding this comment

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

logic has been updated, to be able to pass a mocks array with websocket mocks

@seaona seaona marked this pull request as ready for review September 1, 2025 09:48
@seaona seaona requested a review from a team as a code owner September 1, 2025 09:48
withSolanaWebSocket = {
server: false,
mocks: [],
},
Copy link

Choose a reason for hiding this comment

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

Bug: WebSocket Server Setup Skipped

The withSolanaWebSocket parameter's type changed from a boolean to an object. If existing calls pass true, the Solana WebSocket server setup is silently skipped because true.server is undefined. This can cause unexpected test failures.

Additional Locations (2)

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

If existing calls pass true, the Solana WebSocket server setup is silently skipped because true.server is undefined. This can caus

ℹ️ there are no existing calls as I've updated all the old references

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 74d9386 | Date: 9/1/2025

📄 https://metamask.github.io/test-dapp/

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.30s (±110ms) 🟡 | historical mean value: 1.30s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 983ms (±107ms) 🟢 | historical mean value: 984ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 93ms (±47ms) 🟢 | historical mean value: 91ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.30s 110ms 1.25s 1.94s 1.50s 1.94s
domContentLoaded 983ms 107ms 943ms 1.61s 1.18s 1.61s
firstPaint 93ms 47ms 68ms 340ms 240ms 340ms
firstContentfulPaint 93ms 47ms 68ms 340ms 240ms 340ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [d8cca1a]
UI Startup Metrics (1197 ± 62 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1197106813636212471304
load103994712105710801141
domContentLoaded103293912015710751132
domInteractive17134551726
firstPaint59268120942710411115
backgroundConnect2352222668239253
firstReactRender23164262437
getState1254961424
initialActions50697613
loadScripts80371197056845898
setupStore952131016
WebpackHomeuiStartup19951463245023621612401
load16001175200517516971850
domContentLoaded15911172199517416901831
domInteractive161184111340
firstPaint1695834758207285
backgroundConnect3016325312947
firstReactRender97353337987315
getState3343237414283
initialActions5213279
loadScripts15871169198517316861823
setupStore1262641424
FirefoxBrowserifyHomeuiStartup13671180185812014071638
load1186104314987712421315
domContentLoaded1185104314987712411315
domInteractive1102928751114258
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3019111133243
firstReactRender26225442834
getState739210615
initialActions5117518311
loadScripts1163102614837512141294
setupStore12420424843
WebpackHomeuiStartup16291425206614317191915
load13961199176212814811626
domContentLoaded13961199176212814811626
domInteractive1133133064107298
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect32216373843
firstReactRender45376154755
getState7313913611
initialActions41657311
loadScripts13721178173612914621602
setupStore95455918
Benchmark value 236 exceeds gate value 10 for chrome browserify home mean backgroundConnect
Benchmark value 24 exceeds gate value 23 for chrome browserify home mean firstReactRender
Benchmark value 5 exceeds gate value 1 for chrome browserify home mean initialActions
Benchmark value 254 exceeds gate value 18 for chrome browserify home p95 backgroundConnect
Benchmark value 13 exceeds gate value 1.2 for chrome browserify home p95 initialActions
Benchmark value 33 exceeds gate value 29 for chrome webpack home mean getState
Benchmark value 283 exceeds gate value 195 for chrome webpack home p95 getState
Benchmark value 9 exceeds gate value 7 for chrome webpack home p95 initialActions
Benchmark value 111 exceeds gate value 110 for firefox browserify home mean domInteractive
Benchmark value 30 exceeds gate value 25 for firefox browserify home mean backgroundConnect
Benchmark value 27 exceeds gate value 25 for firefox browserify home mean firstReactRender
Benchmark value 5 exceeds gate value 1 for firefox browserify home mean initialActions
Benchmark value 13 exceeds gate value 9 for firefox browserify home mean setupStore
Benchmark value 258 exceeds gate value 195 for firefox browserify home p95 domInteractive
Benchmark value 11 exceeds gate value 2 for firefox browserify home p95 initialActions
Benchmark value 43 exceeds gate value 27 for firefox browserify home p95 setupStore
Benchmark value 1630 exceeds gate value 1615 for firefox webpack home mean uiStartup
Benchmark value 1396 exceeds gate value 1380 for firefox webpack home mean load
Benchmark value 1396 exceeds gate value 1380 for firefox webpack home mean domContentLoaded
Benchmark value 113 exceeds gate value 100 for firefox webpack home mean domInteractive
Benchmark value 33 exceeds gate value 26 for firefox webpack home mean backgroundConnect
Benchmark value 45 exceeds gate value 38 for firefox webpack home mean firstReactRender
Benchmark value 4 exceeds gate value 1 for firefox webpack home mean initialActions
Benchmark value 1372 exceeds gate value 1360 for firefox webpack home mean loadScripts
Benchmark value 298 exceeds gate value 156 for firefox webpack home p95 domInteractive
Benchmark value 55 exceeds gate value 50 for firefox webpack home p95 firstReactRender
Benchmark value 11 exceeds gate value 2 for firefox webpack home p95 initialActions
Sum of mean exceeds: 340ms | Sum of p95 exceeds: 581.8ms
Sum of all benchmark exceeds: 921.8ms

Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 43 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 10 Bytes (0%)

@DDDDDanica
Copy link
Contributor

LGTM !

@seaona seaona enabled auto-merge September 1, 2025 16:41
Copy link
Contributor

@davibroc davibroc left a comment

Choose a reason for hiding this comment

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

LGTM

@seaona seaona added this pull request to the merge queue Sep 2, 2025
Merged via the queue into main with commit d6c9db2 Sep 2, 2025
145 of 146 checks passed
@seaona seaona deleted the test-wss-mocks-solana branch September 2, 2025 11:16
@github-actions github-actions bot locked and limited conversation to collaborators Sep 2, 2025
@metamaskbot metamaskbot added the release-13.4.0 Issue or pull request that will be included in release 13.4.0 label Sep 2, 2025
@gauthierpetetin gauthierpetetin changed the title test: split Solana WebSocket Mock setup logic from Websocket Mocks test: split Solana WebSocket Mock setup logic from Websocket Mocks cp-13.3.1 Sep 23, 2025
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.4.0 Issue or pull request that will be included in release 13.4.0 size-M team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants