1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

feature(19625): eliminate e2e flakyness for add-account and send-eth (#19645)

* feature(19625): eliminate e2e flakyness for add-account and send-eth

* feature(19625): remove await delay in send-eth
This commit is contained in:
Danica Shen 2023-06-20 14:45:40 +01:00 committed by GitHub
parent ba3f86400c
commit f10775f55d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 58 deletions

View File

@ -500,10 +500,12 @@ const findAnotherAccountFromAccountList = async (
) => { ) => {
await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement('[data-testid="account-menu-icon"]');
const accountMenuItemSelector = `.multichain-account-list-item:nth-child(${itemNumber})`; const accountMenuItemSelector = `.multichain-account-list-item:nth-child(${itemNumber})`;
const acctName = await driver.findElement(
`${accountMenuItemSelector} .multichain-account-list-item__account-name__button`, await driver.findElement({
); css: `${accountMenuItemSelector} .multichain-account-list-item__account-name__button`,
assert.equal(await acctName.getText(), accountName); text: accountName,
});
return accountMenuItemSelector; return accountMenuItemSelector;
}; };

View File

@ -8,6 +8,7 @@ const {
waitForAccountRendered, waitForAccountRendered,
convertToHexValue, convertToHexValue,
regularDelayMs, regularDelayMs,
login,
} = require('../helpers'); } = require('../helpers');
const FixtureBuilder = require('../fixture-builder'); const FixtureBuilder = require('../fixture-builder');
@ -37,8 +38,7 @@ describe('Add account', function () {
}, },
async ({ driver }) => { async ({ driver }) => {
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await login(driver);
await driver.press('#password', driver.Key.ENTER);
await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement('[data-testid="account-menu-icon"]');
await driver.clickElement( await driver.clickElement(
@ -47,11 +47,10 @@ describe('Add account', function () {
await driver.fill('[placeholder="Account 2"]', '2nd account'); await driver.fill('[placeholder="Account 2"]', '2nd account');
await driver.clickElement({ text: 'Create', tag: 'button' }); await driver.clickElement({ text: 'Create', tag: 'button' });
const accountName = await driver.waitForSelector({ await driver.findElement({
css: '[data-testid="account-menu-icon"]', css: '[data-testid="account-menu-icon"]',
text: '2nd', text: '2nd account',
}); });
assert.equal(await accountName.getText(), '2nd account');
}, },
); );
}); });
@ -76,10 +75,10 @@ describe('Add account', function () {
// Check address of 1st account // Check address of 1st account
await waitForAccountRendered(driver); await waitForAccountRendered(driver);
const firstAccountPublicAddress = await retrieveShortenAccountAddress( await driver.findElement({
driver, css: '.multichain-address-copy-button',
); text: shortenAddress(firstAccount),
assert.equal(firstAccountPublicAddress, shortenAddress(firstAccount)); });
// Create 2nd account // Create 2nd account
await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement('[data-testid="account-menu-icon"]');
@ -91,13 +90,11 @@ describe('Add account', function () {
await waitForAccountRendered(driver); await waitForAccountRendered(driver);
// Check address of 2nd account // Check address of 2nd account
const secondAccountPublicAddress = await retrieveShortenAccountAddress( await waitForAccountRendered(driver);
driver, await driver.findElement({
); css: '.multichain-address-copy-button',
assert.strictEqual( text: shortenAddress(secondAccount),
secondAccountPublicAddress, });
shortenAddress(secondAccount),
);
// Log into the account with balance(account 1) // Log into the account with balance(account 1)
// and transfer some balance to 2nd account // and transfer some balance to 2nd account
@ -143,12 +140,10 @@ describe('Add account', function () {
await waitForAccountRendered(driver); await waitForAccountRendered(driver);
// Check address of 1st account // Check address of 1st account
const restoredFirstAccountPublicAddress = await driver.findElement({
await retrieveShortenAccountAddress(driver); css: '.multichain-address-copy-button',
assert.equal( text: shortenAddress(firstAccount),
restoredFirstAccountPublicAddress, });
shortenAddress(firstAccount),
);
// Check address of 2nd account // Check address of 2nd account
const accountTwoSelector = await findAnotherAccountFromAccountList( const accountTwoSelector = await findAnotherAccountFromAccountList(
@ -158,17 +153,15 @@ describe('Add account', function () {
); );
await driver.clickElement(accountTwoSelector); await driver.clickElement(accountTwoSelector);
const restoredSecondAccountPublicAddress = await driver.findElement({
await retrieveShortenAccountAddress(driver); css: '.multichain-address-copy-button',
assert.equal( text: shortenAddress(secondAccount),
restoredSecondAccountPublicAddress, });
shortenAddress(secondAccount),
);
}, },
); );
}); });
it('It should be possible to remove an account imported with a private key, but should not be possible to remove an account generated from the SRP imported in onboarding', async function () { it('should be possible to remove an account imported with a private key, but should not be possible to remove an account generated from the SRP imported in onboarding', async function () {
const testPrivateKey = const testPrivateKey =
'14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6'; '14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6';
@ -180,10 +173,7 @@ describe('Add account', function () {
}, },
async ({ driver }) => { async ({ driver }) => {
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await login(driver);
await driver.press('#password', driver.Key.ENTER);
await waitForAccountRendered(driver);
await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement('[data-testid="account-menu-icon"]');
@ -195,10 +185,10 @@ describe('Add account', function () {
// Wait for 2nd account to be created // Wait for 2nd account to be created
await waitForAccountRendered(driver); await waitForAccountRendered(driver);
const secondAccountCreated = await driver.findElement( await driver.findElement({
'[data-testid="account-menu-icon"]', css: '[data-testid="account-menu-icon"]',
); text: '2nd account',
assert.equal(await secondAccountCreated.getText(), '2nd account'); });
await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement('[data-testid="account-menu-icon"]');
@ -226,10 +216,10 @@ describe('Add account', function () {
// Wait for 3rd account to be created // Wait for 3rd account to be created
await waitForAccountRendered(driver); await waitForAccountRendered(driver);
const thirdAccountCreated = await driver.findElement( await driver.findElement({
'[data-testid="account-menu-icon"]', css: '[data-testid="account-menu-icon"]',
); text: 'Account 3',
assert.equal(await thirdAccountCreated.getText(), 'Account 3'); });
// User can delete 3rd account imported with a private key // User can delete 3rd account imported with a private key
await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement('[data-testid="account-menu-icon"]');
@ -245,11 +235,3 @@ describe('Add account', function () {
); );
}); });
}); });
async function retrieveShortenAccountAddress(driver) {
// get the shorten public address for account
const accountDOM = await driver.waitForSelector(
'.multichain-address-copy-button',
);
return await accountDOM.getText();
}

View File

@ -412,8 +412,7 @@ describe('Send ETH from inside MetaMask to a Multisig Address', function () {
smartContract, smartContract,
); );
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await logInWithBalanceValidation(driver, ganacheServer);
await driver.press('#password', driver.Key.ENTER);
await driver.clickElement('[data-testid="eth-overview-send"]'); await driver.clickElement('[data-testid="eth-overview-send"]');
@ -426,10 +425,7 @@ describe('Send ETH from inside MetaMask to a Multisig Address', function () {
await inputAmount.fill('1'); await inputAmount.fill('1');
// Continue to next screen // Continue to next screen
await driver.findClickableElement({ text: 'Next', tag: 'button' });
await driver.clickElement({ text: 'Next', tag: 'button' }); await driver.clickElement({ text: 'Next', tag: 'button' });
await driver.findClickableElement({ text: 'Confirm', tag: 'button' });
await driver.clickElement({ text: 'Confirm', tag: 'button' }); await driver.clickElement({ text: 'Confirm', tag: 'button' });
// Go back to home screen to check txn // Go back to home screen to check txn