aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-03-30 07:54:00 +0800
committerkumavis <aaron@kumavis.me>2018-03-30 07:54:00 +0800
commitb49ad750dd87232553a72663af94bb2840c2f2ad (patch)
tree71e4002e6bc28c42ea227299752814d6f1f10486 /test
parent93c123c6f52b28b525658492ce93fbcc30fc1e7c (diff)
parent9d4be1842e7c56e3bfde529ff555dcae8dec3dbd (diff)
downloadtangerine-wallet-browser-b49ad750dd87232553a72663af94bb2840c2f2ad.tar.gz
tangerine-wallet-browser-b49ad750dd87232553a72663af94bb2840c2f2ad.tar.zst
tangerine-wallet-browser-b49ad750dd87232553a72663af94bb2840c2f2ad.zip
Merge branch 'master' of github.com:MetaMask/metamask-extension into ci-artifacts
Diffstat (limited to 'test')
-rw-r--r--test/e2e/metamask.spec.js63
-rw-r--r--test/unit/nonce-tracker-test.js36
2 files changed, 76 insertions, 23 deletions
diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js
index e81e0a8df..d2ffa041e 100644
--- a/test/e2e/metamask.spec.js
+++ b/test/e2e/metamask.spec.js
@@ -1,5 +1,8 @@
+const fs = require('fs')
+const mkdirp = require('mkdirp')
const path = require('path')
const assert = require('assert')
+const pify = require('pify')
const webdriver = require('selenium-webdriver')
const By = webdriver.By
const { delay, buildWebDriver } = require('./func')
@@ -14,12 +17,18 @@ describe('Metamask popup page', function () {
const extPath = path.resolve('dist/chrome')
driver = buildWebDriver(extPath)
await driver.get('chrome://extensions-frame')
- const elems = await driver.findElements(By.className('extension-list-item-wrapper'))
+ 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)
})
+ afterEach(async function () {
+ if (this.currentTest.state === 'failed') {
+ await verboseReportOnFailure(this.currentTest)
+ }
+ })
+
after(async function () {
await driver.quit()
})
@@ -37,32 +46,27 @@ describe('Metamask popup page', function () {
})
it('should show privacy notice', async () => {
- const privacy = await driver.findElement(By.className(
- 'terms-header'
- )).getText()
+ const privacy = await driver.findElement(By.css('.terms-header')).getText()
assert.equal(privacy, 'PRIVACY NOTICE', 'shows privacy notice')
- driver.findElement(By.css(
- 'button'
- )).click()
+ driver.findElement(By.css('button')).click()
+ await delay(300)
})
it('should show terms of use', async () => {
await delay(300)
- const terms = await driver.findElement(By.className(
- 'terms-header'
- )).getText()
+ const terms = await driver.findElement(By.css('.terms-header')).getText()
assert.equal(terms, 'TERMS OF USE', 'shows terms of use')
+ await delay(300)
})
it('should be unable to continue without scolling throught the terms of use', async () => {
- const button = await driver.findElement(By.css(
- 'button'
- )).isEnabled()
+ const button = await driver.findElement(By.css('button')).isEnabled()
assert.equal(button, false, 'disabled continue button')
const element = driver.findElement(By.linkText(
'Attributions'
))
await driver.executeScript('arguments[0].scrollIntoView(true)', element)
+ await delay(300)
})
it('should be able to continue when scrolled to the bottom of terms of use', async () => {
@@ -71,10 +75,10 @@ describe('Metamask popup page', function () {
await delay(500)
assert.equal(buttonEnabled, true, 'enabled continue button')
await button.click()
+ await delay(300)
})
it('should accept password with length of eight', async () => {
- await delay(300)
const passwordBox = await driver.findElement(By.id('password-box'))
const passwordBoxConfirm = await driver.findElement(By.id('password-box-confirm'))
const button = driver.findElement(By.css('button'))
@@ -87,16 +91,16 @@ describe('Metamask popup page', function () {
it('should show value was created and seed phrase', async () => {
await delay(700)
- this.seedPhase = await driver.findElement(By.className('twelve-word-phrase')).getText()
+ this.seedPhase = await driver.findElement(By.css('.twelve-word-phrase')).getText()
const continueAfterSeedPhrase = await driver.findElement(By.css('button'))
await continueAfterSeedPhrase.click()
+ await delay(300)
})
it('should show lock account', async () => {
- await delay(300)
- await driver.findElement(By.className('sandwich-expando')).click()
+ await driver.findElement(By.css('.sandwich-expando')).click()
await delay(500)
- await driver.findElement(By.xpath('//*[@id="app-content"]/div/div[3]/span/div/li[2]')).click()
+ await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)')).click()
})
it('should accept account password after lock', async () => {
@@ -106,17 +110,30 @@ describe('Metamask popup page', function () {
await delay(500)
})
- it('should show QR code', async () => {
+ it('should show QR code option', async () => {
await delay(300)
- await driver.findElement(By.className('fa-ellipsis-h')).click()
- await driver.findElement(By.xpath('//*[@id="app-content"]/div/div[4]/div/div/div[1]/flex-column/div[1]/div/span/i/div/div/li[2]')).click()
+ 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.className('ellip-address')).getText()
- await driver.findElement(By.className('fa-arrow-left')).click()
+ this.accountAddress = await driver.findElement(By.css('.ellip-address')).getText()
+ await driver.findElement(By.css('.fa-arrow-left')).click()
await delay(500)
})
})
+
+ 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/unit/nonce-tracker-test.js b/test/unit/nonce-tracker-test.js
index 8970cf84d..5a27882ef 100644
--- a/test/unit/nonce-tracker-test.js
+++ b/test/unit/nonce-tracker-test.js
@@ -33,6 +33,42 @@ describe('Nonce Tracker', function () {
})
})
+ describe('sentry issue 476304902', function () {
+ beforeEach(function () {
+ const txGen = new MockTxGen()
+ pendingTxs = txGen.generate({ status: 'submitted' }, {
+ fromNonce: 3,
+ count: 29,
+ })
+ nonceTracker = generateNonceTrackerWith(pendingTxs, [], '0x3')
+ })
+
+ it('should return 9', async function () {
+ this.timeout(15000)
+ const nonceLock = await nonceTracker.getNonceLock('0x7d3517b0d011698406d6e0aed8453f0be2697926')
+ assert.equal(nonceLock.nextNonce, '32', `nonce should be 32 got ${nonceLock.nextNonce}`)
+ await nonceLock.releaseLock()
+ })
+ })
+
+ describe('issue 3670', function () {
+ beforeEach(function () {
+ const txGen = new MockTxGen()
+ pendingTxs = txGen.generate({ status: 'submitted' }, {
+ fromNonce: 6,
+ count: 3,
+ })
+ nonceTracker = generateNonceTrackerWith(pendingTxs, [], '0x6')
+ })
+
+ it('should return 9', async function () {
+ this.timeout(15000)
+ const nonceLock = await nonceTracker.getNonceLock('0x7d3517b0d011698406d6e0aed8453f0be2697926')
+ assert.equal(nonceLock.nextNonce, '9', `nonce should be 9 got ${nonceLock.nextNonce}`)
+ await nonceLock.releaseLock()
+ })
+ })
+
describe('with no previous txs', function () {
beforeEach(function () {
nonceTracker = generateNonceTrackerWith([], [])