From dd4e684f7d41643ac7a510f2740697c64cedda09 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Tue, 14 Jan 2020 13:34:38 -0400 Subject: [PATCH] Consolidate webdriver initialization (#7814) The webdriver is now instantiated directly by the webdriver module, rather than via a helper method. --- test/e2e/address-book.spec.js | 4 ++-- test/e2e/ethereum-on.spec.js | 4 ++-- test/e2e/from-import-ui.spec.js | 4 ++-- test/e2e/helpers.js | 11 ----------- test/e2e/incremental-security.spec.js | 4 ++-- test/e2e/metamask-responsive-ui.spec.js | 4 ++-- test/e2e/metamask-ui.spec.js | 4 ++-- test/e2e/permissions.spec.js | 4 ++-- test/e2e/send-edit.spec.js | 4 ++-- test/e2e/signature-request.spec.js | 4 ++-- test/e2e/threebox.spec.js | 6 +++--- test/e2e/web3.spec.js | 4 ++-- test/e2e/webdriver/index.js | 5 ++++- 13 files changed, 27 insertions(+), 35 deletions(-) diff --git a/test/e2e/address-book.spec.js b/test/e2e/address-book.spec.js index fc1738ebe..d3cadf169 100644 --- a/test/e2e/address-book.spec.js +++ b/test/e2e/address-book.spec.js @@ -2,11 +2,11 @@ const assert = require('assert') const { By, until } = require('selenium-webdriver') const { - prepareExtensionForTesting, tinyDelayMs, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const Ganache = require('./ganache') const enLocaleMessages = require('../../app/_locales/en/messages.json') @@ -29,7 +29,7 @@ describe('MetaMask', function () { }, ], }) - const result = await prepareExtensionForTesting() + const result = await buildWebDriver() driver = result.driver }) diff --git a/test/e2e/ethereum-on.spec.js b/test/e2e/ethereum-on.spec.js index 3955d5993..41a5f5c22 100644 --- a/test/e2e/ethereum-on.spec.js +++ b/test/e2e/ethereum-on.spec.js @@ -3,10 +3,10 @@ const webdriver = require('selenium-webdriver') const { By, until } = webdriver const { - prepareExtensionForTesting, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const Ganache = require('./ganache') const enLocaleMessages = require('../../app/_locales/en/messages.json') @@ -28,7 +28,7 @@ describe('MetaMask', function () { }, ], }) - const result = await prepareExtensionForTesting() + const result = await buildWebDriver() driver = result.driver }) diff --git a/test/e2e/from-import-ui.spec.js b/test/e2e/from-import-ui.spec.js index 3d742785f..3f1b68e73 100644 --- a/test/e2e/from-import-ui.spec.js +++ b/test/e2e/from-import-ui.spec.js @@ -3,11 +3,11 @@ const webdriver = require('selenium-webdriver') const { By, Key, until } = webdriver const { - prepareExtensionForTesting, tinyDelayMs, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const Ganache = require('./ganache') const enLocaleMessages = require('../../app/_locales/en/messages.json') @@ -33,7 +33,7 @@ describe('Using MetaMask with an existing account', function () { }, ], }) - const result = await prepareExtensionForTesting() + const result = await buildWebDriver() driver = result.driver }) diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 6ab427e6d..08dc1c97b 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -1,20 +1,9 @@ -const { buildWebDriver } = require('./webdriver') - const tinyDelayMs = 200 const regularDelayMs = tinyDelayMs * 2 const largeDelayMs = regularDelayMs * 2 module.exports = { - prepareExtensionForTesting, tinyDelayMs, regularDelayMs, largeDelayMs, } - -async function prepareExtensionForTesting ({ responsive, port } = {}) { - const browser = process.env.SELENIUM_BROWSER - const extensionPath = `dist/${browser}` - const { driver, extensionId, extensionUrl } = await buildWebDriver({ browser, extensionPath, responsive, port }) - - return { driver, extensionId, extensionUrl } -} diff --git a/test/e2e/incremental-security.spec.js b/test/e2e/incremental-security.spec.js index 811040452..0b75653c2 100644 --- a/test/e2e/incremental-security.spec.js +++ b/test/e2e/incremental-security.spec.js @@ -3,11 +3,11 @@ const webdriver = require('selenium-webdriver') const { By, until } = webdriver const { - prepareExtensionForTesting, tinyDelayMs, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const Ganache = require('./ganache') const enLocaleMessages = require('../../app/_locales/en/messages.json') @@ -33,7 +33,7 @@ describe('MetaMask', function () { }, ], }) - const result = await prepareExtensionForTesting() + const result = await buildWebDriver() driver = result.driver }) diff --git a/test/e2e/metamask-responsive-ui.spec.js b/test/e2e/metamask-responsive-ui.spec.js index 2e8d74f36..d014011a2 100644 --- a/test/e2e/metamask-responsive-ui.spec.js +++ b/test/e2e/metamask-responsive-ui.spec.js @@ -3,11 +3,11 @@ const webdriver = require('selenium-webdriver') const { By, until } = webdriver const { - prepareExtensionForTesting, tinyDelayMs, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const Ganache = require('./ganache') const enLocaleMessages = require('../../app/_locales/en/messages.json') @@ -23,7 +23,7 @@ describe('MetaMask', function () { before(async function () { await ganacheServer.start() - const result = await prepareExtensionForTesting({ responsive: true }) + const result = await buildWebDriver({ responsive: true }) driver = result.driver }) diff --git a/test/e2e/metamask-ui.spec.js b/test/e2e/metamask-ui.spec.js index 02184d0fd..5230a9d1c 100644 --- a/test/e2e/metamask-ui.spec.js +++ b/test/e2e/metamask-ui.spec.js @@ -3,11 +3,11 @@ const webdriver = require('selenium-webdriver') const { By, Key, until } = webdriver const { - prepareExtensionForTesting, tinyDelayMs, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const Ganache = require('./ganache') const enLocaleMessages = require('../../app/_locales/en/messages.json') @@ -24,7 +24,7 @@ describe('MetaMask', function () { before(async function () { await ganacheServer.start() - const result = await prepareExtensionForTesting() + const result = await buildWebDriver() driver = result.driver }) diff --git a/test/e2e/permissions.spec.js b/test/e2e/permissions.spec.js index 95b19709d..bb15dfab6 100644 --- a/test/e2e/permissions.spec.js +++ b/test/e2e/permissions.spec.js @@ -3,10 +3,10 @@ const webdriver = require('selenium-webdriver') const { By, until } = webdriver const { - prepareExtensionForTesting, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const Ganache = require('./ganache') const enLocaleMessages = require('../../app/_locales/en/messages.json') @@ -28,7 +28,7 @@ describe('MetaMask', function () { }, ], }) - const result = await prepareExtensionForTesting() + const result = await buildWebDriver() driver = result.driver }) diff --git a/test/e2e/send-edit.spec.js b/test/e2e/send-edit.spec.js index df0d03acf..6bad4494d 100644 --- a/test/e2e/send-edit.spec.js +++ b/test/e2e/send-edit.spec.js @@ -3,11 +3,11 @@ const webdriver = require('selenium-webdriver') const { By, Key, until } = webdriver const { - prepareExtensionForTesting, tinyDelayMs, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const Ganache = require('./ganache') const enLocaleMessages = require('../../app/_locales/en/messages.json') @@ -30,7 +30,7 @@ describe('Using MetaMask with an existing account', function () { }, ], }) - const result = await prepareExtensionForTesting() + const result = await buildWebDriver() driver = result.driver }) diff --git a/test/e2e/signature-request.spec.js b/test/e2e/signature-request.spec.js index 7a05f6bec..f401d8aae 100644 --- a/test/e2e/signature-request.spec.js +++ b/test/e2e/signature-request.spec.js @@ -4,10 +4,10 @@ const webdriver = require('selenium-webdriver') const { By, Key, until } = webdriver const { - prepareExtensionForTesting, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const Ganache = require('./ganache') const FixtureServer = require('./fixture-server') @@ -27,7 +27,7 @@ describe('MetaMask', function () { await fixtureServer.start() await fixtureServer.loadState(path.join(__dirname, 'fixtures', 'imported-account')) publicAddress = '0x5cfe73b6021e818b776b421b1c4db2474086a7e1' - const result = await prepareExtensionForTesting() + const result = await buildWebDriver() driver = result.driver }) diff --git a/test/e2e/threebox.spec.js b/test/e2e/threebox.spec.js index a6194e013..a9599f887 100644 --- a/test/e2e/threebox.spec.js +++ b/test/e2e/threebox.spec.js @@ -4,11 +4,11 @@ const getPort = require('get-port') const { By, until } = webdriver const { - prepareExtensionForTesting, tinyDelayMs, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const Ganache = require('./ganache') const enLocaleMessages = require('../../app/_locales/en/messages.json') @@ -31,7 +31,7 @@ describe('MetaMask', function () { }, ], }) - const result = await prepareExtensionForTesting({ port: await getPort() }) + const result = await buildWebDriver({ port: await getPort() }) driver = result.driver }) @@ -171,7 +171,7 @@ describe('MetaMask', function () { let driver2 before(async function () { - const result = await prepareExtensionForTesting({ port: await getPort() }) + const result = await buildWebDriver({ port: await getPort() }) driver2 = result.driver }) diff --git a/test/e2e/web3.spec.js b/test/e2e/web3.spec.js index 6fb6027d4..b7704e463 100644 --- a/test/e2e/web3.spec.js +++ b/test/e2e/web3.spec.js @@ -3,10 +3,10 @@ const webdriver = require('selenium-webdriver') const { By } = webdriver const { - prepareExtensionForTesting, regularDelayMs, largeDelayMs, } = require('./helpers') +const { buildWebDriver } = require('./webdriver') const enLocaleMessages = require('../../app/_locales/en/messages.json') describe('Using MetaMask with an existing account', function () { @@ -30,7 +30,7 @@ describe('Using MetaMask with an existing account', function () { this.bail(true) before(async function () { - const result = await prepareExtensionForTesting() + const result = await buildWebDriver() driver = result.driver }) diff --git a/test/e2e/webdriver/index.js b/test/e2e/webdriver/index.js index 66e0403cf..17c3b2744 100644 --- a/test/e2e/webdriver/index.js +++ b/test/e2e/webdriver/index.js @@ -4,7 +4,10 @@ const ChromeDriver = require('./chrome') const FirefoxDriver = require('./firefox') const fetchMockResponses = require('../../data/fetch-mocks.json') -async function buildWebDriver ({ browser, extensionPath, responsive, port }) { +async function buildWebDriver ({ responsive, port } = {}) { + const browser = process.env.SELENIUM_BROWSER + const extensionPath = `dist/${browser}` + switch (browser) { case Browser.CHROME: { const { driver, extensionId, extensionUrl } = await ChromeDriver.build({ extensionPath, responsive, port })