diff options
-rw-r--r-- | test/screens/new.spec.js | 43 | ||||
-rw-r--r-- | ui/index.js | 5 |
2 files changed, 35 insertions, 13 deletions
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() diff --git a/ui/index.js b/ui/index.js index 1e0e9f1cc..8fb000d85 100644 --- a/ui/index.js +++ b/ui/index.js @@ -69,6 +69,11 @@ async function startApp (metamaskState, accountManager, opts) { store.dispatch(actions.updateMetamaskState(metamaskState)) }) + // used by screenshotter tooling + global.setLocale = (key) => { + store.dispatch(actions.updateCurrentLocale(key)) + } + // start app render( h(Root, { |