mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Integration tests for signature requests confirmations. (#3194)
This commit is contained in:
parent
d452403322
commit
a7bfea51e5
26
development/backGroundConnectionModifiers.js
Normal file
26
development/backGroundConnectionModifiers.js
Normal file
@ -0,0 +1,26 @@
|
||||
module.exports = {
|
||||
"confirm sig requests": {
|
||||
signMessage: (msgData, cb) => {
|
||||
const stateUpdate = {
|
||||
unapprovedMsgs: {},
|
||||
unapprovedMsgCount: 0,
|
||||
}
|
||||
return cb(null, stateUpdate)
|
||||
},
|
||||
signPersonalMessage: (msgData, cb) => {
|
||||
const stateUpdate = {
|
||||
unapprovedPersonalMsgs: {},
|
||||
unapprovedPersonalMsgsCount: 0,
|
||||
}
|
||||
return cb(null, stateUpdate)
|
||||
},
|
||||
signTypedMessage: (msgData, cb) => {
|
||||
const stateUpdate = {
|
||||
unapprovedTypedMessages: {},
|
||||
unapprovedTypedMessagesCount: 0,
|
||||
}
|
||||
return cb(null, stateUpdate)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -11,7 +11,14 @@ function NewComponent () {
|
||||
|
||||
NewComponent.prototype.render = function () {
|
||||
const props = this.props
|
||||
let { states, selectedKey, actions, store } = props
|
||||
let {
|
||||
states,
|
||||
selectedKey,
|
||||
actions,
|
||||
store,
|
||||
modifyBackgroundConnection,
|
||||
backGroundConnectionModifiers,
|
||||
} = props
|
||||
|
||||
const state = this.state || {}
|
||||
const selected = state.selected || selectedKey
|
||||
@ -23,6 +30,8 @@ NewComponent.prototype.render = function () {
|
||||
value: selected,
|
||||
onChange:(event) => {
|
||||
const selectedKey = event.target.value
|
||||
const backgroundConnectionModifier = backGroundConnectionModifiers[selectedKey]
|
||||
modifyBackgroundConnection(backgroundConnectionModifier || {})
|
||||
store.dispatch(actions.update(selectedKey))
|
||||
this.setState({ selected: selectedKey })
|
||||
},
|
||||
|
175
development/states/confirm-sig-requests.json
Normal file
175
development/states/confirm-sig-requests.json
Normal file
File diff suppressed because one or more lines are too long
15
mock-dev.js
15
mock-dev.js
@ -20,6 +20,7 @@ const Root = require('./ui/app/root')
|
||||
const configureStore = require('./ui/app/store')
|
||||
const actions = require('./ui/app/actions')
|
||||
const states = require('./development/states')
|
||||
const backGroundConnectionModifiers = require('./development/backGroundConnectionModifiers')
|
||||
const Selector = require('./development/selector')
|
||||
const MetamaskController = require('./app/scripts/metamask-controller')
|
||||
const firstTimeState = require('./app/scripts/first-time-state')
|
||||
@ -85,6 +86,11 @@ actions.update = function(stateName) {
|
||||
}
|
||||
}
|
||||
|
||||
function modifyBackgroundConnection(backgroundConnectionModifier) {
|
||||
const modifiedBackgroundConnection = Object.assign({}, controller.getApi(), backgroundConnectionModifier)
|
||||
actions._setBackgroundConnection(modifiedBackgroundConnection)
|
||||
}
|
||||
|
||||
var css = MetaMaskUiCss()
|
||||
injectCss(css)
|
||||
|
||||
@ -113,7 +119,14 @@ function startApp(){
|
||||
},
|
||||
}, 'Reset State'),
|
||||
|
||||
h(Selector, { actions, selectedKey: selectedView, states, store }),
|
||||
h(Selector, {
|
||||
actions,
|
||||
selectedKey: selectedView,
|
||||
states,
|
||||
store,
|
||||
modifyBackgroundConnection,
|
||||
backGroundConnectionModifiers,
|
||||
}),
|
||||
|
||||
h('#app-content', {
|
||||
style: {
|
||||
|
67
test/integration/lib/confirm-sig-requests.js
Normal file
67
test/integration/lib/confirm-sig-requests.js
Normal file
@ -0,0 +1,67 @@
|
||||
const reactTriggerChange = require('react-trigger-change')
|
||||
|
||||
const PASSWORD = 'password123'
|
||||
|
||||
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()
|
||||
})
|
||||
})
|
||||
|
||||
async function runConfirmSigRequestsTest(assert, done) {
|
||||
let selectState = $('select')
|
||||
selectState.val('confirm sig requests')
|
||||
reactTriggerChange(selectState[0])
|
||||
|
||||
await timeout(2000)
|
||||
|
||||
let confirmSigHeadline = $('.request-signature__headline')
|
||||
assert.equal(confirmSigHeadline[0].textContent, 'Your signature is being requested')
|
||||
|
||||
let confirmSigRowValue = $('.request-signature__row-value')
|
||||
assert.ok(confirmSigRowValue[0].textContent.match(/^\#\sTerms\sof\sUse/))
|
||||
|
||||
let confirmSigSignButton = $('.request-signature__footer__sign-button')
|
||||
confirmSigSignButton[0].click()
|
||||
|
||||
await timeout(2000)
|
||||
|
||||
confirmSigHeadline = $('.request-signature__headline')
|
||||
assert.equal(confirmSigHeadline[0].textContent, 'Your signature is being requested')
|
||||
|
||||
let confirmSigMessage = $('.request-signature__notice')
|
||||
assert.ok(confirmSigMessage[0].textContent.match(/^Signing\sthis\smessage/))
|
||||
|
||||
confirmSigRowValue = $('.request-signature__row-value')
|
||||
assert.equal(confirmSigRowValue[0].textContent, '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0')
|
||||
|
||||
confirmSigSignButton = $('.request-signature__footer__sign-button')
|
||||
confirmSigSignButton[0].click()
|
||||
|
||||
await timeout(2000)
|
||||
|
||||
confirmSigHeadline = $('.request-signature__headline')
|
||||
assert.equal(confirmSigHeadline[0].textContent, 'Your signature is being requested')
|
||||
|
||||
confirmSigRowValue = $('.request-signature__row-value')
|
||||
assert.equal(confirmSigRowValue[0].textContent, 'Hi, Alice!')
|
||||
assert.equal(confirmSigRowValue[1].textContent, '1337')
|
||||
|
||||
confirmSigSignButton = $('.request-signature__footer__sign-button')
|
||||
confirmSigSignButton[0].click()
|
||||
|
||||
await timeout(2000)
|
||||
|
||||
const txView = $('.tx-view')
|
||||
assert.ok(txView[0], 'Should return to the account details screen after confirming')
|
||||
}
|
||||
|
||||
function timeout (time) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(resolve, time || 1500)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user