Skip to content

Commit

Permalink
feature(19625): eliminate e2e flakyness for add-account and send-eth (M…
Browse files Browse the repository at this point in the history
…etaMask#19645)

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

* feature(19625): remove await delay in send-eth
  • Loading branch information
DDDDDanica authored Jun 20, 2023
1 parent ba3f864 commit f10775f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 58 deletions.
10 changes: 6 additions & 4 deletions test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
80 changes: 31 additions & 49 deletions test/e2e/tests/add-account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
waitForAccountRendered,
convertToHexValue,
regularDelayMs,
login,
} = require('../helpers');

const FixtureBuilder = require('../fixture-builder');
Expand Down Expand Up @@ -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(
Expand All @@ -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');
},
);
});
Expand All @@ -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"]');
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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';

Expand All @@ -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"]');

Expand All @@ -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"]');

Expand Down Expand Up @@ -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"]');
Expand All @@ -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();
}
6 changes: 1 addition & 5 deletions test/e2e/tests/send-eth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]');

Expand All @@ -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
Expand Down

0 comments on commit f10775f

Please sign in to comment.