1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Consolidate webdriver initialization (#7814)

The webdriver is now instantiated directly by the webdriver module,
rather than via a helper method.
This commit is contained in:
Mark Stacey 2020-01-14 13:34:38 -04:00 committed by GitHub
parent 87b95205fc
commit dd4e684f7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 27 additions and 35 deletions

View File

@ -2,11 +2,11 @@ const assert = require('assert')
const { By, until } = require('selenium-webdriver')
const {
prepareExtensionForTesting,
tinyDelayMs,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const Ganache = require('./ganache')
const enLocaleMessages = require('../../app/_locales/en/messages.json')
@ -29,7 +29,7 @@ describe('MetaMask', function () {
},
],
})
const result = await prepareExtensionForTesting()
const result = await buildWebDriver()
driver = result.driver
})

View File

@ -3,10 +3,10 @@ const webdriver = require('selenium-webdriver')
const { By, until } = webdriver
const {
prepareExtensionForTesting,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const Ganache = require('./ganache')
const enLocaleMessages = require('../../app/_locales/en/messages.json')
@ -28,7 +28,7 @@ describe('MetaMask', function () {
},
],
})
const result = await prepareExtensionForTesting()
const result = await buildWebDriver()
driver = result.driver
})

View File

@ -3,11 +3,11 @@ const webdriver = require('selenium-webdriver')
const { By, Key, until } = webdriver
const {
prepareExtensionForTesting,
tinyDelayMs,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const Ganache = require('./ganache')
const enLocaleMessages = require('../../app/_locales/en/messages.json')
@ -33,7 +33,7 @@ describe('Using MetaMask with an existing account', function () {
},
],
})
const result = await prepareExtensionForTesting()
const result = await buildWebDriver()
driver = result.driver
})

View File

@ -1,20 +1,9 @@
const { buildWebDriver } = require('./webdriver')
const tinyDelayMs = 200
const regularDelayMs = tinyDelayMs * 2
const largeDelayMs = regularDelayMs * 2
module.exports = {
prepareExtensionForTesting,
tinyDelayMs,
regularDelayMs,
largeDelayMs,
}
async function prepareExtensionForTesting ({ responsive, port } = {}) {
const browser = process.env.SELENIUM_BROWSER
const extensionPath = `dist/${browser}`
const { driver, extensionId, extensionUrl } = await buildWebDriver({ browser, extensionPath, responsive, port })
return { driver, extensionId, extensionUrl }
}

View File

@ -3,11 +3,11 @@ const webdriver = require('selenium-webdriver')
const { By, until } = webdriver
const {
prepareExtensionForTesting,
tinyDelayMs,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const Ganache = require('./ganache')
const enLocaleMessages = require('../../app/_locales/en/messages.json')
@ -33,7 +33,7 @@ describe('MetaMask', function () {
},
],
})
const result = await prepareExtensionForTesting()
const result = await buildWebDriver()
driver = result.driver
})

View File

@ -3,11 +3,11 @@ const webdriver = require('selenium-webdriver')
const { By, until } = webdriver
const {
prepareExtensionForTesting,
tinyDelayMs,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const Ganache = require('./ganache')
const enLocaleMessages = require('../../app/_locales/en/messages.json')
@ -23,7 +23,7 @@ describe('MetaMask', function () {
before(async function () {
await ganacheServer.start()
const result = await prepareExtensionForTesting({ responsive: true })
const result = await buildWebDriver({ responsive: true })
driver = result.driver
})

View File

@ -3,11 +3,11 @@ const webdriver = require('selenium-webdriver')
const { By, Key, until } = webdriver
const {
prepareExtensionForTesting,
tinyDelayMs,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const Ganache = require('./ganache')
const enLocaleMessages = require('../../app/_locales/en/messages.json')
@ -24,7 +24,7 @@ describe('MetaMask', function () {
before(async function () {
await ganacheServer.start()
const result = await prepareExtensionForTesting()
const result = await buildWebDriver()
driver = result.driver
})

View File

@ -3,10 +3,10 @@ const webdriver = require('selenium-webdriver')
const { By, until } = webdriver
const {
prepareExtensionForTesting,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const Ganache = require('./ganache')
const enLocaleMessages = require('../../app/_locales/en/messages.json')
@ -28,7 +28,7 @@ describe('MetaMask', function () {
},
],
})
const result = await prepareExtensionForTesting()
const result = await buildWebDriver()
driver = result.driver
})

View File

@ -3,11 +3,11 @@ const webdriver = require('selenium-webdriver')
const { By, Key, until } = webdriver
const {
prepareExtensionForTesting,
tinyDelayMs,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const Ganache = require('./ganache')
const enLocaleMessages = require('../../app/_locales/en/messages.json')
@ -30,7 +30,7 @@ describe('Using MetaMask with an existing account', function () {
},
],
})
const result = await prepareExtensionForTesting()
const result = await buildWebDriver()
driver = result.driver
})

View File

@ -4,10 +4,10 @@ const webdriver = require('selenium-webdriver')
const { By, Key, until } = webdriver
const {
prepareExtensionForTesting,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const Ganache = require('./ganache')
const FixtureServer = require('./fixture-server')
@ -27,7 +27,7 @@ describe('MetaMask', function () {
await fixtureServer.start()
await fixtureServer.loadState(path.join(__dirname, 'fixtures', 'imported-account'))
publicAddress = '0x5cfe73b6021e818b776b421b1c4db2474086a7e1'
const result = await prepareExtensionForTesting()
const result = await buildWebDriver()
driver = result.driver
})

View File

@ -4,11 +4,11 @@ const getPort = require('get-port')
const { By, until } = webdriver
const {
prepareExtensionForTesting,
tinyDelayMs,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const Ganache = require('./ganache')
const enLocaleMessages = require('../../app/_locales/en/messages.json')
@ -31,7 +31,7 @@ describe('MetaMask', function () {
},
],
})
const result = await prepareExtensionForTesting({ port: await getPort() })
const result = await buildWebDriver({ port: await getPort() })
driver = result.driver
})
@ -171,7 +171,7 @@ describe('MetaMask', function () {
let driver2
before(async function () {
const result = await prepareExtensionForTesting({ port: await getPort() })
const result = await buildWebDriver({ port: await getPort() })
driver2 = result.driver
})

View File

@ -3,10 +3,10 @@ const webdriver = require('selenium-webdriver')
const { By } = webdriver
const {
prepareExtensionForTesting,
regularDelayMs,
largeDelayMs,
} = require('./helpers')
const { buildWebDriver } = require('./webdriver')
const enLocaleMessages = require('../../app/_locales/en/messages.json')
describe('Using MetaMask with an existing account', function () {
@ -30,7 +30,7 @@ describe('Using MetaMask with an existing account', function () {
this.bail(true)
before(async function () {
const result = await prepareExtensionForTesting()
const result = await buildWebDriver()
driver = result.driver
})

View File

@ -4,7 +4,10 @@ const ChromeDriver = require('./chrome')
const FirefoxDriver = require('./firefox')
const fetchMockResponses = require('../../data/fetch-mocks.json')
async function buildWebDriver ({ browser, extensionPath, responsive, port }) {
async function buildWebDriver ({ responsive, port } = {}) {
const browser = process.env.SELENIUM_BROWSER
const extensionPath = `dist/${browser}`
switch (browser) {
case Browser.CHROME: {
const { driver, extensionId, extensionUrl } = await ChromeDriver.build({ extensionPath, responsive, port })