Merge pull request #5835 from MetaMask/revert-5412-after-install-steps

Open full-screen UI on install
feature/default_network_editable
Whymarrh Whitby 6 years ago committed by GitHub
commit d59ac28194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/scripts/background.js
  2. 14
      test/e2e/beta/from-import-beta-ui.spec.js
  3. 7
      test/e2e/beta/helpers.js
  4. 17
      test/e2e/beta/metamask-beta-responsive-ui.spec.js
  5. 16
      test/e2e/beta/metamask-beta-ui.spec.js

@ -41,6 +41,7 @@ const {
const firstTimeState = Object.assign({}, rawFirstTimeState, global.METAMASK_TEST_CONFIG) const firstTimeState = Object.assign({}, rawFirstTimeState, global.METAMASK_TEST_CONFIG)
const STORAGE_KEY = 'metamask-config' const STORAGE_KEY = 'metamask-config'
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn') log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')
@ -472,3 +473,10 @@ function openPopup () {
} }
) )
} }
// On first install, open a new tab with MetaMask
extension.runtime.onInstalled.addListener(({reason}) => {
if ((reason === 'install') && (!METAMASK_DEBUG)) {
platform.openExtensionInBrowser()
}
})

@ -12,6 +12,7 @@ const {
} = require('../func') } = require('../func')
const { const {
checkBrowserForConsoleErrors, checkBrowserForConsoleErrors,
closeAllWindowHandlesExcept,
verboseReportOnFailure, verboseReportOnFailure,
findElement, findElement,
findElements, findElements,
@ -32,13 +33,14 @@ describe('Using MetaMask with an existing account', function () {
this.bail(true) this.bail(true)
before(async function () { before(async function () {
let extensionUrl
switch (process.env.SELENIUM_BROWSER) { switch (process.env.SELENIUM_BROWSER) {
case 'chrome': { case 'chrome': {
const extensionPath = path.resolve('dist/chrome') const extensionPath = path.resolve('dist/chrome')
driver = buildChromeWebDriver(extensionPath) driver = buildChromeWebDriver(extensionPath)
extensionId = await getExtensionIdChrome(driver) extensionId = await getExtensionIdChrome(driver)
await driver.get(`chrome-extension://${extensionId}/home.html`)
await delay(regularDelayMs) await delay(regularDelayMs)
extensionUrl = `chrome-extension://${extensionId}/home.html`
break break
} }
case 'firefox': { case 'firefox': {
@ -47,11 +49,17 @@ describe('Using MetaMask with an existing account', function () {
await installWebExt(driver, extensionPath) await installWebExt(driver, extensionPath)
await delay(regularDelayMs) await delay(regularDelayMs)
extensionId = await getExtensionIdFirefox(driver) extensionId = await getExtensionIdFirefox(driver)
await driver.get(`moz-extension://${extensionId}/home.html`) extensionUrl = `moz-extension://${extensionId}/home.html`
await delay(regularDelayMs)
break break
} }
} }
// Depending on the state of the application built into the above directory (extPath) and the value of
// METAMASK_DEBUG we will see different post-install behaviour and possibly some extra windows. Here we
// are closing any extraneous windows to reset us to a single window before continuing.
const [tab1] = await driver.getAllWindowHandles()
await closeAllWindowHandlesExcept(driver, [tab1])
await driver.switchTo().window(tab1)
await driver.get(extensionUrl)
}) })
afterEach(async function () { afterEach(async function () {

@ -120,6 +120,13 @@ async function switchToWindowWithTitle (driver, title, windowHandles) {
} }
} }
/**
* Closes all windows except those in the given list of exceptions
* @param {object} driver the WebDriver instance
* @param {string|Array<string>} exceptions the list of window handle exceptions
* @param {Array?} windowHandles the full list of window handles
* @returns {Promise<void>}
*/
async function closeAllWindowHandlesExcept (driver, exceptions, windowHandles) { async function closeAllWindowHandlesExcept (driver, exceptions, windowHandles) {
exceptions = typeof exceptions === 'string' ? [ exceptions ] : exceptions exceptions = typeof exceptions === 'string' ? [ exceptions ] : exceptions
windowHandles = windowHandles || await driver.getAllWindowHandles() windowHandles = windowHandles || await driver.getAllWindowHandles()

@ -12,6 +12,7 @@ const {
} = require('../func') } = require('../func')
const { const {
checkBrowserForConsoleErrors, checkBrowserForConsoleErrors,
closeAllWindowHandlesExcept,
findElement, findElement,
findElements, findElements,
loadExtension, loadExtension,
@ -31,23 +32,33 @@ describe('MetaMask', function () {
this.bail(true) this.bail(true)
before(async function () { before(async function () {
let extensionUrl
switch (process.env.SELENIUM_BROWSER) { switch (process.env.SELENIUM_BROWSER) {
case 'chrome': { case 'chrome': {
const extPath = path.resolve('dist/chrome') const extPath = path.resolve('dist/chrome')
driver = buildChromeWebDriver(extPath, { responsive: true }) driver = buildChromeWebDriver(extPath, { responsive: true })
extensionId = await getExtensionIdChrome(driver) extensionId = await getExtensionIdChrome(driver)
await driver.get(`chrome-extension://${extensionId}/home.html`) await delay(largeDelayMs)
extensionUrl = `chrome-extension://${extensionId}/home.html`
break break
} }
case 'firefox': { case 'firefox': {
const extPath = path.resolve('dist/firefox') const extPath = path.resolve('dist/firefox')
driver = buildFirefoxWebdriver({ responsive: true }) driver = buildFirefoxWebdriver({ responsive: true })
await installWebExt(driver, extPath) await installWebExt(driver, extPath)
await delay(700) await delay(largeDelayMs)
extensionId = await getExtensionIdFirefox(driver) extensionId = await getExtensionIdFirefox(driver)
await driver.get(`moz-extension://${extensionId}/home.html`) extensionUrl = `moz-extension://${extensionId}/home.html`
break
} }
} }
// Depending on the state of the application built into the above directory (extPath) and the value of
// METAMASK_DEBUG we will see different post-install behaviour and possibly some extra windows. Here we
// are closing any extraneous windows to reset us to a single window before continuing.
const [tab1] = await driver.getAllWindowHandles()
await closeAllWindowHandlesExcept(driver, [tab1])
await driver.switchTo().window(tab1)
await driver.get(extensionUrl)
}) })
afterEach(async function () { afterEach(async function () {

@ -37,23 +37,33 @@ describe('MetaMask', function () {
this.bail(true) this.bail(true)
before(async function () { before(async function () {
let extensionUrl
switch (process.env.SELENIUM_BROWSER) { switch (process.env.SELENIUM_BROWSER) {
case 'chrome': { case 'chrome': {
const extPath = path.resolve('dist/chrome') const extPath = path.resolve('dist/chrome')
driver = buildChromeWebDriver(extPath) driver = buildChromeWebDriver(extPath)
extensionId = await getExtensionIdChrome(driver) extensionId = await getExtensionIdChrome(driver)
await driver.get(`chrome-extension://${extensionId}/home.html`) await delay(largeDelayMs)
extensionUrl = `chrome-extension://${extensionId}/home.html`
break break
} }
case 'firefox': { case 'firefox': {
const extPath = path.resolve('dist/firefox') const extPath = path.resolve('dist/firefox')
driver = buildFirefoxWebdriver() driver = buildFirefoxWebdriver()
await installWebExt(driver, extPath) await installWebExt(driver, extPath)
await delay(700) await delay(largeDelayMs)
extensionId = await getExtensionIdFirefox(driver) extensionId = await getExtensionIdFirefox(driver)
await driver.get(`moz-extension://${extensionId}/home.html`) extensionUrl = `moz-extension://${extensionId}/home.html`
break
} }
} }
// Depending on the state of the application built into the above directory (extPath) and the value of
// METAMASK_DEBUG we will see different post-install behaviour and possibly some extra windows. Here we
// are closing any extraneous windows to reset us to a single window before continuing.
const [tab1] = await driver.getAllWindowHandles()
await closeAllWindowHandlesExcept(driver, [tab1])
await driver.switchTo().window(tab1)
await driver.get(extensionUrl)
}) })
afterEach(async function () { afterEach(async function () {

Loading…
Cancel
Save