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

test - e2e - remove usage of extensionId from tests

This commit is contained in:
kumavis 2018-06-11 16:45:29 -07:00
parent ab0e60e802
commit 93a2e28705
4 changed files with 12 additions and 28 deletions

View File

@ -9,17 +9,16 @@ const {
verboseReportOnFailure, verboseReportOnFailure,
} = require('../func') } = require('../func')
const { const {
checkBrowserForConsoleErrors,
loadExtension,
findElement, findElement,
findElements, findElements,
checkBrowserForConsoleErrors,
} = require('./helpers') } = require('./helpers')
describe('Using MetaMask with an existing account', function () { describe('Using MetaMask with an existing account', function () {
const browser = process.env.SELENIUM_BROWSER const browser = process.env.SELENIUM_BROWSER
let extensionId
let driver let driver
let extensionUri
let tokenAddress let tokenAddress
const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent' const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'
@ -273,7 +272,7 @@ describe('Using MetaMask with an existing account', function () {
await delay(regularDelayMs) await delay(regularDelayMs)
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await loadExtension(driver, extensionId) await driver.get(extensionUri)
await delay(regularDelayMs) await delay(regularDelayMs)
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`), 14000) const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`), 14000)
@ -286,7 +285,7 @@ describe('Using MetaMask with an existing account', function () {
await delay(regularDelayMs) await delay(regularDelayMs)
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await delay(regularDelayMs) await delay(regularDelayMs)
await loadExtension(driver, extensionId) await driver.get(extensionUri)
await delay(regularDelayMs) await delay(regularDelayMs)
}) })
}) })
@ -348,7 +347,7 @@ describe('Using MetaMask with an existing account', function () {
await delay(regularDelayMs) await delay(regularDelayMs)
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await loadExtension(driver, extensionId) await driver.get(extensionUri)
await delay(regularDelayMs) await delay(regularDelayMs)
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`)) const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`))
@ -361,7 +360,7 @@ describe('Using MetaMask with an existing account', function () {
tokenAddress = await tokenContactAddress.getText() tokenAddress = await tokenContactAddress.getText()
await driver.close() await driver.close()
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await loadExtension(driver, extensionId) await driver.get(extensionUri)
await delay(regularDelayMs) await delay(regularDelayMs)
}) })

View File

@ -2,24 +2,10 @@ const { until } = require('selenium-webdriver')
module.exports = { module.exports = {
checkBrowserForConsoleErrors, checkBrowserForConsoleErrors,
loadExtension,
findElement, findElement,
findElements, findElements,
} }
async function loadExtension (driver, extensionId) {
switch (process.env.SELENIUM_BROWSER) {
case 'chrome': {
await driver.get(`chrome-extension://${extensionId}/home.html`)
break
}
case 'firefox': {
await driver.get(`moz-extension://${extensionId}/home.html`)
break
}
}
}
async function checkBrowserForConsoleErrors (driver) { async function checkBrowserForConsoleErrors (driver) {
const ignoredLogTypes = ['WARNING'] const ignoredLogTypes = ['WARNING']
const ignoredErrorMessages = [ const ignoredErrorMessages = [

View File

@ -12,13 +12,12 @@ const {
findElement, findElement,
findElements, findElements,
checkBrowserForConsoleErrors, checkBrowserForConsoleErrors,
loadExtension,
} = require('./helpers') } = require('./helpers')
describe('MetaMask', function () { describe('MetaMask', function () {
const browser = process.env.SELENIUM_BROWSER const browser = process.env.SELENIUM_BROWSER
let extensionId
let driver let driver
let extensionUri
let tokenAddress let tokenAddress
const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent' const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'
@ -361,7 +360,7 @@ describe('MetaMask', function () {
await delay(regularDelayMs) await delay(regularDelayMs)
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await loadExtension(driver, extensionId) await driver.get(extensionUri)
await delay(regularDelayMs) await delay(regularDelayMs)
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`), 14000) const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`), 14000)
@ -374,7 +373,7 @@ describe('MetaMask', function () {
await delay(regularDelayMs) await delay(regularDelayMs)
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await delay(regularDelayMs) await delay(regularDelayMs)
await loadExtension(driver, extensionId) await driver.get(extensionUri)
await delay(regularDelayMs) await delay(regularDelayMs)
}) })
}) })
@ -437,7 +436,7 @@ describe('MetaMask', function () {
await delay(regularDelayMs) await delay(regularDelayMs)
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await loadExtension(driver, extensionId) await driver.get(extensionUri)
await delay(regularDelayMs) await delay(regularDelayMs)
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`)) const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`))
@ -450,7 +449,7 @@ describe('MetaMask', function () {
tokenAddress = await tokenContactAddress.getText() tokenAddress = await tokenContactAddress.getText()
await driver.close() await driver.close()
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await loadExtension(driver, extensionId) await driver.get(extensionUri)
await delay(regularDelayMs) await delay(regularDelayMs)
}) })

View File

@ -8,7 +8,7 @@ const { delay, createModifiedTestBuild, setupBrowserAndExtension, verboseReportO
describe('Metamask popup page', function () { describe('Metamask popup page', function () {
const browser = process.env.SELENIUM_BROWSER const browser = process.env.SELENIUM_BROWSER
let driver, accountAddress, tokenAddress, extensionId, extensionUri let driver, accountAddress, tokenAddress, extensionUri
this.timeout(0) this.timeout(0)