-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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: Added e2e for switch network #27967
Conversation
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. |
Builds ready [f043170]
Page Load Metrics (1811 ± 101 ms)
Bundle size diffs
|
Builds ready [185abee]
Page Load Metrics (1799 ± 87 ms)
Bundle size diffs
|
Builds ready [aa5f232]
Page Load Metrics (2158 ± 456 ms)
Bundle size diffs
|
Builds ready [2caa271]
Page Load Metrics (2005 ± 117 ms)
Bundle size diffs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, the test looks good 🔥 Just added a couple of suggestions.
I would suggest some naming changes:
notification.ts
seems quite a vague name -> this component represents the Network Confirmations modal for switching networks, so I would name something likenetwork-switch-modal-confirmation
or similar, so it's easier to know what it refers to (see pic)
dialog/...
I think the folder name is again quite vague -> here both components refer to the network picker and modal, so we could have some folder name more explicit
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @seaona for the detailed and valuable feedback.
Name Change
- I agree with you that
notification.ts
is generic and a more accurate name as you suggested, will benetwork-switch-modal-confirmation
and will make the change. - Since Dialog is the component, anything related to it should come under this folder. I can't think of any other options. Could you suggest some alternatives? It would be helpful.
|
||
async clickApproveButton(): Promise<void> { | ||
console.log('Click Approve Button'); | ||
await this.driver.clickElement(this.submitButton); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid race conditions:
await this.driver.clickElement(this.submitButton); | |
await this.driver.clickElementAndWaitToDisappear( | |
this.submitButton, | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually tried using clickElementAndWaitToDisappear
but it was unable to click properly. Since this is a dialog and I used clickElement
instead. I will try again and check locally, and I will keep you updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I have updated clickElementAndWaitToDisappear
and it worked locally and pushed up the changes.
await homePage.check_expectedBalanceIsDisplayed('25'); | ||
await headerNavbar.check_currentSelectedNetwork('Localhost 8545'); | ||
|
||
// Add Aribtrum network and perform the switch network functionality |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: Aribtrum
should be Arbitrum
The test is called: Switch network - Ethereum Mainnet and Sepolia
, however here we are adding Arbitrum network and switching to it too.
I would suggest either split this into 2 different tests and add more precise test naming, or change the test naming so it represents the complete test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I will change this..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seaona, I believe this test scenario is a simple one, so I have simplified the test name and provided comments. This should be sufficient. Please let me know if anything else needs to be updated
|
||
async clickCloseButton(): Promise<void> { | ||
console.log('Click Close Button'); | ||
await this.driver.clickElement(this.closeButton); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await this.driver.clickElement(this.closeButton); | |
await this.driver.clickElementAndWaitToDisappear( | |
this.closeButton, | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated this change.
|
||
async clickAddButton(): Promise<void> { | ||
console.log('Click Add Button'); | ||
await this.driver.clickElement('[data-testid="test-add-button"]'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await this.driver.clickElement('[data-testid="test-add-button"]'); | |
await this.driver.clickElementAndWaitToDisappear( | |
'[data-testid="test-add-button"]', | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated this change.
Builds ready [70b9cd1]
Page Load Metrics (2076 ± 93 ms)
Bundle size diffs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Co-authored-by: seaona <54408225+seaona@users.noreply.github.com>
Builds ready [c08dbca]
Page Load Metrics (2183 ± 97 ms)
Bundle size diffs
|
… switch-network-e2e
Builds ready [2318c32]
Page Load Metrics (2205 ± 176 ms)
Bundle size diffs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
This is e2e PR for switch network
Related issues
Fixes:
https://github.com/MetaMask/MetaMask-planning/issues/2906
Manual testing steps
Run the test locally or in codespaces using the below command:
yarn
yarn build:test:webpack
ENABLE_MV3=false yarn test:e2e:single test/e2e/tests/network/switch-network.spec.ts --browser=chrome
Pre-merge reviewer checklist