From 592c2e59484d94f2674ea2a9570436b664d94b0a Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 17:02:40 -0700 Subject: test - add auto screen shotter --- test/screens/func.js | 18 ++++++ test/screens/new.spec.js | 148 +++++++++++++++++++++++++++++++++++++++++++++++ test/screens/old.spec.js | 105 +++++++++++++++++++++++++++++++++ 3 files changed, 271 insertions(+) create mode 100644 test/screens/func.js create mode 100644 test/screens/new.spec.js create mode 100644 test/screens/old.spec.js (limited to 'test') diff --git a/test/screens/func.js b/test/screens/func.js new file mode 100644 index 000000000..733225565 --- /dev/null +++ b/test/screens/func.js @@ -0,0 +1,18 @@ +require('chromedriver') +const webdriver = require('selenium-webdriver') + +exports.delay = function delay (time) { + return new Promise(resolve => setTimeout(resolve, time)) +} + + +exports.buildWebDriver = function buildWebDriver (extPath) { + return new webdriver.Builder() + .withCapabilities({ + chromeOptions: { + args: [`load-extension=${extPath}`], + }, + }) + .forBrowser('chrome') + .build() +} diff --git a/test/screens/new.spec.js b/test/screens/new.spec.js new file mode 100644 index 000000000..c5a8ef859 --- /dev/null +++ b/test/screens/new.spec.js @@ -0,0 +1,148 @@ +const path = require('path') +const fs = require('fs') +const pify = require('pify') +const mkdirp = require('mkdirp') +const webdriver = require('selenium-webdriver') +const endOfStream = require('end-of-stream') +const GIFEncoder = require('gifencoder') +const pngFileStream = require('png-file-stream') +const sizeOfPng = require('image-size/lib/types/png') +const By = webdriver.By +const { delay, buildWebDriver } = require('./func') + +captureAllScreens().catch(console.error) + +async function captureAllScreens() { + let screenshotCount = 0 + + // setup selenium and install extension + const extPath = path.resolve('dist/chrome') + const driver = buildWebDriver(extPath) + await driver.get('chrome://extensions-frame') + const elems = await driver.findElements(By.css('.extension-list-item-wrapper')) + const extensionId = await elems[1].getAttribute('id') + await driver.get(`chrome-extension://${extensionId}/popup.html`) + await delay(500) + const tabs = await driver.getAllWindowHandles() + await driver.switchTo().window(tabs[0]) + await delay(300) + + // common names + let button + + await captureScreenShot('start-old') + + // click try new ui + await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-center.flex-grow > p')).click() + await captureScreenShot('start-new') + await delay(300) + await captureScreenShot('start-new2') + await delay(300) + await captureScreenShot('start-new3') + await delay(300) + await captureScreenShot('start-new4') + await delay(300) + await captureScreenShot('start-new5') + + // exit early for dev + await generateGif() + await driver.quit() + return + + + await captureScreenShot('privacy') + + const privacy = await driver.findElement(By.css('.terms-header')).getText() + driver.findElement(By.css('button')).click() + await delay(300) + await captureScreenShot('terms') + + await delay(300) + const terms = await driver.findElement(By.css('.terms-header')).getText() + await delay(300) + const element = driver.findElement(By.linkText('Attributions')) + await driver.executeScript('arguments[0].scrollIntoView(true)', element) + await delay(300) + button = await driver.findElement(By.css('button')) + const buttonEnabled = await button.isEnabled() + await delay(500) + await captureScreenShot('terms-scrolled') + + await button.click() + await delay(300) + await captureScreenShot('choose-password') + + const passwordBox = await driver.findElement(By.id('password-box')) + const passwordBoxConfirm = await driver.findElement(By.id('password-box-confirm')) + button = driver.findElement(By.css('button')) + passwordBox.sendKeys('123456789') + passwordBoxConfirm.sendKeys('123456789') + await delay(500) + await captureScreenShot('choose-password-filled') + + await button.click() + await delay(700) + this.seedPhase = await driver.findElement(By.css('.twelve-word-phrase')).getText() + await captureScreenShot('seed phrase') + + const continueAfterSeedPhrase = await driver.findElement(By.css('button')) + await continueAfterSeedPhrase.click() + await delay(300) + await captureScreenShot('main screen') + + await driver.findElement(By.css('.sandwich-expando')).click() + await delay(500) + await captureScreenShot('menu') + + // await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)')).click() + // await captureScreenShot('main screen') + // it('should accept account password after lock', async () => { + // await delay(500) + // await driver.findElement(By.id('password-box')).sendKeys('123456789') + // await driver.findElement(By.css('button')).click() + // await delay(500) + // }) + // + // it('should show QR code option', async () => { + // await delay(300) + // await driver.findElement(By.css('.fa-ellipsis-h')).click() + // await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div > div:nth-child(1) > flex-column > div.name-label > div > span > i > div > div > li:nth-child(3)')).click() + // await delay(300) + // }) + // + // it('should show the account address', async () => { + // this.accountAddress = await driver.findElement(By.css('.ellip-address')).getText() + // await driver.findElement(By.css('.fa-arrow-left')).click() + // await delay(500) + // }) + + // cleanup + await driver.quit() + + async function captureScreenShot(label) { + const shotIndex = screenshotCount + screenshotCount++ + const artifactDir = `./test-artifacts/screens/` + await pify(mkdirp)(artifactDir) + // capture screenshot + const screenshot = await driver.takeScreenshot() + await pify(fs.writeFile)(`${artifactDir}/${shotIndex} - ${label}.png`, screenshot, { encoding: 'base64' }) + } + + async function generateGif(){ + // calculate screenshot size + const screenshot = await driver.takeScreenshot() + const pngBuffer = Buffer.from(screenshot, 'base64') + const size = sizeOfPng.calculate(pngBuffer) + + // read all pngs into gif + const encoder = new GIFEncoder(size.width, size.height) + const stream = pngFileStream('./test-artifacts/screens/*.png') + .pipe(encoder.createWriteStream({ repeat: -1, delay: 500, quality: 10 })) + .pipe(fs.createWriteStream('./test-artifacts/screens/walkthrough.gif')) + + // wait for end + await pify(endOfStream)(stream) + } + +} diff --git a/test/screens/old.spec.js b/test/screens/old.spec.js new file mode 100644 index 000000000..87399d4b5 --- /dev/null +++ b/test/screens/old.spec.js @@ -0,0 +1,105 @@ +const path = require('path') +const fs = require('fs') +const pify = require('pify') +const mkdirp = require('mkdirp') +const webdriver = require('selenium-webdriver') +const By = webdriver.By +const { delay, buildWebDriver } = require('./func') + +captureAllScreens().catch(console.error) + +async function captureAllScreens() { + // setup selenium and install extension + const extPath = path.resolve('dist/chrome') + const driver = buildWebDriver(extPath) + await driver.get('chrome://extensions-frame') + const elems = await driver.findElements(By.css('.extension-list-item-wrapper')) + const extensionId = await elems[1].getAttribute('id') + await driver.get(`chrome-extension://${extensionId}/popup.html`) + await delay(500) + const tabs = await driver.getAllWindowHandles() + await driver.switchTo().window(tabs[0]) + await delay(300) + + // common names + let button + + await captureScreenShot('privacy') + + const privacy = await driver.findElement(By.css('.terms-header')).getText() + driver.findElement(By.css('button')).click() + await delay(300) + await captureScreenShot('terms') + + await delay(300) + const terms = await driver.findElement(By.css('.terms-header')).getText() + await delay(300) + const element = driver.findElement(By.linkText('Attributions')) + await driver.executeScript('arguments[0].scrollIntoView(true)', element) + await delay(300) + button = await driver.findElement(By.css('button')) + const buttonEnabled = await button.isEnabled() + await delay(500) + await captureScreenShot('terms-scrolled') + + await button.click() + await delay(300) + await captureScreenShot('choose-password') + + const passwordBox = await driver.findElement(By.id('password-box')) + const passwordBoxConfirm = await driver.findElement(By.id('password-box-confirm')) + button = driver.findElement(By.css('button')) + passwordBox.sendKeys('123456789') + passwordBoxConfirm.sendKeys('123456789') + await delay(500) + await captureScreenShot('choose-password-filled') + + await button.click() + await delay(700) + this.seedPhase = await driver.findElement(By.css('.twelve-word-phrase')).getText() + await captureScreenShot('seed phrase') + + const continueAfterSeedPhrase = await driver.findElement(By.css('button')) + await continueAfterSeedPhrase.click() + await delay(300) + await captureScreenShot('main screen') + + await driver.findElement(By.css('.sandwich-expando')).click() + await delay(500) + await captureScreenShot('menu') + + // await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)')).click() + // await captureScreenShot('main screen') + // it('should accept account password after lock', async () => { + // await delay(500) + // await driver.findElement(By.id('password-box')).sendKeys('123456789') + // await driver.findElement(By.css('button')).click() + // await delay(500) + // }) + // + // it('should show QR code option', async () => { + // await delay(300) + // await driver.findElement(By.css('.fa-ellipsis-h')).click() + // await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div > div:nth-child(1) > flex-column > div.name-label > div > span > i > div > div > li:nth-child(3)')).click() + // await delay(300) + // }) + // + // it('should show the account address', async () => { + // this.accountAddress = await driver.findElement(By.css('.ellip-address')).getText() + // await driver.findElement(By.css('.fa-arrow-left')).click() + // await delay(500) + // }) + + // cleanup + await driver.quit() + + async function captureScreenShot(label) { + const artifactDir = `./test-artifacts/${label}` + const filepathBase = `${artifactDir}` + await pify(mkdirp)(artifactDir) + // capture screenshot + const screenshot = await driver.takeScreenshot() + await pify(fs.writeFile)(`${filepathBase}/screenshot.png`, screenshot, { encoding: 'base64' }) + } + +} -- cgit v1.2.3 From 2979de2e6bae809d53a34b9c981e4f27ab6580e5 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 30 Mar 2018 02:08:29 -0230 Subject: Adds integration tests for rendering of tx list items. --- test/integration/lib/tx-list-items.js | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 test/integration/lib/tx-list-items.js (limited to 'test') diff --git a/test/integration/lib/tx-list-items.js b/test/integration/lib/tx-list-items.js new file mode 100644 index 000000000..d0056eb94 --- /dev/null +++ b/test/integration/lib/tx-list-items.js @@ -0,0 +1,61 @@ +const reactTriggerChange = require('../../lib/react-trigger-change') +const { + timeout, + queryAsync, + findAsync, +} = require('../../lib/util') + +QUnit.module('tx list items') + +QUnit.test('renders list items successfully', (assert) => { + const done = assert.async() + runTxListItemsTest(assert).then(done).catch((err) => { + assert.notOk(err, `Error was thrown: ${err.stack}`) + done() + }) +}) + +async function runTxListItemsTest(assert, done) { + console.log('*** start runTxListItemsTest') + const selectState = await queryAsync($, 'select') + selectState.val('tx list items') + reactTriggerChange(selectState[0]) + + const metamaskLogo = await queryAsync($, '.left-menu-wrapper') + assert.ok(metamaskLogo[0], 'metamask logo present') + metamaskLogo[0].click() + + const txListItems = await queryAsync($, '.tx-list-item') + assert.equal(txListItems.length, 8, 'all tx list items are rendered') + + const unapprovedTx = txListItems[0] + assert.equal($(unapprovedTx).hasClass('tx-list-pending-item-container'), true, 'unapprovedTx has the correct class') + + const retryTx = txListItems[1] + const retryTxLink = await findAsync($(retryTx), '.tx-list-item-retry-link') + assert.equal(retryTxLink[0].textContent, 'Increase the gas price on your transaction', 'retryTx has expected link') + + const approvedTx = txListItems[2] + const approvedTxRenderedStatus = await findAsync($(approvedTx), '.tx-list-status') + assert.equal(approvedTxRenderedStatus[0].textContent, 'Approved', 'approvedTx has correct label') + + const unapprovedMsg = txListItems[3] + const unapprovedMsgDescription = await findAsync($(unapprovedMsg), '.tx-list-account') + assert.equal(unapprovedMsgDescription[0].textContent, 'Signature Request', 'unapprovedMsg has correct description') + + const failedTx = txListItems[4] + const failedTxRenderedStatus = await findAsync($(failedTx), '.tx-list-status') + assert.equal(failedTxRenderedStatus[0].textContent, 'Failed', 'failedTx has correct label') + + const shapeShiftTx = txListItems[5] + const shapeShiftTxStatus = await findAsync($(shapeShiftTx), '.flex-column div:eq(1)') + assert.equal(shapeShiftTxStatus[0].textContent, 'No deposits received', 'shapeShiftTx has correct status') + + const confirmedTokenTx = txListItems[6] + const confirmedTokenTxAddress = await findAsync($(confirmedTokenTx), '.tx-list-account') + assert.equal(confirmedTokenTxAddress[0].textContent, '0xe7884118...81a9', 'confirmedTokenTx has correct address') + + const rejectedTx = txListItems[7] + const rejectedTxRenderedStatus = await findAsync($(rejectedTx), '.tx-list-status') + assert.equal(rejectedTxRenderedStatus[0].textContent, 'Rejected', 'rejectedTx has correct label') +} -- cgit v1.2.3 From 5945c8cf67201f651eb98b000fbe6702b8ec6a88 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 00:09:39 -0700 Subject: development - create selenium screen shotter --- test/screens/new.spec.js | 122 ++++++++++++++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 45 deletions(-) (limited to 'test') diff --git a/test/screens/new.spec.js b/test/screens/new.spec.js index c5a8ef859..f17781d7a 100644 --- a/test/screens/new.spec.js +++ b/test/screens/new.spec.js @@ -2,6 +2,7 @@ const path = require('path') const fs = require('fs') const pify = require('pify') const mkdirp = require('mkdirp') +const rimraf = require('rimraf') const webdriver = require('selenium-webdriver') const endOfStream = require('end-of-stream') const GIFEncoder = require('gifencoder') @@ -15,84 +16,111 @@ captureAllScreens().catch(console.error) async function captureAllScreens() { let screenshotCount = 0 + // common names + let button + let tabs + let element + + await cleanScreenShotDir() + // setup selenium and install extension const extPath = path.resolve('dist/chrome') const driver = buildWebDriver(extPath) await driver.get('chrome://extensions-frame') const elems = await driver.findElements(By.css('.extension-list-item-wrapper')) const extensionId = await elems[1].getAttribute('id') - await driver.get(`chrome-extension://${extensionId}/popup.html`) + await driver.get(`chrome-extension://${extensionId}/home.html`) await delay(500) - const tabs = await driver.getAllWindowHandles() + tabs = await driver.getAllWindowHandles() await driver.switchTo().window(tabs[0]) await delay(300) - // common names - let button - await captureScreenShot('start-old') // click try new ui await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-center.flex-grow > p')).click() - await captureScreenShot('start-new') - await delay(300) - await captureScreenShot('start-new2') await delay(300) - await captureScreenShot('start-new3') + + // close metamask homepage and extra home.html + tabs = await driver.getAllWindowHandles() + await driver.switchTo().window(tabs[2]) + driver.close() + await driver.switchTo().window(tabs[1]) + driver.close() + await driver.switchTo().window(tabs[0]) await delay(300) - await captureScreenShot('start-new4') + await captureScreenShot('welcome-new-ui') + + // setup account + await delay(1000) + await driver.findElement(By.css('body')).click() await delay(300) - await captureScreenShot('start-new5') + await captureScreenShot('welcome') - // exit early for dev - await generateGif() - await driver.quit() - return + await driver.findElement(By.css('button')).click() + await captureScreenShot('create password') + + const passwordBox = await driver.findElement(By.css('input[type=password]:nth-of-type(1)')) + const passwordBoxConfirm = await driver.findElement(By.css('input[type=password]:nth-of-type(2)')) + passwordBox.sendKeys('123456789') + passwordBoxConfirm.sendKeys('123456789') + await delay(500) + await captureScreenShot('choose-password-filled') + await driver.findElement(By.css('button')).click() + await delay(500) + await captureScreenShot('unique account image') - await captureScreenShot('privacy') + await driver.findElement(By.css('button')).click() + await delay(500) + await captureScreenShot('privacy note') - const privacy = await driver.findElement(By.css('.terms-header')).getText() - driver.findElement(By.css('button')).click() + await driver.findElement(By.css('button')).click() await delay(300) await captureScreenShot('terms') await delay(300) - const terms = await driver.findElement(By.css('.terms-header')).getText() - await delay(300) - const element = driver.findElement(By.linkText('Attributions')) + element = driver.findElement(By.linkText('Attributions')) await driver.executeScript('arguments[0].scrollIntoView(true)', element) await delay(300) - button = await driver.findElement(By.css('button')) - const buttonEnabled = await button.isEnabled() - await delay(500) await captureScreenShot('terms-scrolled') - await button.click() + await driver.findElement(By.css('button')).click() await delay(300) - await captureScreenShot('choose-password') + await captureScreenShot('secret backup phrase') - const passwordBox = await driver.findElement(By.id('password-box')) - const passwordBoxConfirm = await driver.findElement(By.id('password-box-confirm')) - button = driver.findElement(By.css('button')) - passwordBox.sendKeys('123456789') - passwordBoxConfirm.sendKeys('123456789') - await delay(500) - await captureScreenShot('choose-password-filled') + await driver.findElement(By.css('button')).click() + await delay(300) + await captureScreenShot('secret backup phrase') - await button.click() - await delay(700) - this.seedPhase = await driver.findElement(By.css('.twelve-word-phrase')).getText() - await captureScreenShot('seed phrase') + await driver.findElement(By.css('.backup-phrase__reveal-button')).click() + await delay(300) + await captureScreenShot('secret backup phrase - reveal') - const continueAfterSeedPhrase = await driver.findElement(By.css('button')) - await continueAfterSeedPhrase.click() + await driver.findElement(By.css('button')).click() await delay(300) - await captureScreenShot('main screen') + await captureScreenShot('confirm secret backup phrase') - await driver.findElement(By.css('.sandwich-expando')).click() - await delay(500) - await captureScreenShot('menu') + // finish up + console.log('building gif...') + await generateGif() + await driver.quit() + return + + // + // await button.click() + // await delay(700) + // this.seedPhase = await driver.findElement(By.css('.twelve-word-phrase')).getText() + // await captureScreenShot('seed phrase') + // + // const continueAfterSeedPhrase = await driver.findElement(By.css('button')) + // await continueAfterSeedPhrase.click() + // await delay(300) + // await captureScreenShot('main screen') + // + // await driver.findElement(By.css('.sandwich-expando')).click() + // await delay(500) + // await captureScreenShot('menu') // await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)')).click() // await captureScreenShot('main screen') @@ -119,8 +147,12 @@ async function captureAllScreens() { // cleanup await driver.quit() + async function cleanScreenShotDir() { + await pify(rimraf)(`./test-artifacts/screens/`) + } + async function captureScreenShot(label) { - const shotIndex = screenshotCount + const shotIndex = screenshotCount.toString().padStart(4, '0') screenshotCount++ const artifactDir = `./test-artifacts/screens/` await pify(mkdirp)(artifactDir) @@ -138,7 +170,7 @@ async function captureAllScreens() { // read all pngs into gif const encoder = new GIFEncoder(size.width, size.height) const stream = pngFileStream('./test-artifacts/screens/*.png') - .pipe(encoder.createWriteStream({ repeat: -1, delay: 500, quality: 10 })) + .pipe(encoder.createWriteStream({ repeat: -1, delay: 1000, quality: 10 })) .pipe(fs.createWriteStream('./test-artifacts/screens/walkthrough.gif')) // wait for end -- cgit v1.2.3 From fcdfd48057db83801d37bc54b1a04c0a328ab24c Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 00:48:37 -0700 Subject: development - screenshotter - capture screens across all locales --- test/screens/new.spec.js | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/screens/new.spec.js b/test/screens/new.spec.js index f17781d7a..83b960c58 100644 --- a/test/screens/new.spec.js +++ b/test/screens/new.spec.js @@ -10,6 +10,7 @@ const pngFileStream = require('png-file-stream') const sizeOfPng = require('image-size/lib/types/png') const By = webdriver.By const { delay, buildWebDriver } = require('./func') +const localesIndex = require('../../app/_locales/index.json') captureAllScreens().catch(console.error) @@ -49,62 +50,62 @@ async function captureAllScreens() { driver.close() await driver.switchTo().window(tabs[0]) await delay(300) - await captureScreenShot('welcome-new-ui') + await captureLanguageScreenShots('welcome-new-ui') // setup account await delay(1000) await driver.findElement(By.css('body')).click() await delay(300) - await captureScreenShot('welcome') + await captureLanguageScreenShots('welcome') await driver.findElement(By.css('button')).click() - await captureScreenShot('create password') + await captureLanguageScreenShots('create password') const passwordBox = await driver.findElement(By.css('input[type=password]:nth-of-type(1)')) const passwordBoxConfirm = await driver.findElement(By.css('input[type=password]:nth-of-type(2)')) passwordBox.sendKeys('123456789') passwordBoxConfirm.sendKeys('123456789') await delay(500) - await captureScreenShot('choose-password-filled') + await captureLanguageScreenShots('choose-password-filled') await driver.findElement(By.css('button')).click() await delay(500) - await captureScreenShot('unique account image') + await captureLanguageScreenShots('unique account image') await driver.findElement(By.css('button')).click() await delay(500) - await captureScreenShot('privacy note') + await captureLanguageScreenShots('privacy note') await driver.findElement(By.css('button')).click() await delay(300) - await captureScreenShot('terms') + await captureLanguageScreenShots('terms') await delay(300) element = driver.findElement(By.linkText('Attributions')) await driver.executeScript('arguments[0].scrollIntoView(true)', element) await delay(300) - await captureScreenShot('terms-scrolled') + await captureLanguageScreenShots('terms-scrolled') await driver.findElement(By.css('button')).click() await delay(300) - await captureScreenShot('secret backup phrase') + await captureLanguageScreenShots('secret backup phrase') await driver.findElement(By.css('button')).click() await delay(300) - await captureScreenShot('secret backup phrase') + await captureLanguageScreenShots('secret backup phrase') await driver.findElement(By.css('.backup-phrase__reveal-button')).click() await delay(300) - await captureScreenShot('secret backup phrase - reveal') + await captureLanguageScreenShots('secret backup phrase - reveal') await driver.findElement(By.css('button')).click() await delay(300) - await captureScreenShot('confirm secret backup phrase') + await captureLanguageScreenShots('confirm secret backup phrase') // finish up console.log('building gif...') await generateGif() - await driver.quit() + // await driver.quit() return // @@ -144,6 +145,22 @@ async function captureAllScreens() { // await delay(500) // }) + async function captureLanguageScreenShots(label) { + const nonEnglishLocales = localesIndex.filter(localeMeta => localeMeta.code !== 'en') + for (let localeMeta of nonEnglishLocales) { + // set locale + await setLocale(localeMeta.code) + await delay(300) + await captureScreenShot(`${label} (${localeMeta.code})`) + } + await setLocale('en') + await delay(300) + } + + async function setLocale(code) { + await driver.executeScript('setLocale(arguments[0])', code) + } + // cleanup await driver.quit() -- cgit v1.2.3 From 0d27d27efa31f614973e6e5cbc8f53cc85aa0bc2 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 00:59:16 -0700 Subject: development - screenshotter - capture en locale and build gif from only en --- test/screens/new.spec.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/screens/new.spec.js b/test/screens/new.spec.js index 83b960c58..14daac1c1 100644 --- a/test/screens/new.spec.js +++ b/test/screens/new.spec.js @@ -36,8 +36,6 @@ async function captureAllScreens() { await driver.switchTo().window(tabs[0]) await delay(300) - await captureScreenShot('start-old') - // click try new ui await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-center.flex-grow > p')).click() await delay(300) @@ -105,7 +103,7 @@ async function captureAllScreens() { // finish up console.log('building gif...') await generateGif() - // await driver.quit() + await driver.quit() return // @@ -147,12 +145,15 @@ async function captureAllScreens() { async function captureLanguageScreenShots(label) { const nonEnglishLocales = localesIndex.filter(localeMeta => localeMeta.code !== 'en') + // take english shot + await captureScreenShot(`${label} (en)`) for (let localeMeta of nonEnglishLocales) { - // set locale + // set locale and take shot await setLocale(localeMeta.code) await delay(300) await captureScreenShot(`${label} (${localeMeta.code})`) } + // return locale to english await setLocale('en') await delay(300) } @@ -184,11 +185,11 @@ async function captureAllScreens() { const pngBuffer = Buffer.from(screenshot, 'base64') const size = sizeOfPng.calculate(pngBuffer) - // read all pngs into gif + // read only the english pngs into gif const encoder = new GIFEncoder(size.width, size.height) - const stream = pngFileStream('./test-artifacts/screens/*.png') + const stream = pngFileStream('./test-artifacts/screens/* (en).png') .pipe(encoder.createWriteStream({ repeat: -1, delay: 1000, quality: 10 })) - .pipe(fs.createWriteStream('./test-artifacts/screens/walkthrough.gif')) + .pipe(fs.createWriteStream('./test-artifacts/screens/walkthrough (en).gif')) // wait for end await pify(endOfStream)(stream) -- cgit v1.2.3 From b014133fdc14ca4fe83b9cb59d181a7745af8de7 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 11:16:08 -0700 Subject: development - screens - use localhost for network --- test/screens/new.spec.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/screens/new.spec.js b/test/screens/new.spec.js index 14daac1c1..2af891060 100644 --- a/test/screens/new.spec.js +++ b/test/screens/new.spec.js @@ -35,6 +35,7 @@ async function captureAllScreens() { tabs = await driver.getAllWindowHandles() await driver.switchTo().window(tabs[0]) await delay(300) + await setProviderType('localhost') // click try new ui await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-center.flex-grow > p')).click() @@ -42,8 +43,12 @@ async function captureAllScreens() { // close metamask homepage and extra home.html tabs = await driver.getAllWindowHandles() - await driver.switchTo().window(tabs[2]) - driver.close() + console.log(tabs) + // metamask homepage is opened on prod, not dev + if (tabs.length > 2) { + await driver.switchTo().window(tabs[2]) + driver.close() + } await driver.switchTo().window(tabs[1]) driver.close() await driver.switchTo().window(tabs[0]) @@ -159,7 +164,11 @@ async function captureAllScreens() { } async function setLocale(code) { - await driver.executeScript('setLocale(arguments[0])', code) + await driver.executeScript('window.metamask.updateCurrentLocale(arguments[0])', code) + } + + async function setProviderType(type) { + await driver.executeScript('window.metamask.setProviderType(arguments[0])', type) } // cleanup -- cgit v1.2.3 From 32bb09bcb9dd5f9db86967128f7d0fe154fe9922 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 13:52:42 -0700 Subject: test - e2e - set network to localhost --- test/e2e/metamask.spec.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js index ff5bdb51b..20e23e2ea 100644 --- a/test/e2e/metamask.spec.js +++ b/test/e2e/metamask.spec.js @@ -38,6 +38,8 @@ describe('Metamask popup page', function () { const tabs = await driver.getAllWindowHandles() await driver.switchTo().window(tabs[0]) await delay(300) + await setProviderType('localhost') + await delay(300) }) it('should match title', async () => { @@ -124,6 +126,10 @@ describe('Metamask popup page', function () { }) }) + async function setProviderType(type) { + await driver.executeScript('window.metamask.setProviderType(arguments[0])', type) + } + async function verboseReportOnFailure(test) { const artifactDir = `./test-artifacts/${test.title}` const filepathBase = `${artifactDir}/test-failure` -- cgit v1.2.3 From d05a2ca96895195e30c0987bf042c079b4caeadf Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 14:39:43 -0700 Subject: development - screens - screenshot on failure --- test/screens/new.spec.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/screens/new.spec.js b/test/screens/new.spec.js index 2af891060..71b3c53ac 100644 --- a/test/screens/new.spec.js +++ b/test/screens/new.spec.js @@ -12,7 +12,17 @@ const By = webdriver.By const { delay, buildWebDriver } = require('./func') const localesIndex = require('../../app/_locales/index.json') -captureAllScreens().catch(console.error) +let driver + +captureAllScreens().catch((err) => { + try { + verboseReportOnFailure() + console.error(err) + driver.quit() + } finally { + process.exit(1) + } +}) async function captureAllScreens() { let screenshotCount = 0 @@ -26,7 +36,7 @@ async function captureAllScreens() { // setup selenium and install extension const extPath = path.resolve('dist/chrome') - const driver = buildWebDriver(extPath) + driver = buildWebDriver(extPath) await driver.get('chrome://extensions-frame') const elems = await driver.findElements(By.css('.extension-list-item-wrapper')) const extensionId = await elems[1].getAttribute('id') @@ -34,7 +44,7 @@ async function captureAllScreens() { await delay(500) tabs = await driver.getAllWindowHandles() await driver.switchTo().window(tabs[0]) - await delay(300) + await delay(500) await setProviderType('localhost') // click try new ui @@ -43,7 +53,6 @@ async function captureAllScreens() { // close metamask homepage and extra home.html tabs = await driver.getAllWindowHandles() - console.log(tabs) // metamask homepage is opened on prod, not dev if (tabs.length > 2) { await driver.switchTo().window(tabs[2]) @@ -204,4 +213,16 @@ async function captureAllScreens() { await pify(endOfStream)(stream) } + async function verboseReportOnFailure(test) { + const artifactDir = `./test-artifacts/${test.title}` + const filepathBase = `${artifactDir}/test-failure` + await pify(mkdirp)(artifactDir) + // capture screenshot + const screenshot = await driver.takeScreenshot() + await pify(fs.writeFile)(`${filepathBase}-screenshot.png`, screenshot, { encoding: 'base64' }) + // capture dom source + const htmlSource = await driver.getPageSource() + await pify(fs.writeFile)(`${filepathBase}-dom.html`, htmlSource) + } + } -- cgit v1.2.3 From 7a406d51c375247242d8b3c752bd1f9341215430 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 14:48:41 -0700 Subject: development - screens - fix screenshot on failure --- test/screens/new.spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/screens/new.spec.js b/test/screens/new.spec.js index 71b3c53ac..43490226b 100644 --- a/test/screens/new.spec.js +++ b/test/screens/new.spec.js @@ -16,12 +16,13 @@ let driver captureAllScreens().catch((err) => { try { - verboseReportOnFailure() console.error(err) + verboseReportOnFailure() driver.quit() - } finally { - process.exit(1) + } catch (err) { + console.error(err) } + process.exit(1) }) async function captureAllScreens() { -- cgit v1.2.3 From a3f7cd1cfc38308983b81a60b9c6e7e325d1acfb Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 15:03:49 -0700 Subject: development - ci-screens - remove mocha wrapper that was losing exit code --- test/screens/new-ui.js | 229 +++++++++++++++++++++++++++++++++++++++++++++++ test/screens/new.spec.js | 229 ----------------------------------------------- test/screens/old.spec.js | 105 ---------------------- 3 files changed, 229 insertions(+), 334 deletions(-) create mode 100644 test/screens/new-ui.js delete mode 100644 test/screens/new.spec.js delete mode 100644 test/screens/old.spec.js (limited to 'test') diff --git a/test/screens/new-ui.js b/test/screens/new-ui.js new file mode 100644 index 000000000..b23260a7c --- /dev/null +++ b/test/screens/new-ui.js @@ -0,0 +1,229 @@ +const path = require('path') +const fs = require('fs') +const pify = require('pify') +const mkdirp = require('mkdirp') +const rimraf = require('rimraf') +const webdriver = require('selenium-webdriver') +const endOfStream = require('end-of-stream') +const GIFEncoder = require('gifencoder') +const pngFileStream = require('png-file-stream') +const sizeOfPng = require('image-size/lib/types/png') +const By = webdriver.By +const { delay, buildWebDriver } = require('./func') +const localesIndex = require('../../app/_locales/index.json') + +let driver + +captureAllScreens().catch((err) => { + try { + console.error(err) + verboseReportOnFailure() + driver.quit() + } catch (err) { + console.error(err) + } + process.exit(1) +}) + +async function captureAllScreens() { + let screenshotCount = 0 + + // common names + let button + let tabs + let element + + await cleanScreenShotDir() + + // setup selenium and install extension + const extPath = path.resolve('dist/chrome') + driver = buildWebDriver(extPath) + await driver.get('chrome://extensions-frame') + const elems = await driver.findElements(By.css('.extension-list-item-wrapper')) + const extensionId = await elems[1].getAttribute('id') + await driver.get(`chrome-extension://${extensionId}/home.html`) + await delay(500) + tabs = await driver.getAllWindowHandles() + await driver.switchTo().window(tabs[0]) + await delay(500) + await setProviderType('localhost') + + // click try new ui + await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-center.flex-grow > p')).click() + await delay(300) + + // close metamask homepage and extra home.html + tabs = await driver.getAllWindowHandles() + // metamask homepage is opened on prod, not dev + if (tabs.length > 2) { + await driver.switchTo().window(tabs[2]) + driver.close() + } + await driver.switchTo().window(tabs[1]) + driver.close() + await driver.switchTo().window(tabs[0]) + await delay(300) + await captureLanguageScreenShots('welcome-new-ui') + + // setup account + await delay(1000) + await driver.findElement(By.css('body')).click() + await delay(300) + await captureLanguageScreenShots('welcome') + + await driver.findElement(By.css('button')).click() + await captureLanguageScreenShots('create password') + + const passwordBox = await driver.findElement(By.css('input[type=password]:nth-of-type(1)')) + const passwordBoxConfirm = await driver.findElement(By.css('input[type=password]:nth-of-type(2)')) + passwordBox.sendKeys('123456789') + passwordBoxConfirm.sendKeys('123456789') + await delay(500) + await captureLanguageScreenShots('choose-password-filled') + + await driver.findElement(By.css('button')).click() + await delay(500) + await captureLanguageScreenShots('unique account image') + + await driver.findElement(By.css('button')).click() + await delay(500) + await captureLanguageScreenShots('privacy note') + + await driver.findElement(By.css('button')).click() + await delay(300) + await captureLanguageScreenShots('terms') + + await delay(300) + element = driver.findElement(By.linkText('Attributions')) + await driver.executeScript('arguments[0].scrollIntoView(true)', element) + await delay(300) + await captureLanguageScreenShots('terms-scrolled') + + await driver.findElement(By.css('button')).click() + await delay(300) + await captureLanguageScreenShots('secret backup phrase') + + await driver.findElement(By.css('button')).click() + await delay(300) + await captureLanguageScreenShots('secret backup phrase') + + await driver.findElement(By.css('.backup-phrase__reveal-button')).click() + await delay(300) + await captureLanguageScreenShots('secret backup phrase - reveal') + + await driver.findElement(By.css('button')).click() + await delay(300) + await captureLanguageScreenShots('confirm secret backup phrase') + + // finish up + console.log('building gif...') + await generateGif() + await driver.quit() + return + + // + // await button.click() + // await delay(700) + // this.seedPhase = await driver.findElement(By.css('.twelve-word-phrase')).getText() + // await captureScreenShot('seed phrase') + // + // const continueAfterSeedPhrase = await driver.findElement(By.css('button')) + // await continueAfterSeedPhrase.click() + // await delay(300) + // await captureScreenShot('main screen') + // + // await driver.findElement(By.css('.sandwich-expando')).click() + // await delay(500) + // await captureScreenShot('menu') + + // await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)')).click() + // await captureScreenShot('main screen') + // it('should accept account password after lock', async () => { + // await delay(500) + // await driver.findElement(By.id('password-box')).sendKeys('123456789') + // await driver.findElement(By.css('button')).click() + // await delay(500) + // }) + // + // it('should show QR code option', async () => { + // await delay(300) + // await driver.findElement(By.css('.fa-ellipsis-h')).click() + // await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div > div:nth-child(1) > flex-column > div.name-label > div > span > i > div > div > li:nth-child(3)')).click() + // await delay(300) + // }) + // + // it('should show the account address', async () => { + // this.accountAddress = await driver.findElement(By.css('.ellip-address')).getText() + // await driver.findElement(By.css('.fa-arrow-left')).click() + // await delay(500) + // }) + + async function captureLanguageScreenShots(label) { + const nonEnglishLocales = localesIndex.filter(localeMeta => localeMeta.code !== 'en') + // take english shot + await captureScreenShot(`${label} (en)`) + for (let localeMeta of nonEnglishLocales) { + // set locale and take shot + await setLocale(localeMeta.code) + await delay(300) + await captureScreenShot(`${label} (${localeMeta.code})`) + } + // return locale to english + await setLocale('en') + await delay(300) + } + + async function setLocale(code) { + await driver.executeScript('window.metamask.updateCurrentLocale(arguments[0])', code) + } + + async function setProviderType(type) { + await driver.executeScript('window.metamask.setProviderType(arguments[0])', type) + } + + // cleanup + await driver.quit() + + async function cleanScreenShotDir() { + await pify(rimraf)(`./test-artifacts/screens/`) + } + + async function captureScreenShot(label) { + const shotIndex = screenshotCount.toString().padStart(4, '0') + screenshotCount++ + const artifactDir = `./test-artifacts/screens/` + await pify(mkdirp)(artifactDir) + // capture screenshot + const screenshot = await driver.takeScreenshot() + await pify(fs.writeFile)(`${artifactDir}/${shotIndex} - ${label}.png`, screenshot, { encoding: 'base64' }) + } + + async function generateGif(){ + // calculate screenshot size + const screenshot = await driver.takeScreenshot() + const pngBuffer = Buffer.from(screenshot, 'base64') + const size = sizeOfPng.calculate(pngBuffer) + + // read only the english pngs into gif + const encoder = new GIFEncoder(size.width, size.height) + const stream = pngFileStream('./test-artifacts/screens/* (en).png') + .pipe(encoder.createWriteStream({ repeat: -1, delay: 1000, quality: 10 })) + .pipe(fs.createWriteStream('./test-artifacts/screens/walkthrough (en).gif')) + + // wait for end + await pify(endOfStream)(stream) + } + +} + +async function verboseReportOnFailure(test) { + const artifactDir = `./test-artifacts/${test.title}` + const filepathBase = `${artifactDir}/test-failure` + await pify(mkdirp)(artifactDir) + // capture screenshot + const screenshot = await driver.takeScreenshot() + await pify(fs.writeFile)(`${filepathBase}-screenshot.png`, screenshot, { encoding: 'base64' }) + // capture dom source + const htmlSource = await driver.getPageSource() + await pify(fs.writeFile)(`${filepathBase}-dom.html`, htmlSource) +} diff --git a/test/screens/new.spec.js b/test/screens/new.spec.js deleted file mode 100644 index 43490226b..000000000 --- a/test/screens/new.spec.js +++ /dev/null @@ -1,229 +0,0 @@ -const path = require('path') -const fs = require('fs') -const pify = require('pify') -const mkdirp = require('mkdirp') -const rimraf = require('rimraf') -const webdriver = require('selenium-webdriver') -const endOfStream = require('end-of-stream') -const GIFEncoder = require('gifencoder') -const pngFileStream = require('png-file-stream') -const sizeOfPng = require('image-size/lib/types/png') -const By = webdriver.By -const { delay, buildWebDriver } = require('./func') -const localesIndex = require('../../app/_locales/index.json') - -let driver - -captureAllScreens().catch((err) => { - try { - console.error(err) - verboseReportOnFailure() - driver.quit() - } catch (err) { - console.error(err) - } - process.exit(1) -}) - -async function captureAllScreens() { - let screenshotCount = 0 - - // common names - let button - let tabs - let element - - await cleanScreenShotDir() - - // setup selenium and install extension - const extPath = path.resolve('dist/chrome') - driver = buildWebDriver(extPath) - await driver.get('chrome://extensions-frame') - const elems = await driver.findElements(By.css('.extension-list-item-wrapper')) - const extensionId = await elems[1].getAttribute('id') - await driver.get(`chrome-extension://${extensionId}/home.html`) - await delay(500) - tabs = await driver.getAllWindowHandles() - await driver.switchTo().window(tabs[0]) - await delay(500) - await setProviderType('localhost') - - // click try new ui - await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-center.flex-grow > p')).click() - await delay(300) - - // close metamask homepage and extra home.html - tabs = await driver.getAllWindowHandles() - // metamask homepage is opened on prod, not dev - if (tabs.length > 2) { - await driver.switchTo().window(tabs[2]) - driver.close() - } - await driver.switchTo().window(tabs[1]) - driver.close() - await driver.switchTo().window(tabs[0]) - await delay(300) - await captureLanguageScreenShots('welcome-new-ui') - - // setup account - await delay(1000) - await driver.findElement(By.css('body')).click() - await delay(300) - await captureLanguageScreenShots('welcome') - - await driver.findElement(By.css('button')).click() - await captureLanguageScreenShots('create password') - - const passwordBox = await driver.findElement(By.css('input[type=password]:nth-of-type(1)')) - const passwordBoxConfirm = await driver.findElement(By.css('input[type=password]:nth-of-type(2)')) - passwordBox.sendKeys('123456789') - passwordBoxConfirm.sendKeys('123456789') - await delay(500) - await captureLanguageScreenShots('choose-password-filled') - - await driver.findElement(By.css('button')).click() - await delay(500) - await captureLanguageScreenShots('unique account image') - - await driver.findElement(By.css('button')).click() - await delay(500) - await captureLanguageScreenShots('privacy note') - - await driver.findElement(By.css('button')).click() - await delay(300) - await captureLanguageScreenShots('terms') - - await delay(300) - element = driver.findElement(By.linkText('Attributions')) - await driver.executeScript('arguments[0].scrollIntoView(true)', element) - await delay(300) - await captureLanguageScreenShots('terms-scrolled') - - await driver.findElement(By.css('button')).click() - await delay(300) - await captureLanguageScreenShots('secret backup phrase') - - await driver.findElement(By.css('button')).click() - await delay(300) - await captureLanguageScreenShots('secret backup phrase') - - await driver.findElement(By.css('.backup-phrase__reveal-button')).click() - await delay(300) - await captureLanguageScreenShots('secret backup phrase - reveal') - - await driver.findElement(By.css('button')).click() - await delay(300) - await captureLanguageScreenShots('confirm secret backup phrase') - - // finish up - console.log('building gif...') - await generateGif() - await driver.quit() - return - - // - // await button.click() - // await delay(700) - // this.seedPhase = await driver.findElement(By.css('.twelve-word-phrase')).getText() - // await captureScreenShot('seed phrase') - // - // const continueAfterSeedPhrase = await driver.findElement(By.css('button')) - // await continueAfterSeedPhrase.click() - // await delay(300) - // await captureScreenShot('main screen') - // - // await driver.findElement(By.css('.sandwich-expando')).click() - // await delay(500) - // await captureScreenShot('menu') - - // await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)')).click() - // await captureScreenShot('main screen') - // it('should accept account password after lock', async () => { - // await delay(500) - // await driver.findElement(By.id('password-box')).sendKeys('123456789') - // await driver.findElement(By.css('button')).click() - // await delay(500) - // }) - // - // it('should show QR code option', async () => { - // await delay(300) - // await driver.findElement(By.css('.fa-ellipsis-h')).click() - // await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div > div:nth-child(1) > flex-column > div.name-label > div > span > i > div > div > li:nth-child(3)')).click() - // await delay(300) - // }) - // - // it('should show the account address', async () => { - // this.accountAddress = await driver.findElement(By.css('.ellip-address')).getText() - // await driver.findElement(By.css('.fa-arrow-left')).click() - // await delay(500) - // }) - - async function captureLanguageScreenShots(label) { - const nonEnglishLocales = localesIndex.filter(localeMeta => localeMeta.code !== 'en') - // take english shot - await captureScreenShot(`${label} (en)`) - for (let localeMeta of nonEnglishLocales) { - // set locale and take shot - await setLocale(localeMeta.code) - await delay(300) - await captureScreenShot(`${label} (${localeMeta.code})`) - } - // return locale to english - await setLocale('en') - await delay(300) - } - - async function setLocale(code) { - await driver.executeScript('window.metamask.updateCurrentLocale(arguments[0])', code) - } - - async function setProviderType(type) { - await driver.executeScript('window.metamask.setProviderType(arguments[0])', type) - } - - // cleanup - await driver.quit() - - async function cleanScreenShotDir() { - await pify(rimraf)(`./test-artifacts/screens/`) - } - - async function captureScreenShot(label) { - const shotIndex = screenshotCount.toString().padStart(4, '0') - screenshotCount++ - const artifactDir = `./test-artifacts/screens/` - await pify(mkdirp)(artifactDir) - // capture screenshot - const screenshot = await driver.takeScreenshot() - await pify(fs.writeFile)(`${artifactDir}/${shotIndex} - ${label}.png`, screenshot, { encoding: 'base64' }) - } - - async function generateGif(){ - // calculate screenshot size - const screenshot = await driver.takeScreenshot() - const pngBuffer = Buffer.from(screenshot, 'base64') - const size = sizeOfPng.calculate(pngBuffer) - - // read only the english pngs into gif - const encoder = new GIFEncoder(size.width, size.height) - const stream = pngFileStream('./test-artifacts/screens/* (en).png') - .pipe(encoder.createWriteStream({ repeat: -1, delay: 1000, quality: 10 })) - .pipe(fs.createWriteStream('./test-artifacts/screens/walkthrough (en).gif')) - - // wait for end - await pify(endOfStream)(stream) - } - - async function verboseReportOnFailure(test) { - const artifactDir = `./test-artifacts/${test.title}` - const filepathBase = `${artifactDir}/test-failure` - await pify(mkdirp)(artifactDir) - // capture screenshot - const screenshot = await driver.takeScreenshot() - await pify(fs.writeFile)(`${filepathBase}-screenshot.png`, screenshot, { encoding: 'base64' }) - // capture dom source - const htmlSource = await driver.getPageSource() - await pify(fs.writeFile)(`${filepathBase}-dom.html`, htmlSource) - } - -} diff --git a/test/screens/old.spec.js b/test/screens/old.spec.js deleted file mode 100644 index 87399d4b5..000000000 --- a/test/screens/old.spec.js +++ /dev/null @@ -1,105 +0,0 @@ -const path = require('path') -const fs = require('fs') -const pify = require('pify') -const mkdirp = require('mkdirp') -const webdriver = require('selenium-webdriver') -const By = webdriver.By -const { delay, buildWebDriver } = require('./func') - -captureAllScreens().catch(console.error) - -async function captureAllScreens() { - // setup selenium and install extension - const extPath = path.resolve('dist/chrome') - const driver = buildWebDriver(extPath) - await driver.get('chrome://extensions-frame') - const elems = await driver.findElements(By.css('.extension-list-item-wrapper')) - const extensionId = await elems[1].getAttribute('id') - await driver.get(`chrome-extension://${extensionId}/popup.html`) - await delay(500) - const tabs = await driver.getAllWindowHandles() - await driver.switchTo().window(tabs[0]) - await delay(300) - - // common names - let button - - await captureScreenShot('privacy') - - const privacy = await driver.findElement(By.css('.terms-header')).getText() - driver.findElement(By.css('button')).click() - await delay(300) - await captureScreenShot('terms') - - await delay(300) - const terms = await driver.findElement(By.css('.terms-header')).getText() - await delay(300) - const element = driver.findElement(By.linkText('Attributions')) - await driver.executeScript('arguments[0].scrollIntoView(true)', element) - await delay(300) - button = await driver.findElement(By.css('button')) - const buttonEnabled = await button.isEnabled() - await delay(500) - await captureScreenShot('terms-scrolled') - - await button.click() - await delay(300) - await captureScreenShot('choose-password') - - const passwordBox = await driver.findElement(By.id('password-box')) - const passwordBoxConfirm = await driver.findElement(By.id('password-box-confirm')) - button = driver.findElement(By.css('button')) - passwordBox.sendKeys('123456789') - passwordBoxConfirm.sendKeys('123456789') - await delay(500) - await captureScreenShot('choose-password-filled') - - await button.click() - await delay(700) - this.seedPhase = await driver.findElement(By.css('.twelve-word-phrase')).getText() - await captureScreenShot('seed phrase') - - const continueAfterSeedPhrase = await driver.findElement(By.css('button')) - await continueAfterSeedPhrase.click() - await delay(300) - await captureScreenShot('main screen') - - await driver.findElement(By.css('.sandwich-expando')).click() - await delay(500) - await captureScreenShot('menu') - - // await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)')).click() - // await captureScreenShot('main screen') - // it('should accept account password after lock', async () => { - // await delay(500) - // await driver.findElement(By.id('password-box')).sendKeys('123456789') - // await driver.findElement(By.css('button')).click() - // await delay(500) - // }) - // - // it('should show QR code option', async () => { - // await delay(300) - // await driver.findElement(By.css('.fa-ellipsis-h')).click() - // await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div > div:nth-child(1) > flex-column > div.name-label > div > span > i > div > div > li:nth-child(3)')).click() - // await delay(300) - // }) - // - // it('should show the account address', async () => { - // this.accountAddress = await driver.findElement(By.css('.ellip-address')).getText() - // await driver.findElement(By.css('.fa-arrow-left')).click() - // await delay(500) - // }) - - // cleanup - await driver.quit() - - async function captureScreenShot(label) { - const artifactDir = `./test-artifacts/${label}` - const filepathBase = `${artifactDir}` - await pify(mkdirp)(artifactDir) - // capture screenshot - const screenshot = await driver.takeScreenshot() - await pify(fs.writeFile)(`${filepathBase}/screenshot.png`, screenshot, { encoding: 'base64' }) - } - -} -- cgit v1.2.3 From 69ff600c747c588cfe2c6792367e091b7f648d8d Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 17:36:43 -0700 Subject: ci - screens - add delay after setting network --- test/screens/new-ui.js | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/screens/new-ui.js b/test/screens/new-ui.js index b23260a7c..ecd45cf9b 100644 --- a/test/screens/new-ui.js +++ b/test/screens/new-ui.js @@ -47,6 +47,7 @@ async function captureAllScreens() { await driver.switchTo().window(tabs[0]) await delay(500) await setProviderType('localhost') + await delay(300) // click try new ui await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div.flex-row.flex-center.flex-grow > p')).click() -- cgit v1.2.3 From 8db097d8d9307bc7a0bbb0cd802ad30ad0fc2740 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 18:14:26 -0700 Subject: ci - screens - increase delay before setting provider type --- test/screens/new-ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/screens/new-ui.js b/test/screens/new-ui.js index ecd45cf9b..f7d7ea20f 100644 --- a/test/screens/new-ui.js +++ b/test/screens/new-ui.js @@ -45,7 +45,7 @@ async function captureAllScreens() { await delay(500) tabs = await driver.getAllWindowHandles() await driver.switchTo().window(tabs[0]) - await delay(500) + await delay(1000) await setProviderType('localhost') await delay(300) -- cgit v1.2.3 From e8a480aac44546e6bd5d7457545bc951a8787814 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Mon, 2 Apr 2018 13:17:54 -0700 Subject: transactions validationt - valdate from field on txParams --- test/unit/tx-gas-util-test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test') diff --git a/test/unit/tx-gas-util-test.js b/test/unit/tx-gas-util-test.js index d9a12d1c3..15d412c72 100644 --- a/test/unit/tx-gas-util-test.js +++ b/test/unit/tx-gas-util-test.js @@ -29,4 +29,28 @@ describe('Tx Gas Util', function () { } assert.throws(() => { txGasUtil.validateRecipient(zeroRecipientTxParams) }, Error, 'Invalid recipient address') }) + + it('should error when from is not a hex string', function () { + + // where from is undefined + const txParams = {} + assert.throws(() => { txGasUtil.validateFrom(txParams) }, Error, `Invalid from address ${txParams.from} not a string`) + + // where from is array + txParams.from = [] + assert.throws(() => { txGasUtil.validateFrom(txParams) }, Error, `Invalid from address ${txParams.from} not a string`) + + // where from is a object + txParams.from = {} + assert.throws(() => { txGasUtil.validateFrom(txParams) }, Error, `Invalid from address ${txParams.from} not a string`) + + // where from is a invalid address + txParams.from = 'im going to fail' + assert.throws(() => { txGasUtil.validateFrom(txParams) }, Error, `Invalid from address`) + + // should run + txParams.from ='0x1678a085c290ebd122dc42cba69373b5953b831d' + txGasUtil.validateFrom(txParams) + }) + }) -- cgit v1.2.3 From b58ca99b61e8332afc441a1520759578b754c424 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Mon, 2 Apr 2018 15:43:50 -0700 Subject: tests - fix txController tests so that txMetas have a from feild --- test/unit/tx-controller-test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js index 712097fce..6bd010e7a 100644 --- a/test/unit/tx-controller-test.js +++ b/test/unit/tx-controller-test.js @@ -162,7 +162,7 @@ describe('Transaction Controller', function () { describe('#addUnapprovedTransaction', function () { it('should add an unapproved transaction and return a valid txMeta', function (done) { - txController.addUnapprovedTransaction({}) + txController.addUnapprovedTransaction({ from: '0x1678a085c290ebd122dc42cba69373b5953b831d' }) .then((txMeta) => { assert(('id' in txMeta), 'should have a id') assert(('time' in txMeta), 'should have a time stamp') @@ -182,7 +182,7 @@ describe('Transaction Controller', function () { assert(txMetaFromEmit, 'txMeta is falsey') done() }) - txController.addUnapprovedTransaction({}) + txController.addUnapprovedTransaction({ from: '0x1678a085c290ebd122dc42cba69373b5953b831d' }) .catch(done) }) @@ -213,6 +213,7 @@ describe('Transaction Controller', function () { describe('#validateTxParams', function () { it('does not throw for positive values', function (done) { var sample = { + from: '0x1678a085c290ebd122dc42cba69373b5953b831d', value: '0x01', } txController.txGasUtil.validateTxParams(sample).then(() => { @@ -222,6 +223,7 @@ describe('Transaction Controller', function () { it('returns error for negative values', function (done) { var sample = { + from: '0x1678a085c290ebd122dc42cba69373b5953b831d', value: '-0x01', } txController.txGasUtil.validateTxParams(sample) -- cgit v1.2.3 From d5a88cdc00dba6a928a6264f8b8dfee8f50bc4a3 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 2 Apr 2018 15:51:00 -0700 Subject: ci:screens - turn on repeat in walkthrough gif --- test/screens/new-ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/screens/new-ui.js b/test/screens/new-ui.js index f7d7ea20f..91b3a9633 100644 --- a/test/screens/new-ui.js +++ b/test/screens/new-ui.js @@ -208,7 +208,7 @@ async function captureAllScreens() { // read only the english pngs into gif const encoder = new GIFEncoder(size.width, size.height) const stream = pngFileStream('./test-artifacts/screens/* (en).png') - .pipe(encoder.createWriteStream({ repeat: -1, delay: 1000, quality: 10 })) + .pipe(encoder.createWriteStream({ repeat: 0, delay: 1000, quality: 10 })) .pipe(fs.createWriteStream('./test-artifacts/screens/walkthrough (en).gif')) // wait for end -- cgit v1.2.3