diff options
author | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2018-11-22 02:51:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-22 02:51:04 +0800 |
commit | 66e0de73c5511b49e24b93667d49d0b4accd89e3 (patch) | |
tree | 425d3e92f4219d2aa96d47cb407d866ec39316f4 /test | |
parent | 80d09d019265ec5cf1c34ecf84cc07746e6bc04d (diff) | |
parent | e68008edf483cdf67a1a97a048fbbe610097d050 (diff) | |
download | tangerine-wallet-browser-66e0de73c5511b49e24b93667d49d0b4accd89e3.tar tangerine-wallet-browser-66e0de73c5511b49e24b93667d49d0b4accd89e3.tar.gz tangerine-wallet-browser-66e0de73c5511b49e24b93667d49d0b4accd89e3.tar.bz2 tangerine-wallet-browser-66e0de73c5511b49e24b93667d49d0b4accd89e3.tar.lz tangerine-wallet-browser-66e0de73c5511b49e24b93667d49d0b4accd89e3.tar.xz tangerine-wallet-browser-66e0de73c5511b49e24b93667d49d0b4accd89e3.tar.zst tangerine-wallet-browser-66e0de73c5511b49e24b93667d49d0b4accd89e3.zip |
Merge pull request #5334 from whymarrh/ui-switch
Default to the new UI for first time users
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/beta/drizzle.spec.js | 16 | ||||
-rw-r--r-- | test/e2e/beta/from-import-beta-ui.spec.js | 73 | ||||
-rw-r--r-- | test/e2e/beta/helpers.js | 21 | ||||
-rw-r--r-- | test/e2e/beta/metamask-beta-responsive-ui.spec.js | 71 | ||||
-rw-r--r-- | test/e2e/beta/metamask-beta-ui.spec.js | 70 | ||||
-rw-r--r-- | test/integration/lib/first-time.js | 117 | ||||
-rw-r--r-- | test/integration/lib/mascara-first-time.js | 133 | ||||
-rw-r--r-- | test/integration/lib/navigate-txs.js | 87 |
8 files changed, 37 insertions, 551 deletions
diff --git a/test/e2e/beta/drizzle.spec.js b/test/e2e/beta/drizzle.spec.js index a9d72a9ba..e669dabcc 100644 --- a/test/e2e/beta/drizzle.spec.js +++ b/test/e2e/beta/drizzle.spec.js @@ -81,22 +81,6 @@ describe('MetaMask', function () { }) it('selects the new UI option', async () => { - try { - const overlay = await findElement(driver, By.css('.full-flex-height')) - await driver.wait(until.stalenessOf(overlay)) - } catch (e) {} - - let button - try { - button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) - } catch (e) { - await loadExtension(driver, extensionId) - await delay(largeDelayMs) - button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) - } - await button.click() - await delay(regularDelayMs) - // Close all other tabs const [tab0, tab1, tab2] = await driver.getAllWindowHandles() await driver.switchTo().window(tab0) diff --git a/test/e2e/beta/from-import-beta-ui.spec.js b/test/e2e/beta/from-import-beta-ui.spec.js index 77a61a73e..4273e7e39 100644 --- a/test/e2e/beta/from-import-beta-ui.spec.js +++ b/test/e2e/beta/from-import-beta-ui.spec.js @@ -12,11 +12,9 @@ const { } = require('../func') const { checkBrowserForConsoleErrors, - closeAllWindowHandlesExcept, verboseReportOnFailure, findElement, findElements, - loadExtension, } = require('./helpers') @@ -27,7 +25,6 @@ describe('Using MetaMask with an existing account', function () { const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent' const testAddress = '0xE18035BF8712672935FDB4e5e431b1a0183d2DFC' const testPrivateKey2 = '14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6' - const tinyDelayMs = 500 const regularDelayMs = 1000 const largeDelayMs = regularDelayMs * 2 @@ -40,7 +37,7 @@ describe('Using MetaMask with an existing account', function () { const extensionPath = path.resolve('dist/chrome') driver = buildChromeWebDriver(extensionPath) extensionId = await getExtensionIdChrome(driver) - await driver.get(`chrome-extension://${extensionId}/popup.html`) + await driver.get(`chrome-extension://${extensionId}/home.html`) await delay(regularDelayMs) break } @@ -50,7 +47,7 @@ describe('Using MetaMask with an existing account', function () { await installWebExt(driver, extensionPath) await delay(regularDelayMs) extensionId = await getExtensionIdFirefox(driver) - await driver.get(`moz-extension://${extensionId}/popup.html`) + await driver.get(`moz-extension://${extensionId}/home.html`) await delay(regularDelayMs) break } @@ -75,69 +72,13 @@ describe('Using MetaMask with an existing account', function () { await driver.quit() }) - describe('New UI setup', async function () { - it('switches to first tab', async function () { - await delay(tinyDelayMs) - const [firstTab] = await driver.getAllWindowHandles() - await driver.switchTo().window(firstTab) - await delay(regularDelayMs) - }) - - it('selects the new UI option', async () => { - try { - const overlay = await findElement(driver, By.css('.full-flex-height')) - await driver.wait(until.stalenessOf(overlay)) - } catch (e) {} - - let button - try { - button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) - } catch (e) { - await loadExtension(driver, extensionId) - await delay(largeDelayMs) - button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) - } - await button.click() - await delay(regularDelayMs) - - // Close all other tabs - const [tab0, tab1, tab2] = await driver.getAllWindowHandles() - await driver.switchTo().window(tab0) - await delay(tinyDelayMs) - - 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() - await delay(regularDelayMs) + describe('First time flow starting from an existing seed phrase', () => { + it('clicks the continue button on the welcome screen', async () => { + const welcomeScreenBtn = await findElement(driver, By.css('.welcome-screen__button')) + welcomeScreenBtn.click() + await delay(largeDelayMs) }) - }) - describe('First time flow starting from an existing seed phrase', () => { it('imports a seed phrase', async () => { const [seedPhrase] = await findElements(driver, By.xpath(`//a[contains(text(), 'Import with seed phrase')]`)) await seedPhrase.click() diff --git a/test/e2e/beta/helpers.js b/test/e2e/beta/helpers.js index 08416857e..5e3f45b2b 100644 --- a/test/e2e/beta/helpers.js +++ b/test/e2e/beta/helpers.js @@ -85,11 +85,22 @@ async function openNewPage (driver, url) { await delay(1000) } -async function waitUntilXWindowHandles (driver, x) { - const windowHandles = await driver.getAllWindowHandles() - if (windowHandles.length === x) return - await delay(1000) - return await waitUntilXWindowHandles(driver, x) +async function waitUntilXWindowHandles (driver, x, delayStep = 1000, timeout = 5000) { + let timeElapsed = 0 + async function _pollWindowHandles () { + const windowHandles = await driver.getAllWindowHandles() + if (windowHandles.length === x) { + return + } + await delay(delayStep) + timeElapsed += delayStep + if (timeElapsed > timeout) { + throw new Error('waitUntilXWindowHandles timed out polling window handles') + } else { + await _pollWindowHandles() + } + } + return await _pollWindowHandles() } async function switchToWindowWithTitle (driver, title, windowHandles) { diff --git a/test/e2e/beta/metamask-beta-responsive-ui.spec.js b/test/e2e/beta/metamask-beta-responsive-ui.spec.js index b93563b25..107f9aa6c 100644 --- a/test/e2e/beta/metamask-beta-responsive-ui.spec.js +++ b/test/e2e/beta/metamask-beta-responsive-ui.spec.js @@ -12,7 +12,6 @@ const { } = require('../func') const { checkBrowserForConsoleErrors, - closeAllWindowHandlesExcept, findElement, findElements, loadExtension, @@ -37,7 +36,7 @@ describe('MetaMask', function () { const extPath = path.resolve('dist/chrome') driver = buildChromeWebDriver(extPath, { responsive: true }) extensionId = await getExtensionIdChrome(driver) - await driver.get(`chrome-extension://${extensionId}/popup.html`) + await driver.get(`chrome-extension://${extensionId}/home.html`) break } case 'firefox': { @@ -46,7 +45,7 @@ describe('MetaMask', function () { await installWebExt(driver, extPath) await delay(700) extensionId = await getExtensionIdFirefox(driver) - await driver.get(`moz-extension://${extensionId}/popup.html`) + await driver.get(`moz-extension://${extensionId}/home.html`) } } }) @@ -69,69 +68,13 @@ describe('MetaMask', function () { await driver.quit() }) - describe('New UI setup', async function () { - it('switches to first tab', async function () { - await delay(tinyDelayMs) - const [firstTab] = await driver.getAllWindowHandles() - await driver.switchTo().window(firstTab) - await delay(regularDelayMs) - }) - - it('selects the new UI option', async () => { - try { - const overlay = await findElement(driver, By.css('.full-flex-height')) - await driver.wait(until.stalenessOf(overlay)) - } catch (e) {} - - let button - try { - button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) - } catch (e) { - await loadExtension(driver, extensionId) - await delay(largeDelayMs) - button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) - } - await button.click() - await delay(regularDelayMs) - - // Close all other tabs - const [tab0, tab1, tab2] = await driver.getAllWindowHandles() - await driver.switchTo().window(tab0) - await delay(tinyDelayMs) - - 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() - await delay(regularDelayMs) + describe('Going through the first time flow', () => { + it('clicks the continue button on the welcome screen', async () => { + const welcomeScreenBtn = await findElement(driver, By.css('.welcome-screen__button')) + welcomeScreenBtn.click() + await delay(largeDelayMs) }) - }) - describe('Going through the first time flow', () => { it('accepts a secure password', async () => { const passwordBox = await findElement(driver, By.css('.create-password #create-password')) const passwordBoxConfirm = await findElement(driver, By.css('.create-password #confirm-password')) diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index 0ef945f8d..9e96ceee6 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -42,7 +42,7 @@ describe('MetaMask', function () { const extPath = path.resolve('dist/chrome') driver = buildChromeWebDriver(extPath) extensionId = await getExtensionIdChrome(driver) - await driver.get(`chrome-extension://${extensionId}/popup.html`) + await driver.get(`chrome-extension://${extensionId}/home.html`) break } case 'firefox': { @@ -51,7 +51,7 @@ describe('MetaMask', function () { await installWebExt(driver, extPath) await delay(700) extensionId = await getExtensionIdFirefox(driver) - await driver.get(`moz-extension://${extensionId}/popup.html`) + await driver.get(`moz-extension://${extensionId}/home.html`) } } }) @@ -74,69 +74,13 @@ describe('MetaMask', function () { await driver.quit() }) - describe('New UI setup', async function () { - it('switches to first tab', async function () { - await delay(tinyDelayMs) - const [firstTab] = await driver.getAllWindowHandles() - await driver.switchTo().window(firstTab) - await delay(regularDelayMs) - }) - - it('selects the new UI option', async () => { - try { - const overlay = await findElement(driver, By.css('.full-flex-height')) - await driver.wait(until.stalenessOf(overlay)) - } catch (e) {} - - let button - try { - button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) - } catch (e) { - await loadExtension(driver, extensionId) - await delay(largeDelayMs) - button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) - } - await button.click() - await delay(regularDelayMs) - - // Close all other tabs - const [tab0, tab1, tab2] = await driver.getAllWindowHandles() - await driver.switchTo().window(tab0) - await delay(tinyDelayMs) - - 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() - await delay(regularDelayMs) + describe('Going through the first time flow', () => { + it('clicks the continue button on the welcome screen', async () => { + const welcomeScreenBtn = await findElement(driver, By.css('.welcome-screen__button')) + welcomeScreenBtn.click() + await delay(largeDelayMs) }) - }) - describe('Going through the first time flow', () => { it('accepts a secure password', async () => { const passwordBox = await findElement(driver, By.css('.create-password #create-password')) const passwordBoxConfirm = await findElement(driver, By.css('.create-password #confirm-password')) diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js deleted file mode 100644 index 8cacd7f14..000000000 --- a/test/integration/lib/first-time.js +++ /dev/null @@ -1,117 +0,0 @@ -const reactTriggerChange = require('react-trigger-change') -const PASSWORD = 'password123' -const runMascaraFirstTimeTest = require('./mascara-first-time') -const { - timeout, - findAsync, -} = require('../../lib/util') - -QUnit.module('first time usage') - -QUnit.test('render init screen', (assert) => { - const done = assert.async() - runFirstTimeUsageTest(assert).then(done).catch((err) => { - assert.notOk(err, `Error was thrown: ${err.stack}`) - done() - }) -}) - -async function runFirstTimeUsageTest(assert, done) { - if (window.METAMASK_PLATFORM_TYPE === 'mascara') { - return runMascaraFirstTimeTest(assert, done) - } - - const selectState = $('select') - selectState.val('first time') - reactTriggerChange(selectState[0]) - - const app = $('#app-content') - - // Selects new ui - const tryNewUIButton = (await findAsync(app, 'button.negative'))[0] - tryNewUIButton.click() - await timeout() - - // recurse notices - while (true) { - const button = await findAsync(app, 'button') - if (button.html() === 'Accept') { - // still notices to accept - const termsPageRaw = await findAsync(app, '.markdown') - const termsPage = (await findAsync(app, '.markdown'))[0] - console.log('termsPageRaw', termsPageRaw) - termsPage.scrollTop = termsPage.scrollHeight - console.log('Clearing notice') - button.click() - } else { - // exit loop - console.log('No more notices...') - break - } - } - - // Scroll through terms - const title = (await findAsync(app, 'h1'))[0] - assert.equal(title.textContent, 'MetaMask', 'title screen') - - // enter password - const pwBox = (await findAsync(app, '#password-box'))[0] - const confBox = (await findAsync(app, '#password-box-confirm'))[0] - pwBox.value = PASSWORD - confBox.value = PASSWORD - - // create vault - const createButton = (await findAsync(app, 'button.primary'))[0] - createButton.click() - - await timeout() - const created = (await findAsync(app, 'h3'))[0] - assert.equal(created.textContent, 'Vault Created', 'Vault created screen') - - // Agree button - const button = (await findAsync(app, 'button'))[0] - assert.ok(button, 'button present') - button.click() - - const detail = (await findAsync(app, '.account-detail-section'))[0] - assert.ok(detail, 'Account detail section loaded.') - - const sandwich = (await findAsync(app, '.sandwich-expando'))[0] - sandwich.click() - - const menu = (await findAsync(app, '.menu-droppo'))[0] - const children = menu.children - const logout = children[2] - assert.ok(logout, 'Lock menu item found') - logout.click() - - const pwBox2 = (await findAsync(app, '#password-box'))[0] - pwBox2.value = PASSWORD - - const createButton2 = (await findAsync(app, 'button.primary'))[0] - createButton2.click() - - const detail2 = (await findAsync(app, '.account-detail-section'))[0] - assert.ok(detail2, 'Account detail section loaded again.') - - // open account settings dropdown - const qrButton = (await findAsync(app, '.fa.fa-ellipsis-h'))[0] - qrButton.click() - - // qr code item - const qrButton2 = (await findAsync(app, '.dropdown-menu-item'))[1] - qrButton2.click() - - const qrHeader = (await findAsync(app, '.qr-header'))[0] - const qrContainer = (await findAsync(app, '#qr-container'))[0] - assert.equal(qrHeader.textContent, 'Account 1', 'Should show account label.') - assert.ok(qrContainer, 'QR Container found') - - const networkMenu = (await findAsync(app, '.network-indicator'))[0] - networkMenu.click() - - const networkMenu2 = (await findAsync(app, '.network-indicator'))[0] - const children2 = networkMenu2.children - children2.length[3] - assert.ok(children2, 'All network options present') -} diff --git a/test/integration/lib/mascara-first-time.js b/test/integration/lib/mascara-first-time.js deleted file mode 100644 index 6756b83f9..000000000 --- a/test/integration/lib/mascara-first-time.js +++ /dev/null @@ -1,133 +0,0 @@ -const PASSWORD = 'password123' -const { - timeout, - findAsync, - queryAsync, -} = require('../../lib/util') - -async function runFirstTimeUsageTest (assert, done) { - await timeout(4000) - - const app = await queryAsync($, '#app-content') - - // Used to set values on TextField input component - const nativeInputValueSetter = Object.getOwnPropertyDescriptor( - window.HTMLInputElement.prototype, 'value' - ).set - - await skipNotices(app) - - const welcomeButton = (await findAsync(app, '.welcome-screen__button'))[0] - welcomeButton.click() - - // Scroll through terms - const title = (await findAsync(app, '.create-password__title')).text() - assert.equal(title, 'Create Password', 'create password screen') - - // enter password - const pwBox = (await findAsync(app, '#create-password'))[0] - const confBox = (await findAsync(app, '#confirm-password'))[0] - - nativeInputValueSetter.call(pwBox, PASSWORD) - pwBox.dispatchEvent(new Event('input', { bubbles: true})) - - nativeInputValueSetter.call(confBox, PASSWORD) - confBox.dispatchEvent(new Event('input', { bubbles: true})) - - // Create Password - const createButton = (await findAsync(app, 'button.first-time-flow__button'))[0] - createButton.click() - - const created = (await findAsync(app, '.unique-image__title'))[0] - assert.equal(created.textContent, 'Your unique account image', 'unique image screen') - - // Agree button - const button = (await findAsync(app, 'button'))[0] - assert.ok(button, 'button present') - button.click() - - await skipNotices(app) - - // secret backup phrase - const seedTitle = (await findAsync(app, '.backup-phrase__title'))[0] - assert.equal(seedTitle.textContent, 'Secret Backup Phrase', 'seed phrase screen') - ;(await findAsync(app, '.backup-phrase__reveal-button')).click() - const seedPhrase = (await findAsync(app, '.backup-phrase__secret-words')).text().split(' ') - ;(await findAsync(app, '.first-time-flow__button')).click() - - await timeout() - const selectPhrase = text => { - const option = $('.backup-phrase__confirm-seed-option') - .filter((i, d) => d.textContent === text)[0] - $(option).click() - } - - seedPhrase.forEach(sp => selectPhrase(sp)) - ;(await findAsync(app, '.first-time-flow__button')).click() - - // Deposit Ether Screen - const depositEthTitle = (await findAsync(app, '.page-container__title'))[0] - assert.equal(depositEthTitle.textContent, 'Deposit Ether', 'deposit ether screen') - ;(await findAsync(app, '.page-container__header-close')).click() - - const menu = (await findAsync(app, '.account-menu__icon'))[0] - menu.click() - - const lock = (await findAsync(app, '.account-menu__logout-button'))[0] - assert.ok(lock, 'Lock menu item found') - lock.click() - - await timeout(5000) - - const pwBox2 = (await findAsync(app, '#password'))[0] - pwBox2.focus() - await timeout(1000) - - nativeInputValueSetter.call(pwBox2, PASSWORD) - pwBox2.dispatchEvent(new Event('input', { bubbles: true})) - - const createButton2 = (await findAsync(app, 'button[type="submit"]'))[0] - createButton2.click() - - const detail2 = (await findAsync(app, '.wallet-view'))[0] - assert.ok(detail2, 'Account detail section loaded again.') - - // open account settings dropdown - const qrButton = (await findAsync(app, '.wallet-view__details-button'))[0] - qrButton.click() - - const qrHeader = (await findAsync(app, '.editable-label__value'))[0] - const qrContainer = (await findAsync(app, '.qr-wrapper'))[0] - assert.equal(qrHeader.textContent, 'Account 1', 'Should show account label.') - assert.ok(qrContainer, 'QR Container found') - - const networkMenu = (await findAsync(app, '.network-component'))[0] - networkMenu.click() - - const networkMenu2 = (await findAsync(app, '.network-indicator'))[0] - const children2 = networkMenu2.children - children2.length[3] - assert.ok(children2, 'All network options present') -} - -module.exports = runFirstTimeUsageTest - -async function skipNotices (app) { - while (true) { - const button = await findAsync(app, 'button') - if (button && button.html() === 'Accept') { - // still notices to accept - const termsPage = (await findAsync(app, '.markdown'))[0] - if (!termsPage) { - break - } - termsPage.scrollTop = termsPage.scrollHeight - await timeout() - button.click() - await timeout() - } else { - console.log('No more notices...') - break - } - } -} diff --git a/test/integration/lib/navigate-txs.js b/test/integration/lib/navigate-txs.js deleted file mode 100644 index 0679d6b00..000000000 --- a/test/integration/lib/navigate-txs.js +++ /dev/null @@ -1,87 +0,0 @@ -const reactTriggerChange = require('react-trigger-change') -const { - timeout, - queryAsync, -} = require('../../lib/util') - -QUnit.module('navigate txs') - -QUnit.test('successful navigate', (assert) => { - const done = assert.async() - runNavigateTxsFlowTest(assert) - .then(done) - .catch(err => { - assert.notOk(err, `Error was thrown: ${err.stack}`) - done() - }) -}) - -async function runNavigateTxsFlowTest (assert, done) { - const selectState = await queryAsync($, 'select') - - selectState.val('navigate txs') - reactTriggerChange(selectState[0]) - - // Confirm navigation buttons present - let navigateTxButtons = await queryAsync($, '.confirm-page-container-navigation__arrow') - assert.ok(navigateTxButtons[0], 'navigation button present') - assert.ok(navigateTxButtons[1], 'navigation button present') - assert.ok(navigateTxButtons[2], 'navigation button present') - assert.ok(navigateTxButtons[3], 'navigation button present') - - // Verify number of transactions present - let trxNum = await queryAsync($, '.confirm-page-container-navigation') - assert.equal(trxNum[0].innerText.includes('1'), true, 'starts on first') - - // Verify correct route - let summaryAction = await queryAsync($, '.confirm-page-container-summary__action') - assert.equal(summaryAction[0].innerText, 'CONTRACT DEPLOYMENT', 'correct route') - - // Click navigation button - navigateTxButtons[2].click() - await timeout(2000) - - // Verify transaction changed to num 2 and routed correctly - trxNum = await queryAsync($, '.confirm-page-container-navigation') - assert.equal(trxNum[0].innerText.includes('2'), true, 'changed transaction right') - summaryAction = await queryAsync($, '.confirm-page-container-summary__action') - // assert.equal(summaryAction[0].innerText, 'CONFIRM', 'correct route') - - // Click navigation button - navigateTxButtons = await queryAsync($, '.confirm-page-container-navigation__arrow') - navigateTxButtons[2].click() - - // Verify transation changed to num 3 and routed correctly - trxNum = await queryAsync($, '.confirm-page-container-navigation') - assert.equal(trxNum[0].innerText.includes('3'), true, 'changed transaction right') - summaryAction = await queryAsync($, '.confirm-page-container-summary__action') - assert.equal(summaryAction[0].innerText, 'CONFIRM', 'correct route') - - // Click navigation button - navigateTxButtons = await queryAsync($, '.confirm-page-container-navigation__arrow') - navigateTxButtons[2].click() - - // Verify transation changed to num 4 and routed correctly - trxNum = await queryAsync($, '.confirm-page-container-navigation') - assert.equal(trxNum[0].innerText.split('4').length, 3, '4 transactions present') - summaryAction = await queryAsync($, '.confirm-page-container-summary__action') - assert.equal(summaryAction[0].innerText, 'TRANSFER', 'correct route') - - // Verify left arrow is working correctly - navigateTxButtons = await queryAsync($, '.confirm-page-container-navigation__arrow') - navigateTxButtons[1].click() - trxNum = await queryAsync($, '.confirm-page-container-navigation') - assert.equal(trxNum[0].innerText.includes('3'), true, 'changed transaction left') - - // Verify navigate to last transaction is working correctly - navigateTxButtons = await queryAsync($, '.confirm-page-container-navigation__arrow') - navigateTxButtons[3].click() - trxNum = await queryAsync($, '.confirm-page-container-navigation') - assert.equal(trxNum[0].innerText.split('4').length, 3, 'navigate to last transaction') - - // Verify navigate to first transaction is working correctly - navigateTxButtons = await queryAsync($, '.confirm-page-container-navigation__arrow') - navigateTxButtons[0].click() - trxNum = await queryAsync($, '.confirm-page-container-navigation') - assert.equal(trxNum[0].innerText.includes('1'), true, 'navigate to first transaction') -} |