mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
test - e2e - inject metamask config to point at localhost
This commit is contained in:
parent
0db776c3cc
commit
02f5502e16
1
.gitignore
vendored
1
.gitignore
vendored
@ -31,6 +31,7 @@ test/bundle.js
|
|||||||
test/test-bundle.js
|
test/test-bundle.js
|
||||||
|
|
||||||
test-artifacts
|
test-artifacts
|
||||||
|
test-builds
|
||||||
|
|
||||||
#ignore css output and sourcemaps
|
#ignore css output and sourcemaps
|
||||||
ui/app/css/output/
|
ui/app/css/output/
|
||||||
|
@ -18,7 +18,7 @@ const migrations = require('./migrations/')
|
|||||||
const PortStream = require('./lib/port-stream.js')
|
const PortStream = require('./lib/port-stream.js')
|
||||||
const NotificationManager = require('./lib/notification-manager.js')
|
const NotificationManager = require('./lib/notification-manager.js')
|
||||||
const MetamaskController = require('./metamask-controller')
|
const MetamaskController = require('./metamask-controller')
|
||||||
const firstTimeState = require('./first-time-state')
|
const rawFirstTimeState = require('./first-time-state')
|
||||||
const setupRaven = require('./lib/setupRaven')
|
const setupRaven = require('./lib/setupRaven')
|
||||||
const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry')
|
const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry')
|
||||||
const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics')
|
const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics')
|
||||||
@ -31,6 +31,8 @@ const {
|
|||||||
ENVIRONMENT_TYPE_FULLSCREEN,
|
ENVIRONMENT_TYPE_FULLSCREEN,
|
||||||
} = require('./lib/enums')
|
} = require('./lib/enums')
|
||||||
|
|
||||||
|
const firstTimeState = Object.assign({}, rawFirstTimeState, global.METAMASK_CONFIG)
|
||||||
|
|
||||||
const STORAGE_KEY = 'metamask-config'
|
const STORAGE_KEY = 'metamask-config'
|
||||||
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
|
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
|
||||||
|
|
||||||
|
54
package-lock.json
generated
54
package-lock.json
generated
@ -10241,15 +10241,25 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"fs-extra": {
|
"fs-extra": {
|
||||||
"version": "0.30.0",
|
"version": "6.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz",
|
||||||
"integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
|
"integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"graceful-fs": "4.1.11",
|
"graceful-fs": "^4.1.2",
|
||||||
"jsonfile": "2.4.0",
|
"jsonfile": "^4.0.0",
|
||||||
"klaw": "1.3.1",
|
"universalify": "^0.1.0"
|
||||||
"path-is-absolute": "1.0.1",
|
},
|
||||||
"rimraf": "2.6.2"
|
"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": {
|
"fs-mkdirp-stream": {
|
||||||
@ -11126,6 +11136,18 @@
|
|||||||
"yargs": "4.8.1"
|
"yargs": "4.8.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"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": {
|
"yargs": {
|
||||||
"version": "4.8.1",
|
"version": "4.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz",
|
"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",
|
"resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz",
|
||||||
"integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=",
|
"integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"graceful-fs": "4.1.11"
|
"graceful-fs": "^4.1.9"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"known-css-properties": {
|
"known-css-properties": {
|
||||||
@ -24426,7 +24448,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz",
|
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz",
|
||||||
"integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=",
|
"integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"os-tmpdir": "1.0.2"
|
"os-tmpdir": "~1.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27736,6 +27758,18 @@
|
|||||||
"yargs": "4.8.1"
|
"yargs": "4.8.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"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": {
|
"yargs": {
|
||||||
"version": "4.8.1",
|
"version": "4.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz",
|
||||||
|
@ -232,6 +232,7 @@
|
|||||||
"eslint-plugin-mocha": "^5.0.0",
|
"eslint-plugin-mocha": "^5.0.0",
|
||||||
"eslint-plugin-react": "^7.4.0",
|
"eslint-plugin-react": "^7.4.0",
|
||||||
"file-loader": "^1.1.11",
|
"file-loader": "^1.1.11",
|
||||||
|
"fs-extra": "^6.0.1",
|
||||||
"fs-promise": "^2.0.3",
|
"fs-promise": "^2.0.3",
|
||||||
"ganache-cli": "^6.1.0",
|
"ganache-cli": "^6.1.0",
|
||||||
"ganache-core": "^2.1.0",
|
"ganache-core": "^2.1.0",
|
||||||
@ -276,6 +277,7 @@
|
|||||||
"open": "0.0.5",
|
"open": "0.0.5",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"png-file-stream": "^1.0.0",
|
"png-file-stream": "^1.0.0",
|
||||||
|
"prepend-file": "^1.3.1",
|
||||||
"prompt": "^1.0.0",
|
"prompt": "^1.0.0",
|
||||||
"proxyquire": "2.0.1",
|
"proxyquire": "2.0.1",
|
||||||
"qs": "^6.2.0",
|
"qs": "^6.2.0",
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
const fs = require('fs')
|
const fs = require('fs-extra')
|
||||||
const mkdirp = require('mkdirp')
|
const mkdirp = require('mkdirp')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const pify = require('pify')
|
const pify = require('pify')
|
||||||
|
const prependFile = pify(require('prepend-file'))
|
||||||
const webdriver = require('selenium-webdriver')
|
const webdriver = require('selenium-webdriver')
|
||||||
const { By, Key } = webdriver
|
const { By, Key } = webdriver
|
||||||
const { delay, buildChromeWebDriver, buildFirefoxWebdriver, installWebExt, getExtensionIdChrome, getExtensionIdFirefox } = require('./func')
|
const { delay, buildChromeWebDriver, buildFirefoxWebdriver, installWebExt, getExtensionIdChrome, getExtensionIdFirefox } = require('./func')
|
||||||
@ -14,7 +15,13 @@ describe('Metamask popup page', function () {
|
|||||||
this.timeout(0)
|
this.timeout(0)
|
||||||
|
|
||||||
before(async function () {
|
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') {
|
if (browser === 'chrome') {
|
||||||
driver = buildChromeWebDriver(extPath)
|
driver = buildChromeWebDriver(extPath)
|
||||||
extensionId = await getExtensionIdChrome(driver)
|
extensionId = await getExtensionIdChrome(driver)
|
||||||
@ -46,6 +53,7 @@ describe('Metamask popup page', function () {
|
|||||||
// gather extra data if test failed
|
// gather extra data if test failed
|
||||||
if (this.currentTest.state === 'failed') {
|
if (this.currentTest.state === 'failed') {
|
||||||
await verboseReportOnFailure(this.currentTest)
|
await verboseReportOnFailure(this.currentTest)
|
||||||
|
await delay(1000000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -61,11 +69,6 @@ describe('Metamask popup page', function () {
|
|||||||
await driver.switchTo().window(windowHandles[0])
|
await driver.switchTo().window(windowHandles[0])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets provider type to localhost', async function () {
|
|
||||||
await delay(300)
|
|
||||||
await setProviderType('localhost')
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Account Creation', () => {
|
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() {
|
async function checkBrowserForConsoleErrors() {
|
||||||
const ignoredLogTypes = ['WARNING']
|
const ignoredLogTypes = ['WARNING']
|
||||||
const ignoredErrorMessages = [
|
const ignoredErrorMessages = [
|
||||||
|
Loading…
Reference in New Issue
Block a user