aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-06-12 00:37:08 +0800
committerkumavis <aaron@kumavis.me>2018-06-12 00:37:08 +0800
commit0fa90149868d5c21bca75e318a392e1ecb77c6f0 (patch)
tree035b2aed850f262193cb06d86df0c808ae22852e /test
parent3ce83570ee336524e1ab0da50a9f47744cddb193 (diff)
downloadtangerine-wallet-browser-0fa90149868d5c21bca75e318a392e1ecb77c6f0.tar
tangerine-wallet-browser-0fa90149868d5c21bca75e318a392e1ecb77c6f0.tar.gz
tangerine-wallet-browser-0fa90149868d5c21bca75e318a392e1ecb77c6f0.tar.bz2
tangerine-wallet-browser-0fa90149868d5c21bca75e318a392e1ecb77c6f0.tar.lz
tangerine-wallet-browser-0fa90149868d5c21bca75e318a392e1ecb77c6f0.tar.xz
tangerine-wallet-browser-0fa90149868d5c21bca75e318a392e1ecb77c6f0.tar.zst
tangerine-wallet-browser-0fa90149868d5c21bca75e318a392e1ecb77c6f0.zip
test - e2e - reduce browser-specific code
Diffstat (limited to 'test')
-rw-r--r--test/e2e/metamask.spec.js33
1 files changed, 13 insertions, 20 deletions
diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js
index a08a34d96..f993f3fca 100644
--- a/test/e2e/metamask.spec.js
+++ b/test/e2e/metamask.spec.js
@@ -8,31 +8,33 @@ const { By, Key } = webdriver
const { delay, buildChromeWebDriver, buildFirefoxWebdriver, installWebExt, getExtensionIdChrome, getExtensionIdFirefox } = require('./func')
describe('Metamask popup page', function () {
- let driver, accountAddress, tokenAddress, extensionId
+ const browser = process.env.SELENIUM_BROWSER
+ let driver, accountAddress, tokenAddress, extensionId, extensionUri
this.timeout(0)
before(async function () {
- if (process.env.SELENIUM_BROWSER === 'chrome') {
- const extPath = path.resolve('dist/chrome')
+ const extPath = path.resolve(`dist/${browser}`)
+ if (browser === 'chrome') {
driver = buildChromeWebDriver(extPath)
extensionId = await getExtensionIdChrome(driver)
- await driver.get(`chrome-extension://${extensionId}/popup.html`)
-
- } else if (process.env.SELENIUM_BROWSER === 'firefox') {
- const extPath = path.resolve('dist/firefox')
+ extensionUri = `chrome-extension://${extensionId}/popup.html`
+ } else if (browser === 'firefox') {
driver = buildFirefoxWebdriver()
await installWebExt(driver, extPath)
await delay(700)
extensionId = await getExtensionIdFirefox(driver)
- await driver.get(`moz-extension://${extensionId}/popup.html`)
+ extensionUri = `moz-extension://${extensionId}/popup.html`
+ } else {
+ throw new Error(`Unknown Browser "${browser}"`)
}
+ await driver.get(extensionUri)
})
afterEach(async function () {
// logs command not supported in firefox
// https://github.com/SeleniumHQ/selenium/issues/2910
- if (process.env.SELENIUM_BROWSER === 'chrome') {
+ if (browser === 'chrome') {
// check for console errors
const errors = await checkBrowserForConsoleErrors()
if (errors.length) {
@@ -272,11 +274,7 @@ describe('Metamask popup page', function () {
})
it('navigates back to MetaMask popup in the tab', async function () {
- if (process.env.SELENIUM_BROWSER === 'chrome') {
- await driver.get(`chrome-extension://${extensionId}/popup.html`)
- } else if (process.env.SELENIUM_BROWSER === 'firefox') {
- await driver.get(`moz-extension://${extensionId}/popup.html`)
- }
+ await driver.get(extensionUri)
await delay(700)
})
})
@@ -340,12 +338,7 @@ describe('Metamask popup page', function () {
}
async function verboseReportOnFailure (test) {
- let artifactDir
- if (process.env.SELENIUM_BROWSER === 'chrome') {
- artifactDir = `./test-artifacts/chrome/${test.title}`
- } else if (process.env.SELENIUM_BROWSER === 'firefox') {
- artifactDir = `./test-artifacts/firefox/${test.title}`
- }
+ const artifactDir = `./test-artifacts/${browser}/${test.title}`
const filepathBase = `${artifactDir}/test-failure`
await pify(mkdirp)(artifactDir)
// capture screenshot