diff options
Diffstat (limited to 'test/e2e/beta/metamask-beta-ui.spec.js')
-rw-r--r-- | test/e2e/beta/metamask-beta-ui.spec.js | 170 |
1 files changed, 74 insertions, 96 deletions
diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index ca1977c5a..3ad5c2d61 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -75,30 +75,11 @@ describe('MetaMask', function () { }) describe('New UI setup', async function () { - let networkSelector it('switches to first tab', async function () { + await delay(tinyDelayMs) const [firstTab] = await driver.getAllWindowHandles() await driver.switchTo().window(firstTab) 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 () => { @@ -107,27 +88,40 @@ describe('MetaMask', function () { await driver.wait(until.stalenessOf(overlay)) } 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 delay(regularDelayMs) // Close all other tabs - const [oldUi, tab1, tab2] = await driver.getAllWindowHandles() - await driver.switchTo().window(oldUi) - await driver.close() + const [tab0, tab1, tab2] = await driver.getAllWindowHandles() + await driver.switchTo().window(tab0) + await delay(tinyDelayMs) - await driver.switchTo().window(tab1) - const tab1Url = await driver.getCurrentUrl() - if (tab1Url.match(/metamask.io/)) { - await driver.switchTo().window(tab1) - await driver.close() - await driver.switchTo().window(tab2) - } else if (tab2) { - await driver.switchTo().window(tab2) - await driver.close() + let selectedUrl = await driver.getCurrentUrl() + await delay(tinyDelayMs) + if (tab0 && selectedUrl.match(/popup.html/)) { + await closeAllWindowHandlesExcept(driver, tab0) + } else if (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) + const [appTab] = await driver.getAllWindowHandles() + await driver.switchTo().window(appTab) + await delay(tinyDelayMs) + + await loadExtension(driver, extensionId) + await delay(regularDelayMs) const continueBtn = await findElement(driver, By.css('.welcome-screen__button')) await continueBtn.click() @@ -201,7 +195,16 @@ describe('MetaMask', function () { await delay(regularDelayMs) }) - async function retypeSeedPhrase (words, wasReloaded) { + async function clickWordAndWait (word) { + const xpathClass = 'backup-phrase__confirm-seed-option backup-phrase__confirm-seed-option--unselected' + const xpath = `//button[@class='${xpathClass}' and contains(text(), '${word}')]` + const word0 = await findElement(driver, By.xpath(xpath), 10000) + + await word0.click() + await delay(tinyDelayMs) + } + + async function retypeSeedPhrase (words, wasReloaded, count = 0) { try { if (wasReloaded) { const byRevealButton = By.css('.backup-phrase__secret-blocker .backup-phrase__reveal-button') @@ -215,67 +218,26 @@ describe('MetaMask', function () { await delay(regularDelayMs) } - const word0 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[0]}')]`), 10000) - - await word0.click() - await delay(tinyDelayMs) - - const word1 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[1]}')]`), 10000) - - await word1.click() - await delay(tinyDelayMs) - - const word2 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[2]}')]`), 10000) - - await word2.click() - await delay(tinyDelayMs) - - const word3 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[3]}')]`), 10000) - - await word3.click() - await delay(tinyDelayMs) + await clickWordAndWait(words[0]) + await clickWordAndWait(words[1]) + await clickWordAndWait(words[2]) + await clickWordAndWait(words[3]) + await clickWordAndWait(words[4]) + await clickWordAndWait(words[5]) + await clickWordAndWait(words[6]) + await clickWordAndWait(words[7]) + await clickWordAndWait(words[8]) + await clickWordAndWait(words[9]) + await clickWordAndWait(words[10]) + await clickWordAndWait(words[11]) - const word4 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[4]}')]`), 10000) - - await word4.click() - await delay(tinyDelayMs) - - const word5 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[5]}')]`), 10000) - - await word5.click() - await delay(tinyDelayMs) - - const word6 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[6]}')]`), 10000) - - await word6.click() - await delay(tinyDelayMs) - - const word7 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[7]}')]`), 10000) - - await word7.click() - await delay(tinyDelayMs) - - const word8 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[8]}')]`), 10000) - - await word8.click() - await delay(tinyDelayMs) - - const word9 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[9]}')]`), 10000) - - await word9.click() - await delay(tinyDelayMs) - - const word10 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[10]}')]`), 10000) - - await word10.click() - await delay(tinyDelayMs) - - const word11 = await findElement(driver, By.xpath(`//button[contains(text(), '${words[11]}')]`), 10000) - await word11.click() - await delay(tinyDelayMs) } catch (e) { - await loadExtension(driver, extensionId) - await retypeSeedPhrase(words, true) + if (count > 2) { + throw e + } else { + await loadExtension(driver, extensionId) + await retypeSeedPhrase(words, true, count + 1) + } } } @@ -389,6 +351,16 @@ describe('MetaMask', function () { await delay(regularDelayMs) }) + it('switches to localhost', async () => { + const networkDropdown = await findElement(driver, By.css('.network-name')) + await networkDropdown.click() + await delay(regularDelayMs) + + const [localhost] = await findElements(driver, By.xpath(`//span[contains(text(), 'Localhost')]`)) + await localhost.click() + await delay(largeDelayMs * 2) + }) + it('balance renders', async () => { const balance = await findElement(driver, By.css('.balance-display .token-amount')) await driver.wait(until.elementTextMatches(balance, /100.+ETH/)) @@ -512,7 +484,7 @@ describe('MetaMask', function () { it('displays the contract creation data', async () => { const dataTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Data')]`)) - dataTab.click() + await dataTab.click() await delay(regularDelayMs) await findElement(driver, By.xpath(`//div[contains(text(), '127.0.0.1')]`)) @@ -522,7 +494,7 @@ describe('MetaMask', function () { assert.equal(confirmDataText.match(/0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff/)) const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`)) - detailsTab.click() + await detailsTab.click() await delay(regularDelayMs) }) @@ -543,9 +515,15 @@ describe('MetaMask', function () { await driver.switchTo().window(dapp) await delay(regularDelayMs) + let contractStatus = await driver.findElement(By.css('#contractStatus')) + await driver.wait(until.elementTextMatches(contractStatus, /Deployed/)) + const depositButton = await findElement(driver, By.css('#depositButton')) await depositButton.click() - await delay(regularDelayMs) + await delay(largeDelayMs) + + contractStatus = await driver.findElement(By.css('#contractStatus')) + await driver.wait(until.elementTextMatches(contractStatus, /Deposit\sinitiated/)) await driver.switchTo().window(extension) await delay(largeDelayMs) |