-
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
feat: added test network as selected network if globally selected for connection Request #27980
base: develop
Are you sure you want to change the base?
Changes from all commits
e9878b4
c4dac99
8ffa4d6
c9686c8
5b6ca71
019d03d
9aa9634
1f27dc0
49390c6
7b09dec
b1c1d3c
b8b0724
0355cf1
aec3385
028c1dd
e9d817f
a18a31d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,7 +158,52 @@ describe('Switch Ethereum Chain for two dapps', function () { | |
}); | ||
|
||
await driver.switchToWindowWithUrl(DAPP_ONE_URL); | ||
// Switch to Dapp One and connect it | ||
await driver.switchToWindowWithUrl(DAPP_URL); | ||
await driver.clickElement({ text: 'Connect', tag: 'button' }); | ||
|
||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Connect', | ||
tag: 'button', | ||
}); | ||
|
||
// Switch to MM and disconnect localhost 8545 for Dapp One | ||
|
||
await driver.switchToWindowWithTitle( | ||
WINDOW_TITLES.ExtensionInFullScreenView, | ||
); | ||
await driver.clickElement( | ||
'[data-testid ="account-options-menu-button"]', | ||
); | ||
await driver.clickElement({ | ||
text: 'All Permissions', | ||
tag: 'div', | ||
}); | ||
await driver.clickElementAndWaitToDisappear({ | ||
text: 'Got it', | ||
tag: 'button', | ||
}); | ||
await driver.clickElement({ | ||
text: '127.0.0.1:8080', | ||
tag: 'p', | ||
}); | ||
const editButtons = await driver.findElements('[data-testid="edit"]'); | ||
|
||
assert.ok(editButtons.length > 0, 'Edit buttons are available'); | ||
|
||
await editButtons[1].click(); | ||
|
||
// Disconnect Mainnet | ||
await driver.clickElement({ | ||
text: 'Localhost 8546', | ||
tag: 'p', | ||
}); | ||
|
||
await driver.clickElement('[data-testid="connect-more-chains-button"]'); | ||
// Switch to Dapp Two | ||
await driver.switchToWindowWithUrl(DAPP_ONE_URL); | ||
Comment on lines
+161
to
+206
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thoughts on the connection happening right after line 147? You also had a nice pattern in the other test of deselecting a network during the connection flow which would be great to use here instead of opening the wallet and disconnecting the chain after connecting it |
||
// Initiate send transaction on Dapp two | ||
await driver.clickElement('#sendButton'); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
@@ -174,15 +219,13 @@ describe('Switch Ethereum Chain for two dapps', function () { | |
const switchEthereumChainRequest = JSON.stringify({ | ||
jsonrpc: '2.0', | ||
method: 'wallet_switchEthereumChain', | ||
params: [{ chainId: '0x539' }], | ||
params: [{ chainId: '0x53a' }], | ||
}); | ||
|
||
// Initiate switchEthereumChain on Dapp One | ||
await driver.executeScript( | ||
`window.ethereum.request(${switchEthereumChainRequest})`, | ||
); | ||
|
||
// Switch to tx and confirm send tx. | ||
await switchToNotificationWindow(driver, 4); | ||
await driver.findClickableElements({ | ||
text: 'Confirm', | ||
|
@@ -192,7 +235,6 @@ describe('Switch Ethereum Chain for two dapps', function () { | |
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
|
||
// Delay here after notification for second notification popup for switchEthereumChain | ||
await driver.delay(1000); | ||
|
||
|
@@ -203,7 +245,13 @@ describe('Switch Ethereum Chain for two dapps', function () { | |
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
await driver.clickElement({ text: 'Confirm', tag: 'button' }); | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
await driver.delay(1000); | ||
await driver.switchToWindowWithUrl(DAPP_URL); | ||
await driver.findElement({ css: '#chainId', text: '0x53a' }); | ||
}, | ||
); | ||
}); | ||
|
@@ -278,7 +326,36 @@ describe('Switch Ethereum Chain for two dapps', function () { | |
text: 'Connect', | ||
tag: 'button', | ||
}); | ||
await driver.switchToWindowWithTitle( | ||
WINDOW_TITLES.ExtensionInFullScreenView, | ||
); | ||
await driver.clickElement( | ||
'[data-testid ="account-options-menu-button"]', | ||
); | ||
await driver.clickElement({ text: 'All Permissions', tag: 'div' }); | ||
await driver.clickElementAndWaitToDisappear({ | ||
text: 'Got it', | ||
tag: 'button', | ||
}); | ||
await driver.clickElement({ | ||
text: '127.0.0.1:8081', | ||
tag: 'p', | ||
}); | ||
const editButtons = await driver.findElements('[data-testid="edit"]'); | ||
|
||
// Ensure there are edit buttons | ||
assert.ok(editButtons.length > 0, 'Edit buttons are available'); | ||
|
||
// Click the first (0th) edit button | ||
await editButtons[1].click(); | ||
|
||
// Disconnect Mainnet | ||
await driver.clickElement({ | ||
text: 'Localhost 8545', | ||
tag: 'p', | ||
}); | ||
|
||
await driver.clickElement('[data-testid="connect-more-chains-button"]'); | ||
Comment on lines
+329
to
+358
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, would be nice to just not connect Dapp Two to 0x539 during the connection flow itself rather than disconnecting it afterwards |
||
await driver.switchToWindow(dappTwo); | ||
assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); | ||
|
||
|
@@ -293,14 +370,11 @@ describe('Switch Ethereum Chain for two dapps', function () { | |
await driver.executeScript( | ||
`window.ethereum.request(${switchEthereumChainRequest})`, | ||
); | ||
|
||
// Switch to notification of switchEthereumChain | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
await driver.findClickableElements({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
|
||
// Switch back to dapp one | ||
await driver.switchToWindow(dappOne); | ||
assert.equal(await driver.getCurrentUrl(), `${DAPP_URL}/`); | ||
|
@@ -401,7 +475,36 @@ describe('Switch Ethereum Chain for two dapps', function () { | |
text: 'Connect', | ||
tag: 'button', | ||
}); | ||
await driver.switchToWindowWithTitle( | ||
WINDOW_TITLES.ExtensionInFullScreenView, | ||
); | ||
await driver.clickElement( | ||
'[data-testid ="account-options-menu-button"]', | ||
); | ||
await driver.clickElement({ text: 'All Permissions', tag: 'div' }); | ||
await driver.clickElementAndWaitToDisappear({ | ||
text: 'Got it', | ||
tag: 'button', | ||
}); | ||
await driver.clickElement({ | ||
text: '127.0.0.1:8081', | ||
tag: 'p', | ||
}); | ||
const editButtons = await driver.findElements('[data-testid="edit"]'); | ||
|
||
// Ensure there are edit buttons | ||
assert.ok(editButtons.length > 0, 'Edit buttons are available'); | ||
|
||
// Click the first (0th) edit button | ||
await editButtons[1].click(); | ||
|
||
// Disconnect Mainnet | ||
await driver.clickElement({ | ||
text: 'Localhost 8545', | ||
tag: 'p', | ||
}); | ||
|
||
await driver.clickElement('[data-testid="connect-more-chains-button"]'); | ||
Comment on lines
+478
to
+507
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
await driver.switchToWindow(dappTwo); | ||
assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,12 +98,6 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { | |
`window.ethereum.request(${switchEthereumChainRequest})`, | ||
); | ||
|
||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
await driver.findElement({ | ||
text: 'Use your enabled networks', | ||
tag: 'p', | ||
}); | ||
|
||
Comment on lines
-101
to
-106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this check should still be valid. The globally selected network is 0x53a when Dapp Two connects, meaning that 0x539 should not be connected for Dapp Two and a Chain Permission approval should appear when trying to switch to it |
||
await driver.switchToWindowWithUrl(DAPP_ONE_URL); | ||
|
||
await driver.clickElement('#sendButton'); | ||
|
@@ -119,19 +113,6 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { | |
// so we leave this delay until the issue is fixed (#27360) | ||
await driver.delay(5000); | ||
|
||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
// Check correct network on the send confirmation. | ||
await driver.findElement({ | ||
css: '[data-testid="network-display"]', | ||
text: 'Localhost 8546', | ||
}); | ||
|
||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
|
||
Comment on lines
-122
to
-134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should also still be valid, but I would assume the confirmation is on Localhost 8545 |
||
// Switch back to the extension | ||
await driver.switchToWindowWithTitle( | ||
WINDOW_TITLES.ExtensionInFullScreenView, | ||
|
@@ -240,37 +221,19 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { | |
`window.ethereum.request(${switchEthereumChainRequest})`, | ||
); | ||
|
||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since Dapp is already connected to Test Network, we don't need to show review permission screem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the goal of the switch call is to trigger an approval to permit a chain that is not already permitted. |
||
await driver.findElement({ | ||
text: 'Use your enabled networks', | ||
tag: 'p', | ||
}); | ||
|
||
await driver.switchToWindowWithUrl(DAPP_ONE_URL); | ||
|
||
await driver.clickElement('#sendButton'); | ||
|
||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElement({ text: 'Cancel', tag: 'button' }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this needs to stay the same as well since we are testing the scenario when there is an approval for permitting a chain |
||
await driver.clickElement({ text: 'Confirm', tag: 'button' }); | ||
await driver.switchToWindowWithUrl(DAPP_ONE_URL); | ||
|
||
// Wait for switch confirmation to close then tx confirmation to show. | ||
// There is an extra window appearing and disappearing | ||
// so we leave this delay until the issue is fixed (#27360) | ||
await driver.delay(5000); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
// Check correct network on the send confirmation. | ||
await driver.findElement({ | ||
css: '[data-testid="network-display"]', | ||
text: 'Localhost 8546', | ||
}); | ||
|
||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
Comment on lines
-262
to
-273
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should stay as well. The goal here is to confirm that the network switch on Dapp One did not affect Dapp Two |
||
|
||
// Switch back to the extension | ||
await driver.switchToWindowWithTitle( | ||
|
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.
Not needed anymore since testnet is now included in the connections request