mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix e2e tests to accomodate new ui suggestion screen changes.
This commit is contained in:
parent
89c74ac4ad
commit
30d92b8d3f
@ -12,9 +12,11 @@ const {
|
|||||||
} = require('../func')
|
} = require('../func')
|
||||||
const {
|
const {
|
||||||
checkBrowserForConsoleErrors,
|
checkBrowserForConsoleErrors,
|
||||||
|
closeAllWindowHandlesExcept,
|
||||||
verboseReportOnFailure,
|
verboseReportOnFailure,
|
||||||
findElement,
|
findElement,
|
||||||
findElements,
|
findElements,
|
||||||
|
loadExtension,
|
||||||
} = require('./helpers')
|
} = require('./helpers')
|
||||||
|
|
||||||
|
|
||||||
@ -25,6 +27,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
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'
|
||||||
const testAddress = '0xE18035BF8712672935FDB4e5e431b1a0183d2DFC'
|
const testAddress = '0xE18035BF8712672935FDB4e5e431b1a0183d2DFC'
|
||||||
const testPrivateKey2 = '14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6'
|
const testPrivateKey2 = '14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6'
|
||||||
|
const tinyDelayMs = 500
|
||||||
const regularDelayMs = 1000
|
const regularDelayMs = 1000
|
||||||
const largeDelayMs = regularDelayMs * 2
|
const largeDelayMs = regularDelayMs * 2
|
||||||
|
|
||||||
@ -74,37 +77,55 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
|
|
||||||
describe('New UI setup', async function () {
|
describe('New UI setup', async function () {
|
||||||
it('switches to first tab', async function () {
|
it('switches to first tab', async function () {
|
||||||
|
await delay(tinyDelayMs)
|
||||||
const [firstTab] = await driver.getAllWindowHandles()
|
const [firstTab] = await driver.getAllWindowHandles()
|
||||||
await driver.switchTo().window(firstTab)
|
await driver.switchTo().window(firstTab)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('use the local network', async function () {
|
|
||||||
const networkSelector = await findElement(driver, By.css('#network_component'))
|
|
||||||
await networkSelector.click()
|
|
||||||
await delay(regularDelayMs)
|
|
||||||
|
|
||||||
const [localhost] = await findElements(driver, By.xpath(`//li[contains(text(), 'Localhost')]`))
|
|
||||||
await localhost.click()
|
|
||||||
await delay(regularDelayMs)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('selects the new UI option', async () => {
|
it('selects the new UI option', async () => {
|
||||||
const button = await findElement(driver, By.xpath("//p[contains(text(), 'Try Beta Version')]"))
|
try {
|
||||||
|
const overlay = await findElement(driver, By.css('.full-flex-height'))
|
||||||
|
await driver.wait(until.stalenessOf(overlay))
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
const button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]"))
|
||||||
await button.click()
|
await button.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
// Close all other tabs
|
// Close all other tabs
|
||||||
const [oldUi, infoPage, newUi] = await driver.getAllWindowHandles()
|
const [tab0, tab1, tab2] = await driver.getAllWindowHandles()
|
||||||
|
await driver.switchTo().window(tab0)
|
||||||
|
await delay(tinyDelayMs)
|
||||||
|
|
||||||
const newUiOrInfoPage = newUi || infoPage
|
let selectedUrl = await driver.getCurrentUrl()
|
||||||
await driver.switchTo().window(oldUi)
|
await delay(tinyDelayMs)
|
||||||
await driver.close()
|
if (tab0 && selectedUrl.match(/popup.html/)) {
|
||||||
if (infoPage !== newUiOrInfoPage) {
|
await closeAllWindowHandlesExcept(driver, tab0)
|
||||||
await driver.switchTo().window(infoPage)
|
} else if (tab1) {
|
||||||
await driver.close()
|
await driver.switchTo().window(tab1)
|
||||||
|
selectedUrl = await driver.getCurrentUrl()
|
||||||
|
await delay(tinyDelayMs)
|
||||||
|
if (selectedUrl.match(/popup.html/)) {
|
||||||
|
await closeAllWindowHandlesExcept(driver, tab1)
|
||||||
|
} else if (tab2) {
|
||||||
|
await driver.switchTo().window(tab2)
|
||||||
|
selectedUrl = await driver.getCurrentUrl()
|
||||||
|
selectedUrl.match(/popup.html/) && await closeAllWindowHandlesExcept(driver, tab2)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('popup.html not found')
|
||||||
}
|
}
|
||||||
await driver.switchTo().window(newUiOrInfoPage)
|
await delay(regularDelayMs)
|
||||||
|
const [appTab] = await driver.getAllWindowHandles()
|
||||||
|
await driver.switchTo().window(appTab)
|
||||||
|
await delay(tinyDelayMs)
|
||||||
|
|
||||||
|
const okayBtn = await findElement(driver, By.xpath("//button[contains(text(), 'Ok')]"))
|
||||||
|
await okayBtn.click()
|
||||||
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
await loadExtension(driver, extensionId)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const continueBtn = await findElement(driver, By.css('.welcome-screen__button'))
|
const continueBtn = await findElement(driver, By.css('.welcome-screen__button'))
|
||||||
|
@ -75,30 +75,11 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('New UI setup', async function () {
|
describe('New UI setup', async function () {
|
||||||
let networkSelector
|
|
||||||
it('switches to first tab', async function () {
|
it('switches to first tab', async function () {
|
||||||
|
await delay(tinyDelayMs)
|
||||||
const [firstTab] = await driver.getAllWindowHandles()
|
const [firstTab] = await driver.getAllWindowHandles()
|
||||||
await driver.switchTo().window(firstTab)
|
await driver.switchTo().window(firstTab)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
try {
|
|
||||||
networkSelector = await findElement(driver, By.css('#network_component'))
|
|
||||||
} catch (e) {
|
|
||||||
await loadExtension(driver, extensionId)
|
|
||||||
await delay(largeDelayMs * 2)
|
|
||||||
networkSelector = await findElement(driver, By.css('#network_component'))
|
|
||||||
}
|
|
||||||
await delay(regularDelayMs)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('uses the local network', async function () {
|
|
||||||
await networkSelector.click()
|
|
||||||
await delay(regularDelayMs)
|
|
||||||
|
|
||||||
const networks = await findElements(driver, By.css('.dropdown-menu-item'))
|
|
||||||
const localhost = networks[4]
|
|
||||||
await driver.wait(until.elementTextMatches(localhost, /Localhost/))
|
|
||||||
await localhost.click()
|
|
||||||
await delay(regularDelayMs)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('selects the new UI option', async () => {
|
it('selects the new UI option', async () => {
|
||||||
@ -107,27 +88,44 @@ describe('MetaMask', function () {
|
|||||||
await driver.wait(until.stalenessOf(overlay))
|
await driver.wait(until.stalenessOf(overlay))
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
const button = await findElement(driver, By.xpath("//p[contains(text(), 'Try Beta Version')]"))
|
const button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]"))
|
||||||
await button.click()
|
await button.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
// Close all other tabs
|
// Close all other tabs
|
||||||
const [oldUi, tab1, tab2] = await driver.getAllWindowHandles()
|
const [tab0, tab1, tab2] = await driver.getAllWindowHandles()
|
||||||
await driver.switchTo().window(oldUi)
|
await driver.switchTo().window(tab0)
|
||||||
await driver.close()
|
await delay(tinyDelayMs)
|
||||||
|
|
||||||
await driver.switchTo().window(tab1)
|
let selectedUrl = await driver.getCurrentUrl()
|
||||||
const tab1Url = await driver.getCurrentUrl()
|
await delay(tinyDelayMs)
|
||||||
if (tab1Url.match(/metamask.io/)) {
|
if (tab0 && selectedUrl.match(/popup.html/)) {
|
||||||
await driver.switchTo().window(tab1)
|
await closeAllWindowHandlesExcept(driver, tab0)
|
||||||
await driver.close()
|
} else if (tab1) {
|
||||||
await driver.switchTo().window(tab2)
|
|
||||||
} else if (tab2) {
|
|
||||||
await driver.switchTo().window(tab2)
|
|
||||||
await driver.close()
|
|
||||||
await driver.switchTo().window(tab1)
|
await driver.switchTo().window(tab1)
|
||||||
|
selectedUrl = await driver.getCurrentUrl()
|
||||||
|
await delay(tinyDelayMs)
|
||||||
|
if (selectedUrl.match(/popup.html/)) {
|
||||||
|
await closeAllWindowHandlesExcept(driver, tab1)
|
||||||
|
} else if (tab2) {
|
||||||
|
await driver.switchTo().window(tab2)
|
||||||
|
selectedUrl = await driver.getCurrentUrl()
|
||||||
|
selectedUrl.match(/popup.html/) && await closeAllWindowHandlesExcept(driver, tab2)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('popup.html not found')
|
||||||
}
|
}
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
const [appTab] = await driver.getAllWindowHandles()
|
||||||
|
await driver.switchTo().window(appTab)
|
||||||
|
await delay(tinyDelayMs)
|
||||||
|
|
||||||
|
const okayBtn = await findElement(driver, By.xpath("//button[contains(text(), 'Ok')]"))
|
||||||
|
await okayBtn.click()
|
||||||
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
await loadExtension(driver, extensionId)
|
||||||
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const continueBtn = await findElement(driver, By.css('.welcome-screen__button'))
|
const continueBtn = await findElement(driver, By.css('.welcome-screen__button'))
|
||||||
await continueBtn.click()
|
await continueBtn.click()
|
||||||
|
@ -59,6 +59,13 @@ describe('Metamask popup page', function () {
|
|||||||
await driver.switchTo().window(windowHandles[0])
|
await driver.switchTo().window(windowHandles[0])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('does not select the new UI option', async () => {
|
||||||
|
await delay(300)
|
||||||
|
const button = await driver.findElement(By.xpath("//button[contains(text(), 'No thanks, maybe later')]"))
|
||||||
|
await button.click()
|
||||||
|
await delay(1000)
|
||||||
|
})
|
||||||
|
|
||||||
it('sets provider type to localhost', async function () {
|
it('sets provider type to localhost', async function () {
|
||||||
await delay(300)
|
await delay(300)
|
||||||
await setProviderType('localhost')
|
await setProviderType('localhost')
|
||||||
@ -133,9 +140,9 @@ describe('Metamask popup page', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('adds a second account', async function () {
|
it('adds a second account', async function () {
|
||||||
await driver.findElement(By.css('#app-content > div > div.full-width > div > div:nth-child(2) > span > div')).click()
|
await driver.findElement(By.css('div.full-width > div > div:nth-child(2) > span > div')).click()
|
||||||
await delay(300)
|
await delay(300)
|
||||||
await driver.findElement(By.css('#app-content > div > div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(3) > span')).click()
|
await driver.findElement(By.css('div.full-width > div > div:nth-child(2) > span > div > div > span > div > li:nth-child(3) > span')).click()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows account address', async function () {
|
it('shows account address', async function () {
|
||||||
@ -146,7 +153,7 @@ describe('Metamask popup page', function () {
|
|||||||
it('logs out of the vault', async () => {
|
it('logs out of the vault', async () => {
|
||||||
await driver.findElement(By.css('.sandwich-expando')).click()
|
await driver.findElement(By.css('.sandwich-expando')).click()
|
||||||
await delay(500)
|
await delay(500)
|
||||||
const logoutButton = await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)'))
|
const logoutButton = await driver.findElement(By.css('.menu-droppo > li:nth-child(3)'))
|
||||||
assert.equal(await logoutButton.getText(), 'Log Out')
|
assert.equal(await logoutButton.getText(), 'Log Out')
|
||||||
await logoutButton.click()
|
await logoutButton.click()
|
||||||
})
|
})
|
||||||
@ -178,7 +185,7 @@ describe('Metamask popup page', function () {
|
|||||||
it('logs out', async function () {
|
it('logs out', async function () {
|
||||||
await driver.findElement(By.css('.sandwich-expando')).click()
|
await driver.findElement(By.css('.sandwich-expando')).click()
|
||||||
await delay(200)
|
await delay(200)
|
||||||
const logOut = await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)'))
|
const logOut = await driver.findElement(By.css('.menu-droppo > li:nth-child(3)'))
|
||||||
assert.equal(await logOut.getText(), 'Log Out')
|
assert.equal(await logOut.getText(), 'Log Out')
|
||||||
await logOut.click()
|
await logOut.click()
|
||||||
await delay(300)
|
await delay(300)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user