mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
feat(19464): fix flaky test in MV3 Deploy contract and call contract methods (#19962)
* feat(19464): fix flaky test in Deploy contract and call contract methods * remove commented out code
This commit is contained in:
parent
a8ad19da32
commit
3871b8abed
@ -3,6 +3,9 @@ const {
|
|||||||
withFixtures,
|
withFixtures,
|
||||||
openDapp,
|
openDapp,
|
||||||
locateAccountBalanceDOM,
|
locateAccountBalanceDOM,
|
||||||
|
unlockWallet,
|
||||||
|
largeDelayMs,
|
||||||
|
WINDOW_TITLES,
|
||||||
} = require('../helpers');
|
} = require('../helpers');
|
||||||
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
|
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
|
||||||
const FixtureBuilder = require('../fixture-builder');
|
const FixtureBuilder = require('../fixture-builder');
|
||||||
@ -34,34 +37,32 @@ describe('Deploy contract and call contract methods', function () {
|
|||||||
smartContract,
|
smartContract,
|
||||||
);
|
);
|
||||||
await driver.navigate();
|
await driver.navigate();
|
||||||
await driver.fill('#password', 'correct horse battery staple');
|
await unlockWallet(driver);
|
||||||
await driver.press('#password', driver.Key.ENTER);
|
|
||||||
|
|
||||||
// deploy contract
|
// deploy contract
|
||||||
await openDapp(driver, contractAddress);
|
await openDapp(driver, contractAddress);
|
||||||
|
|
||||||
// wait for deployed contract, calls and confirms a contract method where ETH is sent
|
// wait for deployed contract, calls and confirms a contract method where ETH is sent
|
||||||
await driver.findClickableElement('#deployButton');
|
await driver.delay(largeDelayMs);
|
||||||
await driver.clickElement('#depositButton');
|
await driver.clickElement('#depositButton');
|
||||||
await driver.waitUntilXWindowHandles(3);
|
|
||||||
let windowHandles = await driver.getAllWindowHandles();
|
|
||||||
const extension = windowHandles[0];
|
|
||||||
const dapp = await driver.switchToWindowWithTitle(
|
|
||||||
'E2E Test Dapp',
|
|
||||||
windowHandles,
|
|
||||||
);
|
|
||||||
|
|
||||||
await driver.switchToWindowWithTitle(
|
await driver.waitForSelector({
|
||||||
'MetaMask Notification',
|
css: 'span',
|
||||||
windowHandles,
|
text: 'Deposit initiated',
|
||||||
);
|
});
|
||||||
|
|
||||||
|
await driver.waitUntilXWindowHandles(3);
|
||||||
|
await driver.switchToWindowWithTitle(WINDOW_TITLES.Notification);
|
||||||
await driver.waitForSelector({
|
await driver.waitForSelector({
|
||||||
css: '.confirm-page-container-summary__action__name',
|
css: '.confirm-page-container-summary__action__name',
|
||||||
text: 'Deposit',
|
text: 'Deposit',
|
||||||
});
|
});
|
||||||
|
|
||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
||||||
await driver.waitUntilXWindowHandles(2);
|
await driver.waitUntilXWindowHandles(2);
|
||||||
await driver.switchToWindow(extension);
|
await driver.switchToWindowWithTitle(
|
||||||
|
WINDOW_TITLES.ExtensionInFullScreenView,
|
||||||
|
);
|
||||||
await driver.clickElement({ text: 'Activity', tag: 'button' });
|
await driver.clickElement({ text: 'Activity', tag: 'button' });
|
||||||
await driver.waitForSelector(
|
await driver.waitForSelector(
|
||||||
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
||||||
@ -72,17 +73,16 @@ describe('Deploy contract and call contract methods', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// calls and confirms a contract method where ETH is received
|
// calls and confirms a contract method where ETH is received
|
||||||
await driver.switchToWindow(dapp);
|
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
|
||||||
await driver.clickElement('#withdrawButton');
|
await driver.clickElement('#withdrawButton');
|
||||||
await driver.waitUntilXWindowHandles(3);
|
await driver.waitUntilXWindowHandles(3);
|
||||||
windowHandles = await driver.getAllWindowHandles();
|
|
||||||
await driver.switchToWindowWithTitle(
|
await driver.switchToWindowWithTitle(WINDOW_TITLES.Notification);
|
||||||
'MetaMask Notification',
|
|
||||||
windowHandles,
|
|
||||||
);
|
|
||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
||||||
await driver.waitUntilXWindowHandles(2);
|
await driver.waitUntilXWindowHandles(2);
|
||||||
await driver.switchToWindow(extension);
|
await driver.switchToWindowWithTitle(
|
||||||
|
WINDOW_TITLES.ExtensionInFullScreenView,
|
||||||
|
);
|
||||||
await driver.waitForSelector(
|
await driver.waitForSelector(
|
||||||
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(2)',
|
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(2)',
|
||||||
);
|
);
|
||||||
@ -92,7 +92,9 @@ describe('Deploy contract and call contract methods', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// renders the correct ETH balance
|
// renders the correct ETH balance
|
||||||
await driver.switchToWindow(extension);
|
await driver.switchToWindowWithTitle(
|
||||||
|
WINDOW_TITLES.ExtensionInFullScreenView,
|
||||||
|
);
|
||||||
await locateAccountBalanceDOM(driver, ganacheServer);
|
await locateAccountBalanceDOM(driver, ganacheServer);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -371,7 +371,7 @@ class Driver {
|
|||||||
return await this.driver.getAllWindowHandles();
|
return await this.driver.getAllWindowHandles();
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilXWindowHandles(x, delayStep = 1000, timeout = 5000) {
|
async waitUntilXWindowHandles(x, delayStep = 1000, timeout = this.timeout) {
|
||||||
let timeElapsed = 0;
|
let timeElapsed = 0;
|
||||||
let windowHandles = [];
|
let windowHandles = [];
|
||||||
while (timeElapsed <= timeout) {
|
while (timeElapsed <= timeout) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user