-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
fix: flaky test Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx should queue send tx after switch network confirmation and transaction should target the correct network after switch is confirmed
#27352
Changes from all commits
8c85d5d
4ce7e5b
70453e1
20bb373
fb6ae91
f865b2d
969eab0
9c96bac
fec77aa
c7fd526
ed3fbf6
3298b59
dffd70c
c116223
c1e9a64
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 |
---|---|---|
@@ -1,14 +1,12 @@ | ||
const FixtureBuilder = require('../../fixture-builder'); | ||
const { | ||
withFixtures, | ||
DAPP_ONE_URL, | ||
DAPP_URL, | ||
defaultGanacheOptions, | ||
openDapp, | ||
unlockWallet, | ||
DAPP_URL, | ||
DAPP_ONE_URL, | ||
regularDelayMs, | ||
WINDOW_TITLES, | ||
defaultGanacheOptions, | ||
switchToNotificationWindow, | ||
withFixtures, | ||
} = require('../../helpers'); | ||
|
||
describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { | ||
|
@@ -51,17 +49,15 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { | |
await driver.findClickableElement({ text: 'Connect', tag: 'button' }); | ||
await driver.clickElement('#connectButton'); | ||
|
||
await driver.delay(regularDelayMs); | ||
|
||
await switchToNotificationWindow(driver); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElement({ | ||
text: 'Next', | ||
tag: 'button', | ||
css: '[data-testid="page-container-footer-next"]', | ||
}); | ||
|
||
await driver.clickElement({ | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
css: '[data-testid="page-container-footer-next"]', | ||
|
@@ -80,9 +76,6 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { | |
css: 'p', | ||
}); | ||
|
||
// Wait for the first dapp's connect confirmation to disappear | ||
await driver.waitUntilXWindowHandles(2); | ||
|
||
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. no need to add this, as we handle the close window into the `clickElementAndWaitForWindowToClose |
||
// TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. | ||
// Open Dapp Two | ||
await openDapp(driver, undefined, DAPP_ONE_URL); | ||
|
@@ -91,17 +84,15 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { | |
await driver.findClickableElement({ text: 'Connect', tag: 'button' }); | ||
await driver.clickElement('#connectButton'); | ||
|
||
await driver.delay(regularDelayMs); | ||
|
||
await switchToNotificationWindow(driver, 4); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElement({ | ||
text: 'Next', | ||
tag: 'button', | ||
css: '[data-testid="page-container-footer-next"]', | ||
}); | ||
|
||
await driver.clickElement({ | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
css: '[data-testid="page-container-footer-next"]', | ||
|
@@ -121,31 +112,39 @@ 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: 'Allow this site to switch the network?', | ||
tag: 'h3', | ||
}); | ||
|
||
await driver.switchToWindowWithUrl(DAPP_ONE_URL); | ||
|
||
await driver.clickElement('#sendButton'); | ||
|
||
await switchToNotificationWindow(driver, 4); | ||
await driver.findClickableElements({ | ||
text: 'Switch network', | ||
tag: 'button', | ||
}); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElement({ text: 'Switch network', tag: 'button' }); | ||
|
||
await driver.switchToWindowWithUrl(DAPP_ONE_URL); | ||
|
||
// Wait for switch confirmation to close then tx confirmation to show. | ||
await driver.waitUntilXWindowHandles(3); | ||
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 point is where test breaks in webpack: if the next dialog window is opened really fast, this condition is never met |
||
await driver.delay(regularDelayMs); | ||
// There is an extra window appearing and disappearing | ||
// so we leave this delay until the issue is fixed (#27360) | ||
await driver.delay(5000); | ||
|
||
await switchToNotificationWindow(driver, 4); | ||
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.clickElement({ text: 'Confirm', tag: 'button' }); | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
|
||
// Switch back to the extension | ||
await driver.switchToWindowWithTitle( | ||
|
@@ -206,17 +205,15 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { | |
await driver.findClickableElement({ text: 'Connect', tag: 'button' }); | ||
await driver.clickElement('#connectButton'); | ||
|
||
await driver.delay(regularDelayMs); | ||
|
||
await switchToNotificationWindow(driver); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElement({ | ||
text: 'Next', | ||
tag: 'button', | ||
css: '[data-testid="page-container-footer-next"]', | ||
}); | ||
|
||
await driver.clickElement({ | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
css: '[data-testid="page-container-footer-next"]', | ||
|
@@ -235,9 +232,6 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { | |
css: 'p', | ||
}); | ||
|
||
// Wait for the first dapp's connect confirmation to disappear | ||
await driver.waitUntilXWindowHandles(2); | ||
|
||
// TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. | ||
// Open Dapp Two | ||
await openDapp(driver, undefined, DAPP_ONE_URL); | ||
|
@@ -246,17 +240,15 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { | |
await driver.findClickableElement({ text: 'Connect', tag: 'button' }); | ||
await driver.clickElement('#connectButton'); | ||
|
||
await driver.delay(regularDelayMs); | ||
|
||
await switchToNotificationWindow(driver, 4); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElement({ | ||
text: 'Next', | ||
tag: 'button', | ||
css: '[data-testid="page-container-footer-next"]', | ||
}); | ||
|
||
await driver.clickElement({ | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
css: '[data-testid="page-container-footer-next"]', | ||
|
@@ -276,31 +268,37 @@ 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: 'Allow this site to switch the network?', | ||
tag: 'h3', | ||
}); | ||
|
||
await driver.switchToWindowWithUrl(DAPP_ONE_URL); | ||
|
||
await driver.clickElement('#sendButton'); | ||
|
||
await switchToNotificationWindow(driver, 4); | ||
await driver.findClickableElements({ | ||
text: 'Cancel', | ||
tag: 'button', | ||
}); | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
await driver.clickElement({ text: 'Cancel', tag: 'button' }); | ||
await driver.switchToWindowWithUrl(DAPP_ONE_URL); | ||
|
||
// Wait for switch confirmation to close then tx confirmation to show. | ||
await driver.waitUntilXWindowHandles(3); | ||
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 point is where test breaks in webpack: if the next dialog window is opened really fast, this condition is never met |
||
await driver.delay(regularDelayMs); | ||
|
||
await switchToNotificationWindow(driver, 4); | ||
// 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.clickElement({ text: 'Confirm', tag: 'button' }); | ||
await driver.clickElementAndWaitForWindowToClose({ | ||
text: 'Confirm', | ||
tag: 'button', | ||
}); | ||
|
||
// 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.
removed deprecated method and using the correct one (no need to add the delay)