-
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: chainid, switch custom net, batch tx diff, snaps #27725
Changes from all commits
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ const { | |
defaultGanacheOptions, | ||
withFixtures, | ||
unlockWallet, | ||
switchToNotificationWindow, | ||
WINDOW_TITLES, | ||
} = require('../helpers'); | ||
const FixtureBuilder = require('../fixture-builder'); | ||
|
@@ -37,22 +36,18 @@ describe('Test Snap TxInsights-v2', function () { | |
await driver.clickElement('#connecttransaction-insights'); | ||
|
||
// switch to metamask extension and click connect | ||
await switchToNotificationWindow(driver); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
await driver.clickElement({ | ||
text: 'Connect', | ||
tag: 'button', | ||
}); | ||
|
||
await driver.waitForSelector({ text: 'Connect' }); | ||
|
||
await driver.clickElement({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
|
||
await driver.waitForSelector({ text: 'OK' }); | ||
|
||
await driver.clickElement({ | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
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 mitigates race conditions: we should not proceed to the next step until the dialog is closed |
||
text: 'OK', | ||
tag: 'button', | ||
}); | ||
|
@@ -62,8 +57,8 @@ describe('Test Snap TxInsights-v2', function () { | |
await driver.clickElement('#getAccounts'); | ||
|
||
// switch back to MetaMask window and deal with dialogs | ||
await switchToNotificationWindow(driver); | ||
await driver.clickElement({ | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
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, wait for the dialog to close before proceeding |
||
text: 'Connect', | ||
tag: 'button', | ||
}); | ||
|
@@ -74,7 +69,7 @@ describe('Test Snap TxInsights-v2', function () { | |
|
||
// switch back to MetaMask window and switch to tx insights pane | ||
await driver.delay(2000); | ||
await switchToNotificationWindow(driver); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.findClickableElement({ | ||
text: 'Confirm', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ const { | |
defaultGanacheOptions, | ||
withFixtures, | ||
unlockWallet, | ||
switchToNotificationWindow, | ||
WINDOW_TITLES, | ||
} = require('../helpers'); | ||
const FixtureBuilder = require('../fixture-builder'); | ||
|
@@ -37,22 +36,18 @@ describe('Test Snap TxInsights', function () { | |
await driver.clickElement('#connecttransaction-insights'); | ||
|
||
// switch to metamask extension and click connect | ||
await switchToNotificationWindow(driver, 2); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
await driver.clickElement({ | ||
text: 'Connect', | ||
tag: 'button', | ||
}); | ||
|
||
await driver.waitForSelector({ text: 'Confirm' }); | ||
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. not needed |
||
|
||
await driver.clickElement({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
|
||
await driver.waitForSelector({ text: 'OK' }); | ||
|
||
await driver.clickElement({ | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
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. wait for the dialog to close before proceeding |
||
text: 'OK', | ||
tag: 'button', | ||
}); | ||
|
@@ -62,8 +57,8 @@ describe('Test Snap TxInsights', function () { | |
await driver.clickElement('#getAccounts'); | ||
|
||
// switch back to MetaMask window and deal with dialogs | ||
await switchToNotificationWindow(driver, 2); | ||
await driver.clickElement({ | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
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. wait for the dialog to close before proceeding |
||
text: 'Connect', | ||
tag: 'button', | ||
}); | ||
|
@@ -74,11 +69,8 @@ describe('Test Snap TxInsights', function () { | |
|
||
// switch back to MetaMask window and switch to tx insights pane | ||
await driver.delay(2000); | ||
await switchToNotificationWindow(driver, 2); | ||
await driver.waitForSelector({ | ||
text: 'Insights Example Snap', | ||
tag: 'button', | ||
}); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElement({ | ||
text: 'Insights Example Snap', | ||
tag: 'button', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,9 @@ const { | |
unlockWallet, | ||
DAPP_URL, | ||
DAPP_ONE_URL, | ||
regularDelayMs, | ||
WINDOW_TITLES, | ||
defaultGanacheOptions, | ||
largeDelayMs, | ||
switchToNotificationWindow, | ||
} = require('../../helpers'); | ||
const { PAGES } = require('../../webdriver/driver'); | ||
|
||
|
@@ -49,14 +47,11 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks', fun | |
await openDapp(driver, undefined, DAPP_URL); | ||
|
||
// Connect to dapp 1 | ||
await driver.findClickableElement({ text: 'Connect', tag: 'button' }); | ||
await driver.clickElement('#connectButton'); | ||
await driver.clickElement({ text: 'Connect', tag: 'button' }); | ||
|
||
await driver.delay(regularDelayMs); | ||
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. not needed |
||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await switchToNotificationWindow(driver); | ||
|
||
await driver.clickElement({ | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
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. wait for the dialog to close before proceeding |
||
text: 'Connect', | ||
tag: 'button', | ||
}); | ||
|
@@ -82,14 +77,11 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks', fun | |
await openDapp(driver, undefined, DAPP_ONE_URL); | ||
|
||
// Connect to dapp 2 | ||
await driver.findClickableElement({ text: 'Connect', 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. not needed |
||
await driver.clickElement('#connectButton'); | ||
|
||
await driver.delay(regularDelayMs); | ||
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. not needed |
||
await driver.clickElement({ text: 'Connect', tag: 'button' }); | ||
|
||
await switchToNotificationWindow(driver, 4); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElement({ | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Connect', | ||
tag: 'button', | ||
}); | ||
|
@@ -108,24 +100,29 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks', fun | |
await driver.clickElement('#sendButton'); | ||
await driver.clickElement('#sendButton'); | ||
|
||
await switchToNotificationWindow(driver, 4); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.findElement( | ||
await driver.waitForSelector( | ||
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. just a nit |
||
By.xpath("//div[normalize-space(.)='1 of 2']"), | ||
); | ||
|
||
// Reject All Transactions | ||
await driver.clickElement('.page-container__footer-secondary a'); | ||
|
||
await driver.clickElement({ text: 'Reject all', tag: 'button' }); // TODO: Do we want to confirm here? | ||
// TODO: Do we want to confirm here? | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
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. wait for the dialog to close before proceeding |
||
text: 'Reject all', | ||
tag: 'button', | ||
}); | ||
|
||
// Wait for confirmation to close | ||
await driver.waitUntilXWindowHandles(3); | ||
// TODO: find a better way to handle different dialog ids | ||
await driver.delay(2000); | ||
|
||
// Wait for new confirmations queued from second dapp to open | ||
await switchToNotificationWindow(driver, 4); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.findElement( | ||
await driver.waitForSelector( | ||
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. nit |
||
By.xpath("//div[normalize-space(.)='1 of 2']"), | ||
); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,13 +233,11 @@ describe('Request Queueing chainId proxy sync', function () { | |
assert.equal(chainIdBeforeConnectAfterManualSwitch, '0x1'); | ||
|
||
// Connect to dapp | ||
await driver.findClickableElement({ text: 'Connect', tag: 'button' }); | ||
await driver.clickElement('#connectButton'); | ||
await driver.clickElement({ text: 'Connect', tag: 'button' }); | ||
|
||
await driver.delay(regularDelayMs); | ||
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. not needed |
||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await switchToNotificationWindow(driver); | ||
await driver.clickElement({ | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Connect', | ||
tag: 'button', | ||
}); | ||
|
@@ -252,6 +250,10 @@ describe('Request Queueing chainId proxy sync', function () { | |
|
||
// should still be on the same chainId as the wallet after connecting | ||
assert.equal(chainIdAfterConnect, '0x1'); | ||
await driver.waitForSelector({ | ||
css: '[id="chainId"]', | ||
text: '0x1', | ||
}); | ||
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. ensure the test dapp has the new chain id too |
||
|
||
const switchEthereumChainRequest = JSON.stringify({ | ||
jsonrpc: '2.0', | ||
|
@@ -263,14 +265,13 @@ describe('Request Queueing chainId proxy sync', function () { | |
`window.ethereum.request(${switchEthereumChainRequest})`, | ||
); | ||
|
||
await switchToNotificationWindow(driver); | ||
await driver.findClickableElements({ | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
|
||
await driver.clickElement({ text: 'Confirm', tag: 'button' }); | ||
|
||
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); | ||
|
||
const chainIdAfterDappSwitch = await driver.executeScript( | ||
|
@@ -280,6 +281,10 @@ describe('Request Queueing chainId proxy sync', function () { | |
// should be on the new chainId that was requested | ||
assert.equal(chainIdAfterDappSwitch, '0x539'); // 1337 | ||
|
||
await driver.waitForSelector({ | ||
css: '[id="chainId"]', | ||
text: '0x539', | ||
}); | ||
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. ensure the test dapp has the new chain id too |
||
await driver.switchToWindowWithTitle( | ||
WINDOW_TITLES.ExtensionInFullScreenView, | ||
); | ||
|
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 as clicking the element already implies the button is there and clickable