mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
* Show portfolio icon in ETH overview
* Show new copy button in QR code modal
* Show address copy button in wallet overview
* Update connected status component
* Remove legacy MenuBar
* Remove legacy ImportTokenLink
* Remove AssetListItem
* Remove DetectedTokensLink
* Remove legacy AppHeader
* Remove MULTICHAIN flag from builds.yml
* Remove legacy AccountMenu
* FIX: Token cell snapshot
* Add data-testid for Account Picker
* Remove multichain check in LoadingNetworkScreen
* Remove MULTICHAIN check for AccountDetailsModal
* Remove MULTICHAIN check for AssetList
* Update QR dimensions
* Remove MULTICHAIN declaration from metamaskrc.dist
* Implement PickerNetwork and NetworkListMenu in onboarding
* Remove legacy NetworkDropdown and Dropdown
* Remove documentation about legacy account menu
* FIX: Fixes route tests for missing data-testid=network-display
* Fix account-menu-icon data-testid
* Fix TokenCell test
* FIX Onboarding Flow tests
* Remove unused locales from AccountMenu removal
* E2E: Fix Import Secret Recovery Phrase: logs out of the vault
* E2E: Fix Show account details: should show the QR code for the account
* E2E: Fix add-account.spec.js
* E2E: Fix state-logs.spec.js
* E2E: Fix lock-account.spec.js
* E2E: Fix settings-general.spec.js
* E2E: Fix advanced-settings.spec.js
* E2E: Fix auto-lock.spec.js
* E2E: Fix backup-restore.spec.js
* E2E: Fix clear-activity.spec.js
* E2E: Fix settings-search.spec.js
* E2E: Fix encrypt-decrypt.spec.js
* E2E: Fix dapp-interactions.spec.js
* E2E: Fix test-snap-management.spec.js
* E2E: Fix add-custom-network.spec.js
* E2E: Fix from-import-ui.spec.js
* E2E: Fix provider-api.spec.js
* E2E: Fix chain-interactions.spec.js
* E2E: Fix custom-rpc-history.spec.js
* Remove network icon from overview components
* E2E: Fix user-actions-benchmark.js
* E2E: Fix benchmark.js
* E2E: Fix add-hide-token.spec.js
* E2E: Fix address-book.spec.js
* E2E: Fix custom-token-add-approve.spec.js
* E2E: Fix incremental-security.spec.js
* E2E: Fix metamask-responsive-ui.spec.js
* E2E: Onboarding.spec.js
* E2E: Fix permissions.spec.js
* E2E: Fix send-hex-address.spec.js
* E2E: Fix send-to-contract.spec.js
* Remove dead AccountOptionsMenu test
* E2E: Fix token-details.spec.js
* E2E: Fix switch-custom-network.spec.js
* E2E: Fix metamask-ui.spec.js
* Revert "UX Multichain: updated border top for activity list (#19176)"
This reverts commit 15598f2a23
.
* E2Es: Fix test-snap-management.spec.js and test-snap-notification.spec.js
* E2Es: Fix add-account.spec.js after flaky test fixes
* e2e flaky test
* adds back the mmi options
* scss fix
* test fix
* removes unnecessary double quotes
* Prevent double logos on login screen
* Update ui/components/ui/list-item/index.scss
Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>
---------
Co-authored-by: seaona <mariona@gmx.es>
Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net>
Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>
403 lines
14 KiB
JavaScript
403 lines
14 KiB
JavaScript
const { strict: assert } = require('assert');
|
|
const path = require('path');
|
|
const {
|
|
TEST_SEED_PHRASE,
|
|
convertToHexValue,
|
|
withFixtures,
|
|
regularDelayMs,
|
|
largeDelayMs,
|
|
completeImportSRPOnboardingFlow,
|
|
completeImportSRPOnboardingFlowWordByWord,
|
|
findAnotherAccountFromAccountList,
|
|
} = require('../helpers');
|
|
const FixtureBuilder = require('../fixture-builder');
|
|
|
|
const ganacheOptions = {
|
|
accounts: [
|
|
{
|
|
secretKey:
|
|
'0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9',
|
|
balance: convertToHexValue(25000000000000000000),
|
|
},
|
|
],
|
|
};
|
|
|
|
describe('MetaMask Import UI', function () {
|
|
it('Importing wallet using Secret Recovery Phrase', async function () {
|
|
const testPassword = 'correct horse battery staple';
|
|
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder({ onboarding: true }).build(),
|
|
ganacheOptions,
|
|
title: this.test.title,
|
|
failOnConsoleError: false,
|
|
},
|
|
async ({ driver }) => {
|
|
await driver.navigate();
|
|
|
|
await completeImportSRPOnboardingFlow(
|
|
driver,
|
|
TEST_SEED_PHRASE,
|
|
testPassword,
|
|
);
|
|
|
|
// Show account information
|
|
await driver.clickElement('[data-testid="account-menu-icon"]');
|
|
await driver.clickElement(
|
|
'[data-testid="account-list-item-menu-button"]',
|
|
);
|
|
await driver.clickElement('[data-testid="account-list-menu-details"');
|
|
await driver.findVisibleElement('.qr-code__wrapper');
|
|
|
|
// shows a QR code for the account
|
|
await driver.findVisibleElement('.popover-container');
|
|
// shows the correct account address
|
|
const address = await driver.findElement(
|
|
'.multichain-address-copy-button',
|
|
);
|
|
assert.equal(await address.getText(), '0x0Cc...afD3');
|
|
|
|
await driver.clickElement('[data-testid="popover-close"]');
|
|
|
|
// logs out of the account
|
|
await driver.clickElement(
|
|
'[data-testid="account-options-menu-button"]',
|
|
);
|
|
const lockButton = await driver.findClickableElement(
|
|
'[data-testid="global-menu-lock"]',
|
|
);
|
|
assert.equal(await lockButton.getText(), 'Lock MetaMask');
|
|
await lockButton.click();
|
|
|
|
// accepts the account password after lock
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
// Create a new account
|
|
// switches to localhost
|
|
await driver.delay(largeDelayMs);
|
|
await driver.clickElement('[data-testid="network-display"]');
|
|
await driver.clickElement('.toggle-button');
|
|
await driver.clickElement({ text: 'Localhost', tag: 'span' });
|
|
|
|
// choose Create account from the account menu
|
|
await driver.clickElement('[data-testid="account-menu-icon"]');
|
|
await driver.clickElement({ text: 'Add account', tag: 'button' });
|
|
|
|
// set account name
|
|
await driver.fill('.new-account-create-form input', '2nd account');
|
|
await driver.delay(regularDelayMs);
|
|
await driver.clickElement({ text: 'Create', tag: 'button' });
|
|
|
|
// should show the correct account name
|
|
const accountName = await driver.isElementPresent({
|
|
tag: 'span',
|
|
text: '2nd account',
|
|
});
|
|
|
|
assert.equal(accountName, true, 'Account name is not correct');
|
|
|
|
// Switch back to original account
|
|
// chooses the original account from the account menu
|
|
await driver.clickElement('[data-testid="account-menu-icon"]');
|
|
await driver.clickElement(
|
|
'.multichain-account-list-item__account-name__button',
|
|
);
|
|
|
|
// Send ETH from inside MetaMask
|
|
// starts a send transaction
|
|
await driver.clickElement('[data-testid="eth-overview-send"]');
|
|
await driver.fill(
|
|
'input[placeholder="Search, public address (0x), or ENS"]',
|
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
|
);
|
|
await driver.fill('.unit-input__input', '1');
|
|
|
|
// Continue to next screen
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
|
|
|
// confirms the transaction
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
|
|
// finds the transaction in the transactions list
|
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
|
await driver.wait(async () => {
|
|
const confirmedTxes = await driver.findElements(
|
|
'.transaction-list__completed-transactions .transaction-list-item',
|
|
);
|
|
return confirmedTxes.length === 1;
|
|
}, 10000);
|
|
|
|
const txValues = await driver.findElements(
|
|
'.transaction-list-item__primary-currency',
|
|
);
|
|
assert.equal(txValues.length, 1);
|
|
assert.ok(/-1\s*ETH/u.test(await txValues[0].getText()));
|
|
},
|
|
);
|
|
});
|
|
|
|
it('Importing wallet using Secret Recovery Phrase with pasting word by word', async function () {
|
|
const testPassword = 'correct horse battery staple';
|
|
const testAddress = '0x0Cc5261AB8cE458dc977078A3623E2BaDD27afD3';
|
|
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder({ onboarding: true }).build(),
|
|
ganacheOptions,
|
|
title: this.test.title,
|
|
failOnConsoleError: false,
|
|
},
|
|
async ({ driver }) => {
|
|
await driver.navigate();
|
|
|
|
await completeImportSRPOnboardingFlowWordByWord(
|
|
driver,
|
|
TEST_SEED_PHRASE,
|
|
testPassword,
|
|
);
|
|
|
|
// Show account information
|
|
await driver.clickElement('[data-testid="account-menu-icon"]');
|
|
await driver.clickElement(
|
|
'[data-testid="account-list-item-menu-button"]',
|
|
);
|
|
await driver.clickElement('[data-testid="account-list-menu-details"');
|
|
await driver.findVisibleElement('.qr-code__wrapper');
|
|
// shows the correct account address
|
|
const address = await driver.findElement(
|
|
'.qr-code [data-testid="address-copy-button-text"]',
|
|
);
|
|
|
|
assert.equal(await address.getText(), testAddress);
|
|
},
|
|
);
|
|
});
|
|
|
|
it('Import Account using private key', async function () {
|
|
const testPrivateKey1 =
|
|
'14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6';
|
|
const testPrivateKey2 =
|
|
'F4EC2590A0C10DE95FBF4547845178910E40F5035320C516A18C117DE02B5669';
|
|
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder()
|
|
.withKeyringControllerImportedAccountVault()
|
|
.withPreferencesControllerImportedAccountIdentities()
|
|
.build(),
|
|
ganacheOptions,
|
|
title: this.test.title,
|
|
},
|
|
async ({ driver }) => {
|
|
await driver.navigate();
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
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({ text: 'Import account', tag: 'button' });
|
|
|
|
// enter private key',
|
|
await driver.delay(regularDelayMs);
|
|
await driver.fill('#private-key-box', testPrivateKey1);
|
|
await driver.delay(regularDelayMs);
|
|
await driver.clickElement({ text: 'Import', tag: 'button' });
|
|
|
|
// should show the correct account name
|
|
const importedAccountName = await driver.findElement(
|
|
'[data-testid="account-menu-icon"]',
|
|
);
|
|
assert.equal(await importedAccountName.getText(), 'Account 4');
|
|
|
|
// should show the imported label
|
|
// confirm 4th account is account 4, as expected
|
|
const accountMenuItemSelector = await findAnotherAccountFromAccountList(
|
|
driver,
|
|
4,
|
|
'Account 4',
|
|
);
|
|
// confirm label is present on the same menu item
|
|
const importedLabel = await driver.findElement(
|
|
`${accountMenuItemSelector} .mm-tag`,
|
|
);
|
|
assert.equal(await importedLabel.getText(), 'Imported');
|
|
|
|
// Imports and removes an account
|
|
// choose Create account from the account menu
|
|
await driver.clickElement({ text: 'Import account', tag: 'button' });
|
|
// enter private key
|
|
await driver.fill('#private-key-box', testPrivateKey2);
|
|
await driver.clickElement({ text: 'Import', tag: 'button' });
|
|
|
|
// should see new account in account menu
|
|
const importedAccount2Name = await driver.findElement(
|
|
'[data-testid="account-menu-icon"]',
|
|
);
|
|
assert.equal(await importedAccount2Name.getText(), 'Account 5');
|
|
await driver.clickElement('[data-testid="account-menu-icon"]');
|
|
const accountListItems = await driver.findElements(
|
|
'.multichain-account-list-item',
|
|
);
|
|
assert.equal(accountListItems.length, 5);
|
|
|
|
await driver.clickElement(
|
|
'.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]',
|
|
);
|
|
|
|
await driver.clickElement('[data-testid="account-list-menu-remove"]');
|
|
|
|
// should remove the account
|
|
await driver.clickElement({ text: 'Remove', tag: 'button' });
|
|
|
|
// Wait until selected account switches away from removed account to first account
|
|
await driver.waitForSelector({
|
|
css: '[data-testid="account-menu-icon"]',
|
|
text: 'Account 1',
|
|
});
|
|
|
|
await driver.delay(regularDelayMs);
|
|
await driver.clickElement('[data-testid="account-menu-icon"]');
|
|
|
|
const accountListItemsAfterRemoval = await driver.findElements(
|
|
'.multichain-account-list-item',
|
|
);
|
|
assert.equal(accountListItemsAfterRemoval.length, 4);
|
|
},
|
|
);
|
|
});
|
|
|
|
it('Import Account using json file', async function () {
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder()
|
|
.withKeyringControllerImportedAccountVault()
|
|
.withPreferencesControllerImportedAccountIdentities()
|
|
.build(),
|
|
ganacheOptions,
|
|
title: this.test.title,
|
|
},
|
|
async ({ driver }) => {
|
|
await driver.navigate();
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
// Imports an account with JSON file
|
|
await driver.clickElement('[data-testid="account-menu-icon"]');
|
|
await driver.clickElement({ text: 'Import account', tag: 'button' });
|
|
|
|
await driver.clickElement('.dropdown__select');
|
|
await driver.clickElement({ text: 'JSON File', tag: 'option' });
|
|
|
|
const fileInput = await driver.findElement('input[type="file"]');
|
|
const importJsonFile = path.join(
|
|
__dirname,
|
|
'..',
|
|
'import-utc-json',
|
|
'test-json-import-account-file.json',
|
|
);
|
|
|
|
fileInput.sendKeys(importJsonFile);
|
|
|
|
await driver.fill('#json-password-box', 'foobarbazqux');
|
|
|
|
await driver.clickElement({ text: 'Import', tag: 'button' });
|
|
|
|
// should show the correct account name
|
|
const importedAccountName = await driver.findElement(
|
|
'[data-testid="account-menu-icon"]',
|
|
);
|
|
assert.equal(await importedAccountName.getText(), 'Account 4');
|
|
|
|
// should show the imported label
|
|
// confirm 4th account is account 4, as expected
|
|
const accountMenuItemSelector = await findAnotherAccountFromAccountList(
|
|
driver,
|
|
4,
|
|
'Account 4',
|
|
);
|
|
|
|
// confirm label is present on the same menu item
|
|
const importedLabel = await driver.findElement(
|
|
`${accountMenuItemSelector} .mm-tag`,
|
|
);
|
|
assert.equal(await importedLabel.getText(), 'Imported');
|
|
|
|
const accountListItems = await driver.findElements(
|
|
'.multichain-account-list-item',
|
|
);
|
|
assert.equal(accountListItems.length, 4);
|
|
},
|
|
);
|
|
});
|
|
|
|
it('Import Account using private key of an already active account should result in an error', async function () {
|
|
const testPrivateKey =
|
|
'0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9';
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder()
|
|
.withKeyringControllerImportedAccountVault()
|
|
.withPreferencesControllerImportedAccountIdentities()
|
|
.build(),
|
|
ganacheOptions,
|
|
title: this.test.title,
|
|
},
|
|
async ({ driver }) => {
|
|
await driver.navigate();
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
// choose Import Account from the account menu
|
|
await driver.clickElement('[data-testid="account-menu-icon"]');
|
|
await driver.clickElement({ text: 'Import account', tag: 'button' });
|
|
|
|
// enter private key',
|
|
await driver.fill('#private-key-box', testPrivateKey);
|
|
await driver.clickElement({ text: 'Import', tag: 'button' });
|
|
|
|
// error should occur
|
|
await driver.waitForSelector({
|
|
css: '.mm-help-text',
|
|
text: 'The account you are trying to import is a duplicate',
|
|
});
|
|
},
|
|
);
|
|
});
|
|
|
|
if (process.env.ENABLE_MV3) {
|
|
it('Connects to a Hardware wallet for trezor', async function () {
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder().build(),
|
|
ganacheOptions,
|
|
title: this.test.title,
|
|
},
|
|
async ({ driver }) => {
|
|
await driver.navigate();
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
// choose Connect hardware wallet from the account menu
|
|
await driver.clickElement('[data-testid="account-menu-icon"]');
|
|
await driver.clickElement({
|
|
text: 'Hardware wallet',
|
|
tag: 'button',
|
|
});
|
|
await driver.delay(regularDelayMs);
|
|
|
|
// should open the TREZOR Connect popup
|
|
await driver.clickElement('.hw-connect__btn:nth-of-type(2)');
|
|
await driver.delay(largeDelayMs * 2);
|
|
await driver.clickElement({ text: 'Continue', tag: 'button' });
|
|
await driver.waitUntilXWindowHandles(2);
|
|
const allWindows = await driver.getAllWindowHandles();
|
|
assert.equal(allWindows.length, 2);
|
|
},
|
|
);
|
|
});
|
|
}
|
|
});
|