From 10097b6a1140d87aef0d8b982115dd6dba90dbe1 Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Thu, 28 Mar 2019 13:34:31 -0230 Subject: [PATCH] Default to localhost network when running e2e tests --- app/scripts/controllers/network/network.js | 12 ++++++++++-- gulpfile.js | 7 +++++-- test/e2e/beta/metamask-beta-ui.spec.js | 10 ---------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index 0c6327f6e..47432c1e2 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -25,10 +25,18 @@ const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET] const env = process.env.METAMASK_ENV const METAMASK_DEBUG = process.env.METAMASK_DEBUG -const testMode = (METAMASK_DEBUG || env === 'test') + +let defaultProviderConfigType +if (process.env.IN_TEST === 'true') { + defaultProviderConfigType = LOCALHOST +} else if (METAMASK_DEBUG || env === 'test') { + defaultProviderConfigType = RINKEBY +} else { + defaultProviderConfigType = MAINNET +} const defaultProviderConfig = { - type: testMode ? RINKEBY : MAINNET, + type: defaultProviderConfigType, } const defaultNetworkConfig = { diff --git a/gulpfile.js b/gulpfile.js index f4c9fc9dd..57d20c54a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -311,6 +311,7 @@ const buildJsFiles = [ // bundle tasks createTasksForBuildJsUIDeps({ dependenciesToBundle: uiDependenciesToBundle, filename: 'libs' }) createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'dev:extension:js', devMode: true }) +createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'dev:test-extension:js', devMode: true, testing: 'true' }) createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'build:extension:js' }) function createTasksForBuildJsUIDeps ({ dependenciesToBundle, filename }) { @@ -334,7 +335,7 @@ function createTasksForBuildJsUIDeps ({ dependenciesToBundle, filename }) { } -function createTasksForBuildJsExtension ({ buildJsFiles, taskPrefix, devMode, bundleTaskOpts = {} }) { +function createTasksForBuildJsExtension ({ buildJsFiles, taskPrefix, devMode, testing, bundleTaskOpts = {} }) { // inpage must be built before all other scripts: const rootDir = './app/scripts' const nonInpageFiles = buildJsFiles.filter(file => file !== 'inpage') @@ -348,6 +349,7 @@ function createTasksForBuildJsExtension ({ buildJsFiles, taskPrefix, devMode, bu buildWithFullPaths: devMode, watch: devMode, devMode, + testing, }, bundleTaskOpts) createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinations, buildPhase1, buildPhase2 }) } @@ -412,7 +414,7 @@ gulp.task('dev:test', 'clean', 'dev:scss', gulp.parallel( - 'dev:extension:js', + 'dev:test-extension:js', 'test:copy', 'dev:reload' ) @@ -496,6 +498,7 @@ function generateBundler (opts, performBundle) { bundler.transform(envify({ METAMASK_DEBUG: opts.devMode, NODE_ENV: opts.devMode ? 'development' : 'production', + IN_TEST: opts.testing, PUBNUB_SUB_KEY: process.env.PUBNUB_SUB_KEY || '', PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '', }), { diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index 202a0052d..0c9c59e55 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -329,16 +329,6 @@ describe('MetaMask', function () { await delay(regularDelayMs) }) - it('switches to localhost', async () => { - const networkDropdown = await findElement(driver, By.css('.network-name')) - await networkDropdown.click() - await delay(regularDelayMs) - - const [localhost] = await findElements(driver, By.xpath(`//span[contains(text(), 'Localhost')]`)) - await localhost.click() - await delay(largeDelayMs * 2) - }) - it('balance renders', async () => { const balance = await findElement(driver, By.css('.balance-display .token-amount')) await driver.wait(until.elementTextMatches(balance, /100\s*ETH/))