1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00
metamask-extension/test/e2e/tests/onboarding.spec.js

314 lines
10 KiB
JavaScript
Raw Normal View History

const { strict: assert } = require('assert');
const { By } = require('selenium-webdriver');
const {
TEST_SEED_PHRASE,
convertToHexValue,
withFixtures,
completeCreateNewWalletOnboardingFlow,
completeImportSRPOnboardingFlow,
importSRPOnboardingFlow,
importWrongSRPOnboardingFlow,
testSRPDropdownIterations,
assertAccountBalanceForDOM,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('MetaMask onboarding', function () {
const testPassword = 'correct horse battery staple';
const wrongSeedPhrase =
'test test test test test test test test test test test test';
const wrongTestPassword = 'test test test test';
const ganacheOptions = {
accounts: [
{
secretKey:
'0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9',
balance: convertToHexValue(25000000000000000000),
},
],
};
it('Clicks create a new wallet, accepts a secure password, reveals the Secret Recovery Phrase, confirm SRP', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder({ onboarding: true }).build(),
ganacheOptions,
title: this.test.title,
failOnConsoleError: false,
},
async ({ driver }) => {
await driver.navigate();
await completeCreateNewWalletOnboardingFlow(driver, testPassword);
const homePage = await driver.findElement('.home__main-view');
const homePageDisplayed = await homePage.isDisplayed();
assert.equal(homePageDisplayed, true);
},
);
});
it('Clicks import a new wallet, accepts a secure password, reveals the Secret Recovery Phrase, confirm SRP', async function () {
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,
);
const homePage = await driver.findElement('.home__main-view');
const homePageDisplayed = await homePage.isDisplayed();
assert.equal(homePageDisplayed, true);
},
);
});
it('User import wrong Secret Recovery Phrase', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder({ onboarding: true }).build(),
ganacheOptions,
title: this.test.title,
failOnConsoleError: false,
},
async ({ driver }) => {
await driver.navigate();
await importWrongSRPOnboardingFlow(driver, wrongSeedPhrase);
const confirmSeedPhrase = await driver.findElement(
'[data-testid="import-srp-confirm"]',
);
assert.equal(await confirmSeedPhrase.isEnabled(), false);
},
);
});
it('Check if user select different type of secret recovery phrase', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder({ onboarding: true }).build(),
ganacheOptions,
title: this.test.title,
failOnConsoleError: false,
},
async ({ driver }) => {
await driver.navigate();
// accept terms of use
await driver.clickElement('[data-testid="onboarding-terms-checkbox"]');
// welcome
await driver.clickElement('[data-testid="onboarding-import-wallet"]');
await driver.clickElement('[data-testid="metametrics-no-thanks"]');
const dropdowns = await driver.findElements('select');
const dropdownElement = dropdowns[1];
await dropdownElement.click();
const options = await dropdownElement.findElements(
By.tagName('option'),
);
const iterations = options.length;
await testSRPDropdownIterations(options, driver, iterations);
const finalFormFields = await driver.findElements(
'.import-srp__srp-word-label',
);
const expectedFinalNumFields = 24; // The last iteration will have 24 fields
const actualFinalNumFields = finalFormFields.length;
assert.equal(actualFinalNumFields, expectedFinalNumFields);
},
);
});
it('User enters the wrong password during password creation', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder({ onboarding: true }).build(),
ganacheOptions,
title: this.test.title,
failOnConsoleError: false,
},
async ({ driver }) => {
await driver.navigate();
await driver.clickElement('[data-testid="onboarding-terms-checkbox"]');
await driver.clickElement('[data-testid="onboarding-create-wallet"]');
// metrics
await driver.clickElement('[data-testid="metametrics-no-thanks"]');
// Fill in confirm password field with incorrect password
await driver.fill('[data-testid="create-password-new"]', testPassword);
await driver.fill(
'[data-testid="create-password-confirm"]',
wrongTestPassword,
);
// Check that the error message is displayed for the password fields
await driver.isElementPresent(
// eslint-disable-next-line prettier/prettier
{ text: "Passwords don't match", tag: 'h6' },
true,
);
// Check that the "Confirm Password" button is disabled
const confirmPasswordButton = await driver.findElement(
'[data-testid="create-password-wallet"]',
);
assert.equal(await confirmPasswordButton.isEnabled(), false);
},
);
});
it('Verify that the user has been redirected to the correct page after importing their wallet', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder({ onboarding: true }).build(),
ganacheOptions,
title: this.test.title,
failOnConsoleError: false,
},
async ({ driver }) => {
await driver.navigate();
await importSRPOnboardingFlow(driver, TEST_SEED_PHRASE, testPassword);
// Verify site
assert.equal(
await driver.isElementPresent({
text: 'Wallet creation successful',
tag: 'h2',
}),
true,
);
},
);
});
it('Verify that the user has been redirected to the correct page after creating a password for their new wallet', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder({ onboarding: true }).build(),
ganacheOptions,
title: this.test.title,
failOnConsoleError: false,
},
async ({ driver }) => {
await driver.navigate();
await driver.clickElement('[data-testid="onboarding-terms-checkbox"]');
await driver.clickElement('[data-testid="onboarding-create-wallet"]');
// metrics
await driver.clickElement('[data-testid="metametrics-no-thanks"]');
// Fill in confirm password field with correct password
await driver.fill('[data-testid="create-password-new"]', testPassword);
await driver.fill(
'[data-testid="create-password-confirm"]',
testPassword,
);
await driver.clickElement('[data-testid="create-password-terms"]');
await driver.clickElement('[data-testid="create-password-wallet"]');
// Verify site
assert.equal(
await driver.isElementPresent({
text: 'Secure your wallet',
tag: 'h2',
}),
true,
);
},
);
});
const ganacheOptions2 = {
accounts: [
{
secretKey:
'0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9',
balance: convertToHexValue(10000000000000000000),
},
],
};
it(`User can add custom network during onboarding`, async function () {
const networkName = 'Localhost 8546';
const networkUrl = 'http://127.0.0.1:8546';
const currencySymbol = 'ETH';
const port = 8546;
const chainId = 1338;
await withFixtures(
{
fixtures: new FixtureBuilder({ onboarding: true }).build(),
ganacheOptions: {
...ganacheOptions,
concurrent: { port, chainId, ganacheOptions2 },
},
title: this.test.title,
},
async ({ driver, secondaryGanacheServer }) => {
await driver.navigate();
await importSRPOnboardingFlow(driver, TEST_SEED_PHRASE, testPassword);
// Add custome network localhost 8546 during onboarding
await driver.clickElement({ text: 'Advanced configuration', tag: 'a' });
Release MultiChain 0.5 (#18903) * 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 15598f2a23d936d3c468a1b8849ec3baaccee4cd. * 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>
2023-06-01 23:14:38 +02:00
await driver.clickElement('.mm-picker-network');
await driver.clickElement({
Release MultiChain 0.5 (#18903) * 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 15598f2a23d936d3c468a1b8849ec3baaccee4cd. * 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>
2023-06-01 23:14:38 +02:00
text: 'Add network',
tag: 'button',
});
const [
networkNameField,
networkUrlField,
chainIdField,
currencySymbolField,
] = await driver.findElements('input[type="text"]');
await networkNameField.sendKeys(networkName);
await networkUrlField.sendKeys(networkUrl);
await chainIdField.sendKeys(chainId.toString());
await currencySymbolField.sendKeys(currencySymbol);
await driver.clickElement({ text: 'Save', tag: 'button' });
await driver.waitForElementNotPresent('span .modal');
await driver.clickElement({ text: 'Done', tag: 'button' });
// After login, check that notification message for added network is displayed
const notificationMessage = `${networkName}” was successfully added!`;
const networkNotification = await driver.isElementPresent({
css: '[class*="actionable-message__message"]',
text: notificationMessage,
});
assert.equal(networkNotification, true);
// Check localhost 8546 is selected and its balance value is correct
await driver.findElement({
css: '[data-testid="network-display"]',
text: networkName,
});
await assertAccountBalanceForDOM(driver, secondaryGanacheServer);
},
);
});
});