aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <thomas.b.huang@gmail.com>2018-08-08 03:07:22 +0800
committerThomas <thomas.b.huang@gmail.com>2018-08-08 03:07:22 +0800
commit562764ccb2b0c3f39670390425f74ad9d88df647 (patch)
treeed7c0c2063d73b271062973f3c6e67b8698dbc0b
parent2df46c1392a61f3a4ae4be836f2cce032233b29c (diff)
downloadtangerine-wallet-browser-562764ccb2b0c3f39670390425f74ad9d88df647.tar
tangerine-wallet-browser-562764ccb2b0c3f39670390425f74ad9d88df647.tar.gz
tangerine-wallet-browser-562764ccb2b0c3f39670390425f74ad9d88df647.tar.bz2
tangerine-wallet-browser-562764ccb2b0c3f39670390425f74ad9d88df647.tar.lz
tangerine-wallet-browser-562764ccb2b0c3f39670390425f74ad9d88df647.tar.xz
tangerine-wallet-browser-562764ccb2b0c3f39670390425f74ad9d88df647.tar.zst
tangerine-wallet-browser-562764ccb2b0c3f39670390425f74ad9d88df647.zip
Use develop e2e beta tests
-rw-r--r--test/e2e/beta/from-import-beta-ui.spec.js143
1 files changed, 34 insertions, 109 deletions
diff --git a/test/e2e/beta/from-import-beta-ui.spec.js b/test/e2e/beta/from-import-beta-ui.spec.js
index 3a75e2378..5582d4697 100644
--- a/test/e2e/beta/from-import-beta-ui.spec.js
+++ b/test/e2e/beta/from-import-beta-ui.spec.js
@@ -4,13 +4,16 @@ const webdriver = require('selenium-webdriver')
const { By, Key, until } = webdriver
const {
delay,
- createModifiedTestBuild,
- setupBrowserAndExtension,
- verboseReportOnFailure,
+ buildChromeWebDriver,
+ buildFirefoxWebdriver,
+ installWebExt,
+ getExtensionIdChrome,
+ getExtensionIdFirefox,
} = require('../func')
const {
checkBrowserForConsoleErrors,
closeAllWindowHandlesExcept,
+ verboseReportOnFailure,
findElement,
findElements,
loadExtension,
@@ -18,10 +21,8 @@ const {
describe('Using MetaMask with an existing account', function () {
- const browser = process.env.SELENIUM_BROWSER
- let driver
- let extensionUri
let extensionId
+ let driver
const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'
const testAddress = '0xE18035BF8712672935FDB4e5e431b1a0183d2DFC'
@@ -29,24 +30,35 @@ describe('Using MetaMask with an existing account', function () {
const tinyDelayMs = 500
const regularDelayMs = 1000
const largeDelayMs = regularDelayMs * 2
- const waitingNewPageDelayMs = regularDelayMs * 10
this.timeout(0)
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
- extensionId = installResult.extensionId
- await driver.get(extensionUri)
- await delay(300)
+ switch (process.env.SELENIUM_BROWSER) {
+ case 'chrome': {
+ const extensionPath = path.resolve('dist/chrome')
+ driver = buildChromeWebDriver(extensionPath)
+ extensionId = await getExtensionIdChrome(driver)
+ await driver.get(`chrome-extension://${extensionId}/popup.html`)
+ await delay(regularDelayMs)
+ break
+ }
+ case 'firefox': {
+ const extensionPath = path.resolve('dist/firefox')
+ driver = buildFirefoxWebdriver()
+ await installWebExt(driver, extensionPath)
+ await delay(regularDelayMs)
+ extensionId = await getExtensionIdFirefox(driver)
+ await driver.get(`moz-extension://${extensionId}/popup.html`)
+ await delay(regularDelayMs)
+ break
+ }
+ }
})
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 +67,7 @@ describe('Using MetaMask with an existing account', function () {
}
}
if (this.currentTest.state === 'failed') {
- await verboseReportOnFailure({ browser, driver, title: this.currentTest.title })
+ await verboseReportOnFailure(driver, this.currentTest)
}
})
@@ -304,109 +316,22 @@ describe('Using MetaMask with an existing account', function () {
})
})
- describe('Send ETH from Faucet', () => {
- it('starts a send transaction inside Faucet', async () => {
- await driver.executeScript('window.open("https://faucet.metamask.io")')
- await delay(waitingNewPageDelayMs)
-
- const [extension, faucet] = await driver.getAllWindowHandles()
- await driver.switchTo().window(faucet)
- await delay(regularDelayMs)
-
- const send1eth = await findElement(driver, By.xpath(`//button[contains(text(), '10 ether')]`), 14000)
- await send1eth.click()
- await delay(regularDelayMs)
-
- await driver.switchTo().window(extension)
- await driver.get(extensionUri)
- await delay(regularDelayMs)
-
- const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`), 14000)
- await confirmButton.click()
- await delay(regularDelayMs)
-
- await driver.switchTo().window(faucet)
- await delay(regularDelayMs)
- await driver.close()
- await delay(regularDelayMs)
- await driver.switchTo().window(extension)
- await delay(regularDelayMs)
- await driver.get(extensionUri)
- await delay(regularDelayMs)
- })
- })
-
- describe('Add existing token using search', () => {
- it('clicks on the Add Token button', async () => {
- const addToken = await findElement(driver, By.xpath(`//button[contains(text(), 'Add Token')]`))
- await addToken.click()
- await delay(regularDelayMs)
- })
-
- it('picks an existing token', async () => {
- const tokenSearch = await findElement(driver, By.css('#search-tokens'))
- await tokenSearch.sendKeys('BAT')
- await delay(regularDelayMs)
-
- const token = await findElement(driver, By.xpath("//span[contains(text(), 'BAT')]"))
- await token.click()
- await delay(regularDelayMs)
-
- const nextScreen = await findElement(driver, By.xpath(`//button[contains(text(), 'Next')]`))
- await nextScreen.click()
+ describe('Imports an account with private key', () => {
+ it('choose Create Account from the account menu', async () => {
+ await driver.findElement(By.css('.account-menu__icon')).click()
await delay(regularDelayMs)
const [importAccount] = await findElements(driver, By.xpath(`//div[contains(text(), 'Import Account')]`))
await importAccount.click()
await delay(regularDelayMs)
})
- })
-
- describe('Add a custom token from TokenFactory', () => {
- let extension, tokenFactory
-
- it('creates a new token', async () => {
- await driver.executeScript('window.open("https://tokenfactory.surge.sh/#/factory")')
- await delay(waitingNewPageDelayMs)
-
- const windowHandles = await driver.getAllWindowHandles()
- extension = windowHandles[0]
- tokenFactory = windowHandles[1]
-
- await driver.switchTo().window(tokenFactory)
- const [
- totalSupply,
- tokenName,
- tokenDecimal,
- tokenSymbol,
- ] = await findElements(driver, By.css('.form-control'))
-
- await totalSupply.sendKeys('100')
- await tokenName.sendKeys('Test')
- await tokenDecimal.sendKeys('0')
- await tokenSymbol.sendKeys('TST')
-
- const createToken = await findElement(driver, By.xpath(`//button[contains(text(), 'Create Token')]`))
- await createToken.click()
- await delay(regularDelayMs)
-
- await driver.switchTo().window(extension)
- await driver.get(extensionUri)
- await delay(regularDelayMs)
- })
it('enter private key', async () => {
const privateKeyInput = await findElement(driver, By.css('#private-key-box'))
await privateKeyInput.sendKeys(testPrivateKey2)
await delay(regularDelayMs)
-
- await driver.switchTo().window(tokenFactory)
- await delay(regularDelayMs)
- const tokenContactAddress = await driver.findElement(By.css('div > div > div:nth-child(2) > span:nth-child(3)'))
- await tokenContactAddress.getText()
- await driver.close()
- await driver.switchTo().window(extension)
- await driver.get(extensionUri)
+ const importButtons = await findElements(driver, By.xpath(`//button[contains(text(), 'Import')]`))
+ await importButtons[0].click()
await delay(regularDelayMs)
})