2018-02-06 19:20:37 +01:00
|
|
|
const reactTriggerChange = require('react-trigger-change')
|
2018-03-12 03:29:35 +01:00
|
|
|
const {
|
2018-07-11 02:09:22 +02:00
|
|
|
timeout,
|
2018-03-12 03:29:35 +01:00
|
|
|
queryAsync,
|
|
|
|
} = require('../../lib/util')
|
2020-01-13 16:07:32 +01:00
|
|
|
const fetchMockResponses = require('../../data/fetch-mocks.json')
|
2018-02-06 19:20:37 +01:00
|
|
|
|
|
|
|
QUnit.module('confirm sig requests')
|
|
|
|
|
|
|
|
QUnit.test('successful confirmation of sig requests', (assert) => {
|
|
|
|
const done = assert.async()
|
|
|
|
runConfirmSigRequestsTest(assert).then(done).catch((err) => {
|
|
|
|
assert.notOk(err, `Error was thrown: ${err.stack}`)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-05-07 19:52:02 +02:00
|
|
|
global.ethQuery = global.ethQuery || {}
|
|
|
|
|
2019-05-08 21:51:33 +02:00
|
|
|
async function runConfirmSigRequestsTest (assert) {
|
2018-07-03 00:49:33 +02:00
|
|
|
const selectState = await queryAsync($, 'select')
|
2018-02-06 19:20:37 +01:00
|
|
|
selectState.val('confirm sig requests')
|
|
|
|
reactTriggerChange(selectState[0])
|
|
|
|
|
2019-05-07 19:52:02 +02:00
|
|
|
const realFetch = window.fetch.bind(window)
|
2020-04-15 19:23:27 +02:00
|
|
|
window.fetch = (...args) => {
|
2019-05-07 19:52:02 +02:00
|
|
|
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].match(/chromeextensionmm/)) {
|
2019-03-05 16:45:01 +01:00
|
|
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
|
|
|
}
|
2019-05-07 19:52:02 +02:00
|
|
|
return realFetch.fetch(...args)
|
2019-03-05 16:45:01 +01:00
|
|
|
}
|
|
|
|
|
2018-09-01 01:03:02 +02:00
|
|
|
const pendingRequestItem = $.find('.transaction-list-item .transaction-list-item__grid')
|
2018-04-06 11:04:39 +02:00
|
|
|
|
2020-01-10 15:34:02 +01:00
|
|
|
if (pendingRequestItem[0]) {
|
|
|
|
pendingRequestItem[0].click()
|
2018-04-06 11:04:39 +02:00
|
|
|
}
|
2018-04-05 03:46:22 +02:00
|
|
|
|
2018-07-11 02:09:22 +02:00
|
|
|
await timeout(1000)
|
|
|
|
|
2018-03-12 03:29:35 +01:00
|
|
|
let confirmSigHeadline = await queryAsync($, '.request-signature__headline')
|
2018-02-06 19:20:37 +01:00
|
|
|
assert.equal(confirmSigHeadline[0].textContent, 'Your signature is being requested')
|
|
|
|
|
2018-03-12 03:29:35 +01:00
|
|
|
let confirmSigRowValue = await queryAsync($, '.request-signature__row-value')
|
2020-01-10 15:34:02 +01:00
|
|
|
assert.equal(confirmSigRowValue[0].textContent, 'Hi, Alice!')
|
|
|
|
assert.equal(confirmSigRowValue[1].textContent, '1337')
|
2018-02-06 19:20:37 +01:00
|
|
|
|
2019-04-16 21:35:22 +02:00
|
|
|
let confirmSigSignButton = await queryAsync($, 'button.btn-secondary.btn--large')
|
2018-02-06 19:20:37 +01:00
|
|
|
confirmSigSignButton[0].click()
|
2018-07-11 02:09:22 +02:00
|
|
|
await timeout(1000)
|
2018-03-12 03:29:35 +01:00
|
|
|
confirmSigHeadline = await queryAsync($, '.request-signature__headline')
|
2018-02-06 19:20:37 +01:00
|
|
|
assert.equal(confirmSigHeadline[0].textContent, 'Your signature is being requested')
|
|
|
|
|
2018-04-06 11:04:39 +02:00
|
|
|
confirmSigRowValue = await queryAsync($, '.request-signature__row-value')
|
2018-07-03 01:52:49 +02:00
|
|
|
assert.ok(confirmSigRowValue[0].textContent.match(/^#\sTerms\sof\sUse/))
|
2018-02-06 19:20:37 +01:00
|
|
|
|
2019-04-16 21:35:22 +02:00
|
|
|
confirmSigSignButton = await queryAsync($, 'button.btn-secondary.btn--large')
|
2018-02-06 19:20:37 +01:00
|
|
|
confirmSigSignButton[0].click()
|
2018-07-11 02:09:22 +02:00
|
|
|
await timeout(1000)
|
2018-03-12 03:29:35 +01:00
|
|
|
confirmSigHeadline = await queryAsync($, '.request-signature__headline')
|
2018-02-06 19:20:37 +01:00
|
|
|
assert.equal(confirmSigHeadline[0].textContent, 'Your signature is being requested')
|
|
|
|
|
2020-01-10 15:34:02 +01:00
|
|
|
const confirmSigMessage = await queryAsync($, '.request-signature__notice')
|
|
|
|
assert.ok(confirmSigMessage[0].textContent.match(/^Signing\sthis\smessage/))
|
|
|
|
|
2018-03-12 03:29:35 +01:00
|
|
|
confirmSigRowValue = await queryAsync($, '.request-signature__row-value')
|
2020-01-10 15:34:02 +01:00
|
|
|
assert.equal(confirmSigRowValue[0].textContent, '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0')
|
2018-02-06 19:20:37 +01:00
|
|
|
|
2019-04-16 21:35:22 +02:00
|
|
|
confirmSigSignButton = await queryAsync($, 'button.btn-secondary.btn--large')
|
2018-02-06 19:20:37 +01:00
|
|
|
confirmSigSignButton[0].click()
|
2018-07-11 18:07:26 +02:00
|
|
|
|
|
|
|
await timeout(2000)
|
2018-02-06 19:20:37 +01:00
|
|
|
}
|