1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

test - e2e - inject metamask config to point at localhost

This commit is contained in:
kumavis 2018-06-11 11:04:28 -07:00
parent 0db776c3cc
commit 02f5502e16
5 changed files with 61 additions and 23 deletions

3
.gitignore vendored
View File

@ -31,6 +31,7 @@ test/bundle.js
test/test-bundle.js
test-artifacts
test-builds
#ignore css output and sourcemaps
ui/app/css/output/
@ -38,4 +39,4 @@ ui/app/css/output/
notes.txt
.coveralls.yml
.nyc_output
.nyc_output

View File

@ -18,7 +18,7 @@ const migrations = require('./migrations/')
const PortStream = require('./lib/port-stream.js')
const NotificationManager = require('./lib/notification-manager.js')
const MetamaskController = require('./metamask-controller')
const firstTimeState = require('./first-time-state')
const rawFirstTimeState = require('./first-time-state')
const setupRaven = require('./lib/setupRaven')
const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry')
const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics')
@ -31,6 +31,8 @@ const {
ENVIRONMENT_TYPE_FULLSCREEN,
} = require('./lib/enums')
const firstTimeState = Object.assign({}, rawFirstTimeState, global.METAMASK_CONFIG)
const STORAGE_KEY = 'metamask-config'
const METAMASK_DEBUG = process.env.METAMASK_DEBUG

54
package-lock.json generated
View File

@ -10241,15 +10241,25 @@
"dev": true
},
"fs-extra": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
"integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz",
"integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==",
"dev": true,
"requires": {
"graceful-fs": "4.1.11",
"jsonfile": "2.4.0",
"klaw": "1.3.1",
"path-is-absolute": "1.0.1",
"rimraf": "2.6.2"
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
},
"dependencies": {
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.6"
}
}
}
},
"fs-mkdirp-stream": {
@ -11126,6 +11136,18 @@
"yargs": "4.8.1"
},
"dependencies": {
"fs-extra": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
"integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^2.1.0",
"klaw": "^1.0.0",
"path-is-absolute": "^1.0.0",
"rimraf": "^2.2.8"
}
},
"yargs": {
"version": "4.8.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz",
@ -16291,7 +16313,7 @@
"resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz",
"integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=",
"requires": {
"graceful-fs": "4.1.11"
"graceful-fs": "^4.1.9"
}
},
"known-css-properties": {
@ -24426,7 +24448,7 @@
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz",
"integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=",
"requires": {
"os-tmpdir": "1.0.2"
"os-tmpdir": "~1.0.1"
}
}
}
@ -27736,6 +27758,18 @@
"yargs": "4.8.1"
},
"dependencies": {
"fs-extra": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
"integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^2.1.0",
"klaw": "^1.0.0",
"path-is-absolute": "^1.0.0",
"rimraf": "^2.2.8"
}
},
"yargs": {
"version": "4.8.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz",

View File

@ -232,6 +232,7 @@
"eslint-plugin-mocha": "^5.0.0",
"eslint-plugin-react": "^7.4.0",
"file-loader": "^1.1.11",
"fs-extra": "^6.0.1",
"fs-promise": "^2.0.3",
"ganache-cli": "^6.1.0",
"ganache-core": "^2.1.0",
@ -276,6 +277,7 @@
"open": "0.0.5",
"path": "^0.12.7",
"png-file-stream": "^1.0.0",
"prepend-file": "^1.3.1",
"prompt": "^1.0.0",
"proxyquire": "2.0.1",
"qs": "^6.2.0",

View File

@ -1,8 +1,9 @@
const fs = require('fs')
const fs = require('fs-extra')
const mkdirp = require('mkdirp')
const path = require('path')
const assert = require('assert')
const pify = require('pify')
const prependFile = pify(require('prepend-file'))
const webdriver = require('selenium-webdriver')
const { By, Key } = webdriver
const { delay, buildChromeWebDriver, buildFirefoxWebdriver, installWebExt, getExtensionIdChrome, getExtensionIdFirefox } = require('./func')
@ -14,7 +15,13 @@ describe('Metamask popup page', function () {
this.timeout(0)
before(async function () {
const extPath = path.resolve(`dist/${browser}`)
const srcPath = path.resolve(`dist/${browser}`)
const extPath = path.resolve(`test-builds/${browser}`)
await fs.ensureDir(extPath)
await fs.copy(srcPath, extPath)
const config = { NetworkController: { provider: { type: 'localhost' } } }
await prependFile(`${extPath}/background.js`, `window.METAMASK_CONFIG=${JSON.stringify(config)};\n`)
if (browser === 'chrome') {
driver = buildChromeWebDriver(extPath)
extensionId = await getExtensionIdChrome(driver)
@ -46,6 +53,7 @@ describe('Metamask popup page', function () {
// gather extra data if test failed
if (this.currentTest.state === 'failed') {
await verboseReportOnFailure(this.currentTest)
await delay(1000000)
}
})
@ -61,11 +69,6 @@ describe('Metamask popup page', function () {
await driver.switchTo().window(windowHandles[0])
})
it('sets provider type to localhost', async function () {
await delay(300)
await setProviderType('localhost')
})
})
describe('Account Creation', () => {
@ -313,10 +316,6 @@ describe('Metamask popup page', function () {
})
})
async function setProviderType (type) {
await driver.executeScript('window.metamask.setProviderType(arguments[0])', type)
}
async function checkBrowserForConsoleErrors() {
const ignoredLogTypes = ['WARNING']
const ignoredErrorMessages = [