1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/test/integration/lib/tx-list-items.js

65 lines
2.8 KiB
JavaScript
Raw Normal View History

const reactTriggerChange = require('../../lib/react-trigger-change')
const {
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()
})
})
global.ethQuery = global.ethQuery || {}
global.ethQuery.getTransactionCount = (_, cb) => {
cb(null, '0x3')
}
2018-07-03 00:49:33 +02:00
async function runTxListItemsTest (assert, done) {
console.log('*** start runTxListItemsTest')
const selectState = await queryAsync($, 'select')
selectState.val('tx list items')
reactTriggerChange(selectState[0])
2018-05-11 01:51:26 +02:00
const metamaskLogo = await queryAsync($, '.app-header__logo-container')
assert.ok(metamaskLogo[0], 'metamask logo present')
metamaskLogo[0].click()
2018-08-07 07:39:54 +02:00
const txListItems = await queryAsync($, '.transaction-list-item')
assert.equal(txListItems.length, 8, 'all tx list items are rendered')
2018-10-04 23:52:49 +02:00
const retryTxGrid = await findAsync($(txListItems[2]), '.transaction-list-item__grid')
retryTxGrid[0].click()
2018-09-18 06:23:54 +02:00
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 approvedTx = txListItems[2]
2018-08-07 07:39:54 +02:00
const approvedTxRenderedStatus = await findAsync($(approvedTx), '.transaction-list-item__status')
assert.equal(approvedTxRenderedStatus[0].textContent, 'pending', 'approvedTx has correct label')
2018-10-04 23:52:49 +02:00
const unapprovedMsg = txListItems[0]
2018-08-07 07:39:54 +02:00
const unapprovedMsgDescription = await findAsync($(unapprovedMsg), '.transaction-list-item__action')
assert.equal(unapprovedMsgDescription[0].textContent, 'Signature Request', 'unapprovedMsg has correct description')
const failedTx = txListItems[4]
2018-08-07 07:39:54 +02:00
const failedTxRenderedStatus = await findAsync($(failedTx), '.transaction-list-item__status')
2018-08-24 04:19:48 +02:00
assert.equal(failedTxRenderedStatus[0].textContent, 'Failed', 'failedTx has correct label')
2018-05-11 01:51:26 +02:00
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]
2018-08-07 07:39:54 +02:00
const confirmedTokenTxAddress = await findAsync($(confirmedTokenTx), '.transaction-list-item__status')
2018-08-24 04:19:48 +02:00
assert.equal(confirmedTokenTxAddress[0].textContent, 'Confirmed', 'confirmedTokenTx has correct address')
const rejectedTx = txListItems[7]
2018-08-07 07:39:54 +02:00
const rejectedTxRenderedStatus = await findAsync($(rejectedTx), '.transaction-list-item__status')
2018-08-24 04:19:48 +02:00
assert.equal(rejectedTxRenderedStatus[0].textContent, 'Rejected', 'rejectedTx has correct label')
}