aboutsummaryrefslogtreecommitdiffstats
path: root/test/integration/lib
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/lib')
-rw-r--r--test/integration/lib/confirm-sig-requests.js12
-rw-r--r--test/integration/lib/currency-localization.js9
-rw-r--r--test/integration/lib/first-time.js117
-rw-r--r--test/integration/lib/mascara-first-time.js133
-rw-r--r--test/integration/lib/send-new-ui.js78
-rw-r--r--test/integration/lib/tx-list-items.js46
6 files changed, 66 insertions, 329 deletions
diff --git a/test/integration/lib/confirm-sig-requests.js b/test/integration/lib/confirm-sig-requests.js
index 9c2ad7cf4..e4540c4f2 100644
--- a/test/integration/lib/confirm-sig-requests.js
+++ b/test/integration/lib/confirm-sig-requests.js
@@ -3,6 +3,7 @@ const {
timeout,
queryAsync,
} = require('../../lib/util')
+const fetchMockResponses = require('../../e2e/beta/fetch-mocks.js')
QUnit.module('confirm sig requests')
@@ -19,10 +20,17 @@ async function runConfirmSigRequestsTest (assert, done) {
selectState.val('confirm sig requests')
reactTriggerChange(selectState[0])
+ global.fetch = (...args) => {
+ if (args[0].match(/chromeextensionmm/)) {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
+ }
+ return window.fetch(...args)
+ }
+
const pendingRequestItem = $.find('.transaction-list-item .transaction-list-item__grid')
- if (pendingRequestItem[0]) {
- pendingRequestItem[0].click()
+ if (pendingRequestItem[2]) {
+ pendingRequestItem[2].click()
}
await timeout(1000)
diff --git a/test/integration/lib/currency-localization.js b/test/integration/lib/currency-localization.js
index f6b751ba2..cd10efa30 100644
--- a/test/integration/lib/currency-localization.js
+++ b/test/integration/lib/currency-localization.js
@@ -4,6 +4,7 @@ const {
queryAsync,
findAsync,
} = require('../../lib/util')
+const fetchMockResponses = require('../../e2e/beta/fetch-mocks.js')
QUnit.module('currency localization')
@@ -19,6 +20,14 @@ async function runCurrencyLocalizationTest (assert, done) {
console.log('*** start runCurrencyLocalizationTest')
const selectState = await queryAsync($, 'select')
selectState.val('currency localization')
+
+ global.fetch = (...args) => {
+ if (args[0].match(/chromeextensionmm/)) {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
+ }
+ return window.fetch(...args)
+ }
+
await timeout(1000)
reactTriggerChange(selectState[0])
await timeout(1000)
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/send-new-ui.js b/test/integration/lib/send-new-ui.js
index 271dd91cf..d7003f4cc 100644
--- a/test/integration/lib/send-new-ui.js
+++ b/test/integration/lib/send-new-ui.js
@@ -4,6 +4,7 @@ const {
queryAsync,
findAsync,
} = require('../../lib/util')
+const fetchMockResponses = require('../../e2e/beta/fetch-mocks.js')
QUnit.module('new ui send flow')
@@ -21,38 +22,22 @@ global.ethQuery = {
global.ethereumProvider = {}
-async function customizeGas (assert, price, limit, ethFee, usdFee) {
- const sendGasOpenCustomizeModalButton = await queryAsync($, '.sliders-icon-container')
- sendGasOpenCustomizeModalButton[0].click()
-
- const customizeGasModal = await queryAsync($, '.send-v2__customize-gas')
- assert.ok(customizeGasModal[0], 'should render the customize gas modal')
-
- const customizeGasPriceInput = (await queryAsync($, '.send-v2__gas-modal-card')).first().find('input')
- customizeGasPriceInput.val(price)
- reactTriggerChange(customizeGasPriceInput[0])
- const customizeGasLimitInput = (await queryAsync($, '.send-v2__gas-modal-card')).last().find('input')
- customizeGasLimitInput.val(limit)
- reactTriggerChange(customizeGasLimitInput[0])
-
- const customizeGasSaveButton = await queryAsync($, '.send-v2__customize-gas__save')
- customizeGasSaveButton[0].click()
- const sendGasField = await queryAsync($, '.send-v2__gas-fee-display')
-
- assert.equal(
- (await findAsync(sendGasField, '.currency-display-component'))[0].textContent,
- ethFee,
- 'send gas field should show customized gas total'
- )
-
- assert.equal(
- (await findAsync(sendGasField, '.currency-display__converted-value'))[0].textContent,
- usdFee,
- 'send gas field should show customized gas total converted to USD'
- )
-}
-
async function runSendFlowTest (assert, done) {
+ const tempFetch = global.fetch
+
+ global.fetch = (...args) => {
+ if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
+ } else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) })
+ } else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) })
+ } else if (args[0].match(/chromeextensionmm/)) {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
+ }
+ return window.fetch(...args)
+ }
+
console.log('*** start runSendFlowTest')
const selectState = await queryAsync($, 'select')
selectState.val('send new ui')
@@ -71,23 +56,14 @@ async function runSendFlowTest (assert, done) {
const sendFromField = await queryAsync($, '.send-v2__form-field')
assert.ok(sendFromField[0], 'send screen has a from field')
- let sendFromFieldItemAddress = await queryAsync($, '.account-list-item__account-name')
- assert.equal(sendFromFieldItemAddress[0].textContent, 'Send Account 4', 'send from field shows correct account name')
-
- const sendFromFieldItem = await queryAsync($, '.account-list-item')
- sendFromFieldItem[0].click()
-
- // this seems to fail if the firefox window is not in focus...
- const sendFromDropdownList = await queryAsync($, '.send-v2__from-dropdown__list')
- assert.equal(sendFromDropdownList.children().length, 4, 'send from dropdown shows all accounts')
- sendFromDropdownList.children()[1].click()
-
- sendFromFieldItemAddress = await queryAsync($, '.account-list-item__account-name')
- assert.equal(sendFromFieldItemAddress[0].textContent, 'Send Account 2', 'send from field dropdown changes account name')
+ const sendFromFieldItemAddress = await queryAsync($, '.account-list-item__account-name')
+ assert.equal(sendFromFieldItemAddress[0].textContent, 'Send Account 2', 'send from field shows correct account name')
const sendToFieldInput = await queryAsync($, '.send-v2__to-autocomplete__input')
sendToFieldInput[0].focus()
+ await timeout(1000)
+
const sendToDropdownList = await queryAsync($, '.send-v2__from-dropdown__list')
assert.equal(sendToDropdownList.children().length, 5, 'send to dropdown shows all accounts and address book accounts')
@@ -112,10 +88,6 @@ async function runSendFlowTest (assert, done) {
errorMessage = $('.send-v2__error')
assert.equal(errorMessage.length, 0, 'send should stop rendering amount error message after amount is corrected')
- await customizeGas(assert, 0, 21000, '0ETH', '$0.00USD')
- await customizeGas(assert, 1, 21000, '0.000021ETH', '$0.03USD')
- await customizeGas(assert, 500, 60000, '0.03ETH', '$36.03USD')
-
const sendButton = await queryAsync($, 'button.btn-primary.btn--large.page-container__footer-button')
assert.equal(sendButton[0].textContent, 'Next', 'next button rendered')
sendButton[0].click()
@@ -125,7 +97,7 @@ async function runSendFlowTest (assert, done) {
reactTriggerChange(selectState[0])
const confirmFromName = (await queryAsync($, '.sender-to-recipient__name')).first()
- assert.equal(confirmFromName[0].textContent, 'Send Account 4', 'confirm screen should show correct from name')
+ assert.equal(confirmFromName[0].textContent, 'Send Account 2', 'confirm screen should show correct from name')
const confirmToName = (await queryAsync($, '.sender-to-recipient__name')).last()
assert.equal(confirmToName[0].textContent, 'Send Account 3', 'confirm screen should show correct to name')
@@ -139,12 +111,6 @@ async function runSendFlowTest (assert, done) {
const confirmScreenBackButton = await queryAsync($, '.confirm-page-container-header__back-button')
confirmScreenBackButton[0].click()
- const sendFromFieldItemInEdit = await queryAsync($, '.account-list-item')
- sendFromFieldItemInEdit[0].click()
-
- const sendFromDropdownListInEdit = await queryAsync($, '.send-v2__from-dropdown__list')
- sendFromDropdownListInEdit.children()[2].click()
-
const sendToFieldInputInEdit = await queryAsync($, '.send-v2__to-autocomplete__input')
sendToFieldInputInEdit[0].focus()
sendToFieldInputInEdit.val('0xd85a4b6a394794842887b8284293d69163007bbb')
@@ -164,6 +130,8 @@ async function runSendFlowTest (assert, done) {
const cancelButtonInEdit = await queryAsync($, '.btn-default.btn--large.page-container__footer-button')
cancelButtonInEdit[0].click()
+
+ global.fetch = tempFetch
// sendButtonInEdit[0].click()
// // TODO: Need a way to mock background so that we can test correct transition from editing to confirm
diff --git a/test/integration/lib/tx-list-items.js b/test/integration/lib/tx-list-items.js
index ed4f82074..c0056dd22 100644
--- a/test/integration/lib/tx-list-items.js
+++ b/test/integration/lib/tx-list-items.js
@@ -3,6 +3,7 @@ const {
queryAsync,
findAsync,
} = require('../../lib/util')
+const fetchMockResponses = require('../../e2e/beta/fetch-mocks.js')
QUnit.module('tx list items')
@@ -16,7 +17,7 @@ QUnit.test('renders list items successfully', (assert) => {
global.ethQuery = global.ethQuery || {}
global.ethQuery.getTransactionCount = (_, cb) => {
- cb(null, '0x3')
+ cb(null, '0x4')
}
async function runTxListItemsTest (assert, done) {
@@ -25,6 +26,13 @@ async function runTxListItemsTest (assert, done) {
selectState.val('tx list items')
reactTriggerChange(selectState[0])
+ global.fetch = (...args) => {
+ if (args[0].match(/chromeextensionmm/)) {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
+ }
+ return window.fetch(...args)
+ }
+
const metamaskLogo = await queryAsync($, '.app-header__logo-container')
assert.ok(metamaskLogo[0], 'metamask logo present')
metamaskLogo[0].click()
@@ -32,33 +40,27 @@ async function runTxListItemsTest (assert, done) {
const txListItems = await queryAsync($, '.transaction-list-item')
assert.equal(txListItems.length, 8, 'all tx list items are rendered')
- const retryTxGrid = await findAsync($(txListItems[2]), '.transaction-list-item__grid')
- retryTxGrid[0].click()
- const retryTxDetails = await findAsync($, '.transaction-list-item-details')
- const headerButtons = await findAsync($(retryTxDetails[0]), '.transaction-list-item-details__header-button')
- assert.equal(headerButtons[0].textContent, 'speed up')
+ const unapprovedMsg = txListItems[0]
+ const unapprovedMsgDescription = await findAsync($(unapprovedMsg), '.transaction-list-item__action')
+ assert.equal(unapprovedMsgDescription[0].textContent, 'Signature Request', 'unapprovedMsg has correct description')
const approvedTx = txListItems[2]
const approvedTxRenderedStatus = await findAsync($(approvedTx), '.transaction-list-item__status')
assert.equal(approvedTxRenderedStatus[0].textContent, 'pending', 'approvedTx has correct label')
- const unapprovedMsg = txListItems[0]
- const unapprovedMsgDescription = await findAsync($(unapprovedMsg), '.transaction-list-item__action')
- assert.equal(unapprovedMsgDescription[0].textContent, 'Signature Request', 'unapprovedMsg has correct description')
-
- const failedTx = txListItems[4]
- const failedTxRenderedStatus = await findAsync($(failedTx), '.transaction-list-item__status')
- assert.equal(failedTxRenderedStatus[0].textContent, 'Failed', 'failedTx has correct label')
+ const confirmedTokenTx1 = txListItems[4]
+ const confirmedTokenTx1Address = await findAsync($(confirmedTokenTx1), '.transaction-list-item__status')
+ assert.equal(confirmedTokenTx1Address[0].textContent, 'Confirmed', 'confirmedTokenTx has correct status')
- 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 shapeShiftTx1 = txListItems[5]
+ const shapeShiftTx1Status = await findAsync($(shapeShiftTx1), '.flex-column div:eq(1)')
+ assert.equal(shapeShiftTx1Status[0].textContent, 'No deposits received', 'shapeShiftTx has correct status')
- const confirmedTokenTx = txListItems[6]
- const confirmedTokenTxAddress = await findAsync($(confirmedTokenTx), '.transaction-list-item__status')
- assert.equal(confirmedTokenTxAddress[0].textContent, 'Confirmed', 'confirmedTokenTx has correct address')
+ const confirmedTokenTx2 = txListItems[6]
+ const confirmedTokenTx2Address = await findAsync($(confirmedTokenTx2), '.transaction-list-item__status')
+ assert.equal(confirmedTokenTx2Address[0].textContent, 'Confirmed', 'confirmedTokenTx has correct status')
- const rejectedTx = txListItems[7]
- const rejectedTxRenderedStatus = await findAsync($(rejectedTx), '.transaction-list-item__status')
- assert.equal(rejectedTxRenderedStatus[0].textContent, 'Rejected', 'rejectedTx has correct label')
+ const shapeShiftTx2 = txListItems[7]
+ const shapeShiftTx2Address = await findAsync($(shapeShiftTx2), '.flex-column div:eq(1)')
+ assert.equal(shapeShiftTx2Address[0].textContent, 'No deposits received', 'shapeShiftTx has correct status')
}