mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
Remove unused test methods (#7679)
These helper methods were no longer used in any e2e tests.
This commit is contained in:
parent
3ce19ee11d
commit
885d30f90a
@ -270,7 +270,6 @@
|
||||
"node-sass": "^4.12.0",
|
||||
"nyc": "^13.0.0",
|
||||
"path": "^0.12.7",
|
||||
"prepend-file": "^1.3.1",
|
||||
"proxyquire": "2.0.1",
|
||||
"qs": "^6.2.0",
|
||||
"qunitjs": "^2.4.1",
|
||||
|
@ -3,17 +3,12 @@ require('geckodriver')
|
||||
const fs = require('fs-extra')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const pify = require('pify')
|
||||
const prependFile = pify(require('prepend-file'))
|
||||
const webdriver = require('selenium-webdriver')
|
||||
const Command = require('selenium-webdriver/lib/command').Command
|
||||
const By = webdriver.By
|
||||
|
||||
module.exports = {
|
||||
delay,
|
||||
createModifiedTestBuild,
|
||||
setupBrowserAndExtension,
|
||||
verboseReportOnFailure,
|
||||
buildChromeWebDriver,
|
||||
buildFirefoxWebdriver,
|
||||
installWebExt,
|
||||
@ -25,37 +20,6 @@ function delay (time) {
|
||||
return new Promise(resolve => setTimeout(resolve, time))
|
||||
}
|
||||
|
||||
async function createModifiedTestBuild ({ browser, srcPath }) {
|
||||
// copy build to test-builds directory
|
||||
const extPath = path.resolve(`test-builds/${browser}`)
|
||||
await fs.ensureDir(extPath)
|
||||
await fs.copy(srcPath, extPath)
|
||||
// inject METAMASK_TEST_CONFIG setting default test network
|
||||
const config = { NetworkController: { provider: { type: 'localhost' } } }
|
||||
await prependFile(`${extPath}/background.js`, `window.METAMASK_TEST_CONFIG=${JSON.stringify(config)};\n`)
|
||||
return { extPath }
|
||||
}
|
||||
|
||||
async function setupBrowserAndExtension ({ browser, extPath }) {
|
||||
let driver, extensionId, extensionUri
|
||||
|
||||
if (browser === 'chrome') {
|
||||
driver = buildChromeWebDriver(extPath)
|
||||
extensionId = await getExtensionIdChrome(driver)
|
||||
extensionUri = `chrome-extension://${extensionId}/home.html`
|
||||
} else if (browser === 'firefox') {
|
||||
driver = buildFirefoxWebdriver()
|
||||
await installWebExt(driver, extPath)
|
||||
await delay(700)
|
||||
extensionId = await getExtensionIdFirefox(driver)
|
||||
extensionUri = `moz-extension://${extensionId}/home.html`
|
||||
} else {
|
||||
throw new Error(`Unknown Browser "${browser}"`)
|
||||
}
|
||||
|
||||
return { driver, extensionId, extensionUri }
|
||||
}
|
||||
|
||||
function buildChromeWebDriver (extPath, opts = {}) {
|
||||
const tmpProfile = fs.mkdtempSync(path.join(os.tmpdir(), 'mm-chrome-profile'))
|
||||
const args = [
|
||||
@ -105,13 +69,3 @@ async function installWebExt (driver, extension) {
|
||||
|
||||
return await driver.schedule(cmd, 'installWebExt(' + extension + ')')
|
||||
}
|
||||
|
||||
async function verboseReportOnFailure ({ browser, driver, title }) {
|
||||
const artifactDir = `./test-artifacts/${browser}/${title}`
|
||||
const filepathBase = `${artifactDir}/test-failure`
|
||||
await fs.ensureDir(artifactDir)
|
||||
const screenshot = await driver.takeScreenshot()
|
||||
await fs.writeFile(`${filepathBase}-screenshot.png`, screenshot, { encoding: 'base64' })
|
||||
const htmlSource = await driver.getPageSource()
|
||||
await fs.writeFile(`${filepathBase}-dom.html`, htmlSource)
|
||||
}
|
||||
|
@ -25,10 +25,8 @@ module.exports = {
|
||||
closeAllWindowHandlesExcept,
|
||||
findElement,
|
||||
findElements,
|
||||
loadExtension,
|
||||
openNewPage,
|
||||
switchToWindowWithTitle,
|
||||
switchToWindowWithUrlThatMatches,
|
||||
verboseReportOnFailure,
|
||||
waitUntilXWindowHandles,
|
||||
setupFetchMocking,
|
||||
@ -111,21 +109,6 @@ async function setupFetchMocking (driver) {
|
||||
await driver.executeScript(`(${fetchMocking})(${fetchMockResponsesJson})`)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
default:
|
||||
throw new Error('Unrecognized SELENIUM_BROWSER value')
|
||||
}
|
||||
}
|
||||
|
||||
async function checkBrowserForConsoleErrors (driver) {
|
||||
const ignoredLogTypes = ['WARNING']
|
||||
const ignoredErrorMessages = [
|
||||
@ -243,19 +226,3 @@ async function assertElementNotPresent (webdriver, driver, by) {
|
||||
}
|
||||
assert.ok(!dataTab, 'Found element that should not be present')
|
||||
}
|
||||
|
||||
async function switchToWindowWithUrlThatMatches (driver, regexp, windowHandles) {
|
||||
if (!windowHandles) {
|
||||
windowHandles = await driver.getAllWindowHandles()
|
||||
} else if (windowHandles.length === 0) {
|
||||
throw new Error('No window that matches: ' + regexp)
|
||||
}
|
||||
const firstHandle = windowHandles[0]
|
||||
await driver.switchTo().window(firstHandle)
|
||||
const windowUrl = await driver.getCurrentUrl()
|
||||
if (windowUrl.match(regexp)) {
|
||||
return firstHandle
|
||||
} else {
|
||||
return await switchToWindowWithUrlThatMatches(driver, regexp, windowHandles.slice(1))
|
||||
}
|
||||
}
|
||||
|
14
yarn.lock
14
yarn.lock
@ -21310,13 +21310,6 @@ prelude-ls@~1.1.2:
|
||||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
|
||||
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=
|
||||
|
||||
prepend-file@^1.3.1:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/prepend-file/-/prepend-file-1.3.1.tgz#83b16e0b4ac1901fce88dbd945a22f4cc81df579"
|
||||
integrity sha1-g7FuC0rBkB/OiNvZRaIvTMgd9Xk=
|
||||
dependencies:
|
||||
tmp "0.0.31"
|
||||
|
||||
prepend-http@^1.0.0, prepend-http@^1.0.1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"
|
||||
@ -26557,13 +26550,6 @@ tmp@0.0.30:
|
||||
dependencies:
|
||||
os-tmpdir "~1.0.1"
|
||||
|
||||
tmp@0.0.31:
|
||||
version "0.0.31"
|
||||
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.31.tgz#8f38ab9438e17315e5dbd8b3657e8bfb277ae4a7"
|
||||
integrity sha1-jzirlDjhcxXl29izZX6L+yd65Kc=
|
||||
dependencies:
|
||||
os-tmpdir "~1.0.1"
|
||||
|
||||
tmp@0.0.33, tmp@0.0.x, tmp@^0.0.33:
|
||||
version "0.0.33"
|
||||
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
|
||||
|
Loading…
Reference in New Issue
Block a user