1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 03:12:42 +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"]');
const accountMenuItemSelector = `.multichain-account-list-item:nth-child(${itemNumber})`;
const acctName = await driver.findElement(
`${accountMenuItemSelector} .multichain-account-list-item__account-name__button`,
);
assert.equal(await acctName.getText(), accountName);
await driver.findElement({
css: `${accountMenuItemSelector} .multichain-account-list-item__account-name__button`,
text: accountName,
});
return accountMenuItemSelector;
};

View File

@ -8,6 +8,7 @@ const {
waitForAccountRendered,
convertToHexValue,
regularDelayMs,
login,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
@ -37,8 +38,7 @@ describe('Add account', function () {
},
async ({ driver }) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await login(driver);
await driver.clickElement('[data-testid="account-menu-icon"]');
await driver.clickElement(
@ -47,11 +47,10 @@ describe('Add account', function () {
await driver.fill('[placeholder="Account 2"]', '2nd account');
await driver.clickElement({ text: 'Create', tag: 'button' });
const accountName = await driver.waitForSelector({
await driver.findElement({
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
await waitForAccountRendered(driver);
const firstAccountPublicAddress = await retrieveShortenAccountAddress(
driver,
);
assert.equal(firstAccountPublicAddress, shortenAddress(firstAccount));
await driver.findElement({
css: '.multichain-address-copy-button',
text: shortenAddress(firstAccount),
});
// Create 2nd account
await driver.clickElement('[data-testid="account-menu-icon"]');
@ -91,13 +90,11 @@ describe('Add account', function () {
await waitForAccountRendered(driver);
// Check address of 2nd account
const secondAccountPublicAddress = await retrieveShortenAccountAddress(
driver,
);
assert.strictEqual(
secondAccountPublicAddress,
shortenAddress(secondAccount),
);
await waitForAccountRendered(driver);
await driver.findElement({
css: '.multichain-address-copy-button',
text: shortenAddress(secondAccount),
});
// Log into the account with balance(account 1)
// and transfer some balance to 2nd account
@ -143,12 +140,10 @@ describe('Add account', function () {
await waitForAccountRendered(driver);
// Check address of 1st account
const restoredFirstAccountPublicAddress =
await retrieveShortenAccountAddress(driver);
assert.equal(
restoredFirstAccountPublicAddress,
shortenAddress(firstAccount),
);
await driver.findElement({
css: '.multichain-address-copy-button',
text: shortenAddress(firstAccount),
});
// Check address of 2nd account
const accountTwoSelector = await findAnotherAccountFromAccountList(
@ -158,17 +153,15 @@ describe('Add account', function () {
);
await driver.clickElement(accountTwoSelector);
const restoredSecondAccountPublicAddress =
await retrieveShortenAccountAddress(driver);
assert.equal(
restoredSecondAccountPublicAddress,
shortenAddress(secondAccount),
);
await driver.findElement({
css: '.multichain-address-copy-button',
text: 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 =
'14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6';
@ -180,10 +173,7 @@ describe('Add account', function () {
},
async ({ driver }) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await waitForAccountRendered(driver);
await login(driver);
await driver.clickElement('[data-testid="account-menu-icon"]');
@ -195,10 +185,10 @@ describe('Add account', function () {
// Wait for 2nd account to be created
await waitForAccountRendered(driver);
const secondAccountCreated = await driver.findElement(
'[data-testid="account-menu-icon"]',
);
assert.equal(await secondAccountCreated.getText(), '2nd account');
await driver.findElement({
css: '[data-testid="account-menu-icon"]',
text: '2nd account',
});
await driver.clickElement('[data-testid="account-menu-icon"]');
@ -226,10 +216,10 @@ describe('Add account', function () {
// Wait for 3rd account to be created
await waitForAccountRendered(driver);
const thirdAccountCreated = await driver.findElement(
'[data-testid="account-menu-icon"]',
);
assert.equal(await thirdAccountCreated.getText(), 'Account 3');
await driver.findElement({
css: '[data-testid="account-menu-icon"]',
text: 'Account 3',
});
// User can delete 3rd account imported with a private key
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,
);
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await logInWithBalanceValidation(driver, ganacheServer);
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');
// Continue to next screen
await driver.findClickableElement({ 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' });
// Go back to home screen to check txn