1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

feature(19496): eliminate flow e2e flakyness in terms of asserting content for DOM (#19600)

This commit is contained in:
Danica Shen 2023-06-15 11:01:44 +01:00 committed by GitHub
parent 46a2604df0
commit 2648c783ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,8 +22,8 @@ const ganacheOptions = {
], ],
}; };
describe('MetaMask Import UI', function () { describe('Import flow', function () {
it('Importing wallet using Secret Recovery Phrase', async function () { it('Import wallet using Secret Recovery Phrase', async function () {
const testPassword = 'correct horse battery staple'; const testPassword = 'correct horse battery staple';
await withFixtures( await withFixtures(
@ -138,7 +138,7 @@ describe('MetaMask Import UI', function () {
); );
}); });
it('Importing wallet using Secret Recovery Phrase with pasting word by word', async function () { it('Import wallet using Secret Recovery Phrase with pasting word by word', async function () {
const testPassword = 'correct horse battery staple'; const testPassword = 'correct horse battery staple';
const testAddress = '0x0Cc5261AB8cE458dc977078A3623E2BaDD27afD3'; const testAddress = '0x0Cc5261AB8cE458dc977078A3623E2BaDD27afD3';
@ -175,7 +175,7 @@ describe('MetaMask Import UI', function () {
); );
}); });
it('Import Account using private key', async function () { it('Import Account using private key and remove imported account', async function () {
const testPrivateKey1 = const testPrivateKey1 =
'14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6'; '14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6';
const testPrivateKey2 = const testPrivateKey2 =
@ -195,52 +195,45 @@ describe('MetaMask Import UI', function () {
await driver.fill('#password', 'correct horse battery staple'); await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER); await driver.press('#password', driver.Key.ENTER);
// Imports an account with private key
// choose Create account from the account menu
await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement('[data-testid="account-menu-icon"]');
await driver.clickElement({ text: 'Import account', tag: 'button' }); await driver.clickElement({ text: 'Import account', tag: 'button' });
// enter private key // Imports Account 4 with private key
await driver.findClickableElement('#private-key-box'); await driver.findClickableElement('#private-key-box');
await driver.fill('#private-key-box', testPrivateKey1); await driver.fill('#private-key-box', testPrivateKey1);
await driver.clickElement( await driver.clickElement(
'[data-testid="import-account-confirm-button"]', '[data-testid="import-account-confirm-button"]',
); );
// should show the correct account name // New imported account has correct name and label
const importedAccountName = await driver.findElement( await driver.findElement({
'[data-testid="account-menu-icon"]', css: '[data-testid="account-menu-icon"]',
); text: 'Account 4',
assert.equal(await importedAccountName.getText(), 'Account 4'); });
// should show the imported label
// confirm 4th account is account 4, as expected
const accountMenuItemSelector = await findAnotherAccountFromAccountList( const accountMenuItemSelector = await findAnotherAccountFromAccountList(
driver, driver,
4, 4,
'Account 4', 'Account 4',
); );
// confirm label is present on the same menu item await driver.findElement({
const importedLabel = await driver.findElement( css: `${accountMenuItemSelector} .mm-tag`,
`${accountMenuItemSelector} .mm-tag`, text: 'Imported',
); });
assert.equal(await importedLabel.getText(), 'Imported');
// Imports and removes an account // Imports Account 5 with private key
// choose Create account from the account menu
await driver.clickElement({ text: 'Import account', tag: 'button' }); await driver.clickElement({ text: 'Import account', tag: 'button' });
// enter private key
await driver.findClickableElement('#private-key-box'); await driver.findClickableElement('#private-key-box');
await driver.fill('#private-key-box', testPrivateKey2); await driver.fill('#private-key-box', testPrivateKey2);
await driver.clickElement( await driver.clickElement(
'[data-testid="import-account-confirm-button"]', '[data-testid="import-account-confirm-button"]',
); );
// should see new account in account menu // New imported account has correct name and label
const importedAccount2Name = await driver.findElement( await driver.findElement({
'[data-testid="account-menu-icon"]', css: '[data-testid="account-menu-icon"]',
); text: 'Account 5',
assert.equal(await importedAccount2Name.getText(), 'Account 5'); });
await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement('[data-testid="account-menu-icon"]');
const accountListItems = await driver.findElements( const accountListItems = await driver.findElements(
'.multichain-account-list-item', '.multichain-account-list-item',
@ -251,20 +244,14 @@ describe('MetaMask Import UI', function () {
'.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]', '.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]',
); );
// Account 5 can be removed
await driver.clickElement('[data-testid="account-list-menu-remove"]'); await driver.clickElement('[data-testid="account-list-menu-remove"]');
// should remove the account
await driver.clickElement({ text: 'Remove', tag: 'button' }); await driver.clickElement({ text: 'Remove', tag: 'button' });
await driver.findElement({
// Wait until selected account switches away from removed account to first account
await driver.waitForSelector({
css: '[data-testid="account-menu-icon"]', css: '[data-testid="account-menu-icon"]',
text: 'Account 1', text: 'Account 1',
}); });
await driver.delay(regularDelayMs);
await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement('[data-testid="account-menu-icon"]');
const accountListItemsAfterRemoval = await driver.findElements( const accountListItemsAfterRemoval = await driver.findElements(
'.multichain-account-list-item', '.multichain-account-list-item',
); );
@ -310,25 +297,21 @@ describe('MetaMask Import UI', function () {
'[data-testid="import-account-confirm-button"]', '[data-testid="import-account-confirm-button"]',
); );
// should show the correct account name // New imported account has correct name and label
const importedAccountName = await driver.findElement( await driver.findElement({
'[data-testid="account-menu-icon"]', css: '[data-testid="account-menu-icon"]',
); text: 'Account 4',
assert.equal(await importedAccountName.getText(), 'Account 4'); });
// should show the imported label
// confirm 4th account is account 4, as expected
const accountMenuItemSelector = await findAnotherAccountFromAccountList( const accountMenuItemSelector = await findAnotherAccountFromAccountList(
driver, driver,
4, 4,
'Account 4', 'Account 4',
); );
await driver.findElement({
// confirm label is present on the same menu item css: `${accountMenuItemSelector} .mm-tag`,
const importedLabel = await driver.findElement( text: 'Imported',
`${accountMenuItemSelector} .mm-tag`, });
);
assert.equal(await importedLabel.getText(), 'Imported');
const accountListItems = await driver.findElements( const accountListItems = await driver.findElements(
'.multichain-account-list-item', '.multichain-account-list-item',