Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: [POM] Dapp subscribe network switch spec migration #29346

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

seaona
Copy link
Contributor

@seaona seaona commented Dec 19, 2024

Description

This PR migrates the test/e2e/tests/request-queuing/dapp1-subscribe-network-switch.spec.js spec to use page object model and typescript. It also updates the assertions to test what it's intended.

  1. We go to the test dapp and connect
  2. We subscribe to the newHeads event
await window.ethereum.request({
 "method": "eth_subscribe",
 "params": [
  "newHeads"
],
});
  1. We add an event listener for subscribe messages, and we'll store this into a window variable, so we can access it later
window.ethereum.on('message', (message) => {
  if (message.type === 'eth_subscription' && message.data.subscription === '0x4bc2639eb3ac769db7a90f60a47b33c4') {
    console.log('New block header:', message.data.result);
  }
})
  1. We switch networks from MM wide screen
  2. We go back to the dapp
  3. We mine a block deterministically --> In ganache we have setup auto-mining by default, however this happens every some seconds, by performing a mine ourselves, we know for sure that this happened at least once at the point we want
  4. We wait a couple of seconds to see if more event logs appear
  5. We assert that we got more events, after switching networks

Open in GitHub Codespaces

Related issues

Fixes: #29348

Manual testing steps

  1. Check ci continues to pass
  2. Run spec manually `yarn test:e2e:single test/e2e/tests/request-queuing/dapp1-subscribe-network-switch.spec.ts --browser=chrome --leave-running=true

Screenshots/Recordings

Messages when we console log them in the spec

Screenshot from 2024-12-19 12-04-23

This is the flow that happens in the spec, done manually.

subscribe-flow-spec.mp4

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.

@seaona seaona self-assigned this Dec 19, 2024
Copy link
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.

@seaona seaona added e2e-test End to end test for the MetaMask extension area-qa Relating to QA work (Quality Assurance) labels Dec 19, 2024
@seaona seaona changed the title spec migration test: [POM] Dapp subscribe network switch spec migration Dec 19, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [5ae20ff]
Page Load Metrics (1677 ± 53 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14931856167611555
domContentLoaded14711851164811153
load14971861167711053
domInteractive2397412211
backgroundConnect977352210
firstReactRender1575402412
getState46011126
initialActions01000
loadScripts1072137612179144
setupStore6511095
uiStartup16792149190912761
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [38f16f7]
Page Load Metrics (1736 ± 96 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint23922321668389187
domContentLoaded14492154170419694
load14622234173620196
domInteractive247636157
backgroundConnect9113322613
firstReactRender1696473014
getState580262713
initialActions01000
loadScripts10251718127817885
setupStore688192311
uiStartup166129532098301145
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Contributor

@chloeYue chloeYue left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for clarifying the scenario!

@seaona seaona added this pull request to the merge queue Dec 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 20, 2024
@seaona seaona added this pull request to the merge queue Dec 20, 2024
Merged via the queue into main with commit 367769b Dec 20, 2024
80 checks passed
@seaona seaona deleted the pom-dapp-subscribe branch December 20, 2024 09:55
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2024
@metamaskbot metamaskbot added the release-12.11.0 Issue or pull request that will be included in release 12.11.0 label Dec 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-qa Relating to QA work (Quality Assurance) e2e-test End to end test for the MetaMask extension release-12.11.0 Issue or pull request that will be included in release 12.11.0 team-extension-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[POM] Migrate Dapp subscribe network switch spec
4 participants