aboutsummaryrefslogtreecommitdiffstats
path: root/test/e2e/beta/metamask-beta-ui.spec.js
diff options
context:
space:
mode:
authorThomas Huang <thomas.b.huang@gmail.com>2018-08-02 01:40:31 +0800
committerThomas Huang <thomas.b.huang@gmail.com>2018-08-02 01:40:31 +0800
commit024ebe07e0c61e7185e84499a2f19885ac52e4a9 (patch)
tree88ed997d61c225573b7d75c357f5c11b6840a3ea /test/e2e/beta/metamask-beta-ui.spec.js
parent5b3927fe5b5243a89e5fd31ad069da9ea5c987e9 (diff)
parent4f02726fd9a2b7509dfd00eb4b23d9fc81eb5dcd (diff)
downloadtangerine-wallet-browser-024ebe07e0c61e7185e84499a2f19885ac52e4a9.tar.gz
tangerine-wallet-browser-024ebe07e0c61e7185e84499a2f19885ac52e4a9.tar.zst
tangerine-wallet-browser-024ebe07e0c61e7185e84499a2f19885ac52e4a9.zip
Merge branch 'develop' into network-remove-provider-engine-tests
Diffstat (limited to 'test/e2e/beta/metamask-beta-ui.spec.js')
-rw-r--r--test/e2e/beta/metamask-beta-ui.spec.js117
1 files changed, 66 insertions, 51 deletions
diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js
index 37e556b55..98b4a2791 100644
--- a/test/e2e/beta/metamask-beta-ui.spec.js
+++ b/test/e2e/beta/metamask-beta-ui.spec.js
@@ -4,9 +4,11 @@ const webdriver = require('selenium-webdriver')
const { By, Key, until } = webdriver
const {
delay,
- createModifiedTestBuild,
- setupBrowserAndExtension,
- verboseReportOnFailure,
+ buildChromeWebDriver,
+ buildFirefoxWebdriver,
+ installWebExt,
+ getExtensionIdChrome,
+ getExtensionIdFirefox,
} = require('../func')
const {
assertElementNotPresent,
@@ -17,13 +19,13 @@ const {
loadExtension,
openNewPage,
switchToWindowWithTitle,
+ verboseReportOnFailure,
waitUntilXWindowHandles,
} = require('./helpers')
describe('MetaMask', function () {
- const browser = process.env.SELENIUM_BROWSER
+ let extensionId
let driver
- let extensionUri
let tokenAddress
const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'
@@ -35,18 +37,27 @@ describe('MetaMask', function () {
this.bail(true)
before(async function () {
- const srcPath = path.resolve(`dist/${browser}`)
- const { extPath } = await createModifiedTestBuild({ browser, srcPath })
- const installResult = await setupBrowserAndExtension({ browser, extPath })
- driver = installResult.driver
- extensionUri = installResult.extensionUri
-
- await driver.get(extensionUri)
- await delay(tinyDelayMs)
+ switch (process.env.SELENIUM_BROWSER) {
+ case 'chrome': {
+ const extPath = path.resolve('dist/chrome')
+ driver = buildChromeWebDriver(extPath)
+ extensionId = await getExtensionIdChrome(driver)
+ await driver.get(`chrome-extension://${extensionId}/popup.html`)
+ break
+ }
+ case 'firefox': {
+ const extPath = path.resolve('dist/firefox')
+ driver = buildFirefoxWebdriver()
+ await installWebExt(driver, extPath)
+ await delay(700)
+ extensionId = await getExtensionIdFirefox(driver)
+ await driver.get(`moz-extension://${extensionId}/popup.html`)
+ }
+ }
})
afterEach(async function () {
- if (browser === 'chrome') {
+ if (process.env.SELENIUM_BROWSER === 'chrome') {
const errors = await checkBrowserForConsoleErrors(driver)
if (errors.length) {
const errorReports = errors.map(err => err.message)
@@ -55,7 +66,7 @@ describe('MetaMask', function () {
}
}
if (this.currentTest.state === 'failed') {
- await verboseReportOnFailure({ browser, driver, title: this.currentTest.title })
+ await verboseReportOnFailure(driver, this.currentTest)
}
})
@@ -64,30 +75,11 @@ describe('MetaMask', function () {
})
describe('New UI setup', async function () {
- let networkSelector
it('switches to first tab', async function () {
+ await delay(tinyDelayMs)
const [firstTab] = await driver.getAllWindowHandles()
await driver.switchTo().window(firstTab)
await delay(regularDelayMs)
- try {
- networkSelector = await findElement(driver, By.css('#network_component'))
- } catch (e) {
- await loadExtension(driver, extensionUri)
- await delay(largeDelayMs * 2)
- networkSelector = await findElement(driver, By.css('#network_component'))
- }
- await delay(regularDelayMs)
- })
-
- it('uses the local network', async function () {
- await networkSelector.click()
- await delay(regularDelayMs)
-
- const networks = await findElements(driver, By.css('.dropdown-menu-item'))
- const localhost = networks[4]
- await driver.wait(until.elementTextMatches(localhost, /Localhost/))
- await localhost.click()
- await delay(regularDelayMs)
})
it('selects the new UI option', async () => {
@@ -96,27 +88,40 @@ describe('MetaMask', function () {
await driver.wait(until.stalenessOf(overlay))
} catch (e) {}
- const button = await findElement(driver, By.xpath("//p[contains(text(), 'Try Beta Version')]"))
+ const button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]"))
await button.click()
await delay(regularDelayMs)
// Close all other tabs
- const [oldUi, tab1, tab2] = await driver.getAllWindowHandles()
- await driver.switchTo().window(oldUi)
- await driver.close()
+ const [tab0, tab1, tab2] = await driver.getAllWindowHandles()
+ await driver.switchTo().window(tab0)
+ await delay(tinyDelayMs)
- await driver.switchTo().window(tab1)
- const tab1Url = await driver.getCurrentUrl()
- if (tab1Url.match(/metamask.io/)) {
- await driver.switchTo().window(tab1)
- await driver.close()
- await driver.switchTo().window(tab2)
- } else if (tab2) {
- await driver.switchTo().window(tab2)
- await driver.close()
+ let selectedUrl = await driver.getCurrentUrl()
+ await delay(tinyDelayMs)
+ if (tab0 && selectedUrl.match(/popup.html/)) {
+ await closeAllWindowHandlesExcept(driver, tab0)
+ } else if (tab1) {
await driver.switchTo().window(tab1)
+ selectedUrl = await driver.getCurrentUrl()
+ await delay(tinyDelayMs)
+ if (selectedUrl.match(/popup.html/)) {
+ await closeAllWindowHandlesExcept(driver, tab1)
+ } else if (tab2) {
+ await driver.switchTo().window(tab2)
+ selectedUrl = await driver.getCurrentUrl()
+ selectedUrl.match(/popup.html/) && await closeAllWindowHandlesExcept(driver, tab2)
+ }
+ } else {
+ throw new Error('popup.html not found')
}
await delay(regularDelayMs)
+ const [appTab] = await driver.getAllWindowHandles()
+ await driver.switchTo().window(appTab)
+ await delay(tinyDelayMs)
+
+ await loadExtension(driver, extensionId)
+ await delay(regularDelayMs)
const continueBtn = await findElement(driver, By.css('.welcome-screen__button'))
await continueBtn.click()
@@ -263,7 +268,7 @@ describe('MetaMask', function () {
await word11.click()
await delay(tinyDelayMs)
} catch (e) {
- await loadExtension(driver, extensionUri)
+ await loadExtension(driver, extensionId)
await retypeSeedPhrase(words, true)
}
}
@@ -378,6 +383,16 @@ 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.+ETH/))
@@ -636,7 +651,7 @@ describe('MetaMask', function () {
await delay(regularDelayMs)
await driver.switchTo().window(extension)
- await driver.get(extensionUri)
+ await loadExtension(driver, extensionId)
await delay(regularDelayMs)
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`))
@@ -1011,4 +1026,4 @@ describe('MetaMask', function () {
await delay(regularDelayMs)
})
})
-})
+}) \ No newline at end of file