From 7753364958e7e4fdaa887274b370207082ff9682 Mon Sep 17 00:00:00 2001 From: Danica Shen Date: Fri, 26 May 2023 14:05:34 +0100 Subject: [PATCH] feature(17901): disable hardware wallet test with trezor in mv3 (#19287) --- test/e2e/helpers.js | 8 ++ test/e2e/metamask-ui.spec.js | 6 +- test/e2e/tests/add-account.spec.js | 7 +- test/e2e/tests/from-import-ui.spec.js | 129 ++++++------------ test/e2e/tests/metamask-responsive-ui.spec.js | 10 +- test/e2e/tests/onboarding.spec.js | 11 +- 6 files changed, 65 insertions(+), 106 deletions(-) diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 3feb514aa..aaa2d8b16 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -505,10 +505,18 @@ const findAnotherAccountFromAccountList = async ( return accountMenuItemSelector; }; +const TEST_SEED_PHRASE = + 'forum vessel pink push lonely enact gentle tail admit parrot grunt dress'; + +const TEST_SEED_PHRASE_TWO = + 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'; + module.exports = { DAPP_URL, DAPP_ONE_URL, SERVICE_WORKER_URL, + TEST_SEED_PHRASE, + TEST_SEED_PHRASE_TWO, getWindowHandles, convertToHexValue, tinyDelayMs, diff --git a/test/e2e/metamask-ui.spec.js b/test/e2e/metamask-ui.spec.js index 4182dd6f2..572e09076 100644 --- a/test/e2e/metamask-ui.spec.js +++ b/test/e2e/metamask-ui.spec.js @@ -4,6 +4,7 @@ const path = require('path'); const enLocaleMessages = require('../../app/_locales/en/messages.json'); const createStaticServer = require('../../development/create-static-server'); const { + TEST_SEED_PHRASE_TWO, tinyDelayMs, regularDelayMs, largeDelayMs, @@ -21,9 +22,6 @@ describe('MetaMask', function () { let dappServer; let tokenAddress; - const testSeedPhrase = - 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'; - this.bail(true); let failed = false; @@ -151,7 +149,7 @@ describe('MetaMask', function () { await driver.pasteIntoField( '[data-testid="import-srp__srp-word-0"]', - testSeedPhrase, + TEST_SEED_PHRASE_TWO, ); await driver.fill('#password', 'correct horse battery staple'); diff --git a/test/e2e/tests/add-account.spec.js b/test/e2e/tests/add-account.spec.js index 6802ce9c6..4b74e61b4 100644 --- a/test/e2e/tests/add-account.spec.js +++ b/test/e2e/tests/add-account.spec.js @@ -1,5 +1,6 @@ const { strict: assert } = require('assert'); const { + TEST_SEED_PHRASE, convertToHexValue, withFixtures, regularDelayMs, @@ -11,8 +12,6 @@ const enLocaleMessages = require('../../../app/_locales/en/messages.json'); const FixtureBuilder = require('../fixture-builder'); describe('Add account', function () { - const testSeedPhrase = - 'forum vessel pink push lonely enact gentle tail admit parrot grunt dress'; const testPassword = 'correct horse battery staple'; const ganacheOptions = { accounts: [ @@ -66,7 +65,7 @@ describe('Add account', function () { // On boarding with 1st account await completeImportSRPOnboardingFlow( driver, - testSeedPhrase, + TEST_SEED_PHRASE, testPassword, ); @@ -116,7 +115,7 @@ describe('Add account', function () { await driver.pasteIntoField( '[data-testid="import-srp__srp-word-0"]', - testSeedPhrase, + TEST_SEED_PHRASE, ); await driver.fill('#password', 'correct horse battery staple'); diff --git a/test/e2e/tests/from-import-ui.spec.js b/test/e2e/tests/from-import-ui.spec.js index 38453daec..e0966999d 100644 --- a/test/e2e/tests/from-import-ui.spec.js +++ b/test/e2e/tests/from-import-ui.spec.js @@ -1,6 +1,7 @@ const { strict: assert } = require('assert'); const path = require('path'); const { + TEST_SEED_PHRASE, convertToHexValue, withFixtures, regularDelayMs, @@ -11,19 +12,18 @@ const { } = 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 ganacheOptions = { - accounts: [ - { - secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', - balance: convertToHexValue(25000000000000000000), - }, - ], - }; - const testSeedPhrase = - 'forum vessel pink push lonely enact gentle tail admit parrot grunt dress'; const testPassword = 'correct horse battery staple'; const testAddress = '0x0Cc5261AB8cE458dc977078A3623E2BaDD27afD3'; @@ -39,7 +39,7 @@ describe('MetaMask Import UI', function () { await completeImportSRPOnboardingFlow( driver, - testSeedPhrase, + TEST_SEED_PHRASE, testPassword, ); @@ -131,17 +131,6 @@ describe('MetaMask Import UI', function () { }); it('Importing wallet using Secret Recovery Phrase with pasting word by word', async function () { - const ganacheOptions = { - accounts: [ - { - secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', - balance: convertToHexValue(25000000000000000000), - }, - ], - }; - const testSeedPhrase = - 'forum vessel pink push lonely enact gentle tail admit parrot grunt dress'; const testPassword = 'correct horse battery staple'; const testAddress = '0x0Cc5261AB8cE458dc977078A3623E2BaDD27afD3'; @@ -157,7 +146,7 @@ describe('MetaMask Import UI', function () { await completeImportSRPOnboardingFlowWordByWord( driver, - testSeedPhrase, + TEST_SEED_PHRASE, testPassword, ); @@ -178,15 +167,6 @@ describe('MetaMask Import UI', function () { }); it('Import Account using private key', async function () { - const ganacheOptions = { - accounts: [ - { - secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', - balance: convertToHexValue(25000000000000000000), - }, - ], - }; const testPrivateKey1 = '14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6'; const testPrivateKey2 = @@ -284,16 +264,6 @@ describe('MetaMask Import UI', function () { }); it('Import Account using json file', async function () { - const ganacheOptions = { - accounts: [ - { - secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', - balance: convertToHexValue(25000000000000000000), - }, - ], - }; - await withFixtures( { fixtures: new FixtureBuilder() @@ -360,15 +330,6 @@ describe('MetaMask Import UI', function () { it('Import Account using private key of an already active account should result in an error', async function () { const testPrivateKey = '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9'; - const ganacheOptions = { - accounts: [ - { - secretKey: testPrivateKey, - balance: convertToHexValue(25000000000000000000), - }, - ], - }; - await withFixtures( { fixtures: new FixtureBuilder() @@ -400,44 +361,36 @@ describe('MetaMask Import UI', function () { ); }); - it('Connects to a Hardware wallet', async function () { - const ganacheOptions = { - accounts: [ + if (process.env.ENABLE_MV3) { + it('Connects to a Hardware wallet for trezor', async function () { + await withFixtures( { - secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', - balance: convertToHexValue(25000000000000000000), + 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); - 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('.account-menu__icon'); + await driver.clickElement({ + text: 'Connect hardware wallet', + tag: 'div', + }); + await driver.delay(regularDelayMs); - // choose Connect hardware wallet from the account menu - await driver.clickElement('.account-menu__icon'); - await driver.clickElement({ - text: 'Connect hardware wallet', - tag: 'div', - }); - 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); - }, - ); - }); + // 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); + }, + ); + }); + } }); diff --git a/test/e2e/tests/metamask-responsive-ui.spec.js b/test/e2e/tests/metamask-responsive-ui.spec.js index 66b1a9cfc..fe2ae4c1a 100644 --- a/test/e2e/tests/metamask-responsive-ui.spec.js +++ b/test/e2e/tests/metamask-responsive-ui.spec.js @@ -1,5 +1,9 @@ const { strict: assert } = require('assert'); -const { convertToHexValue, withFixtures } = require('../helpers'); +const { + TEST_SEED_PHRASE_TWO, + convertToHexValue, + withFixtures, +} = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); describe('MetaMask Responsive UI', function () { @@ -76,8 +80,6 @@ describe('MetaMask Responsive UI', function () { it('Importing existing wallet from lock page', async function () { const driverOptions = { openDevToolsForTabs: true }; - const testSeedPhrase = - 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'; await withFixtures( { @@ -98,7 +100,7 @@ describe('MetaMask Responsive UI', function () { await driver.pasteIntoField( '[data-testid="import-srp__srp-word-0"]', - testSeedPhrase, + TEST_SEED_PHRASE_TWO, ); await driver.fill('#password', 'correct horse battery staple'); diff --git a/test/e2e/tests/onboarding.spec.js b/test/e2e/tests/onboarding.spec.js index 260857ce9..a585d4896 100644 --- a/test/e2e/tests/onboarding.spec.js +++ b/test/e2e/tests/onboarding.spec.js @@ -1,6 +1,7 @@ const { strict: assert } = require('assert'); const { By } = require('selenium-webdriver'); const { + TEST_SEED_PHRASE, convertToHexValue, withFixtures, completeCreateNewWalletOnboardingFlow, @@ -12,8 +13,6 @@ const { const FixtureBuilder = require('../fixture-builder'); describe('MetaMask onboarding', function () { - const testSeedPhrase = - 'forum vessel pink push lonely enact gentle tail admit parrot grunt dress'; const testPassword = 'correct horse battery staple'; const wrongSeedPhrase = 'test test test test test test test test test test test test'; @@ -63,7 +62,7 @@ describe('MetaMask onboarding', function () { await completeImportSRPOnboardingFlow( driver, - testSeedPhrase, + TEST_SEED_PHRASE, testPassword, ); @@ -164,7 +163,7 @@ describe('MetaMask onboarding', function () { // 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' }, + { text: "Passwords don't match", tag: 'h6' }, true, ); @@ -188,7 +187,7 @@ describe('MetaMask onboarding', function () { async ({ driver }) => { await driver.navigate(); - await importSRPOnboardingFlow(driver, testSeedPhrase, testPassword); + await importSRPOnboardingFlow(driver, TEST_SEED_PHRASE, testPassword); // Verify site assert.equal( await driver.isElementPresent({ @@ -267,7 +266,7 @@ describe('MetaMask onboarding', function () { async ({ driver, secondaryGanacheServer }) => { await driver.navigate(); - await importSRPOnboardingFlow(driver, testSeedPhrase, testPassword); + await importSRPOnboardingFlow(driver, TEST_SEED_PHRASE, testPassword); // Add custome network localhost 8546 during onboarding await driver.clickElement({ text: 'Advanced configuration', tag: 'a' });