Modified testFunction command

pull/5370/head
ioedeveloper 5 years ago committed by yann300
parent 9806a205d4
commit cf2632c3b7
  1. 2
      src/app/components/vertical-icons.js
  2. 2
      src/app/udapp/run-tab.js
  3. 7
      src/app/ui/multiParamManager.js
  4. 2
      src/app/ui/txLogger.js
  5. 2
      test-browser/commands/goToVMTraceStep.js
  6. 73
      test-browser/commands/testFunction.js
  7. 13
      test-browser/commands/testTransactionLog.js
  8. 23
      test-browser/tests/ballot.js

@ -262,7 +262,7 @@ export class VerticalIcons extends Plugin {
`
this.iconKind['debugging'] = yo`
<div id='debuggingIcons'>
<div id='debuggingIcons' data-id="verticalIconsDebuggingIcons">
</div>
`

@ -47,7 +47,7 @@ export class RunTab extends LibraryPlugin {
}
renderContainer () {
this.container = yo`<div class="${css.runTabView} run-tab" id="runTabView" ></div>`
this.container = yo`<div class="${css.runTabView} run-tab" id="runTabView" data-id="runTabView"></div>`
var el = yo`
<div class="list-group list-group-flush">

@ -100,7 +100,7 @@ class MultiParamManager {
if (this.funABI.inputs) {
return yo`<div>
${this.funABI.inputs.map(function (inp) {
return yo`<div class="${css.multiArg}"><label for="${inp.name}"> ${inp.name}: </label><input class="form-control" placeholder="${inp.type}" title="${inp.name}"></div>`
return yo`<div class="${css.multiArg}"><label for="${inp.name}"> ${inp.name}: </label><input class="form-control" placeholder="${inp.type}" title="${inp.name}" data-id="multiParamManagerInput${inp.name}"></div>`
})}
</div>`
}
@ -119,7 +119,7 @@ class MultiParamManager {
this.basicInputField = yo`<input class="form-control"></input>`
this.basicInputField.setAttribute('placeholder', this.inputs)
this.basicInputField.setAttribute('title', this.inputs)
this.basicInputField.setAttribute('data-id', this.inputs)
this.basicInputField.setAttribute('data-id', `multiParamManagerBasicInputField${this.inputs}`)
var onClick = () => {
this.clickCallBack(this.funABI.inputs, this.basicInputField.value)
@ -184,6 +184,7 @@ class MultiParamManager {
expandedButton.setAttribute('title', (title + ' - call'))
expandedButton.innerHTML = 'call'
expandedButton.classList.add('btn-info')
expandedButton.setAttribute('data-id', (title + ' - call'))
funcButton.setAttribute('title', (title + ' - call'))
funcButton.classList.add('btn-info')
funcButton.setAttribute('data-id', (title + ' - call'))
@ -192,6 +193,7 @@ class MultiParamManager {
expandedButton.setAttribute('title', (title + ' - transact (payable)'))
expandedButton.innerHTML = 'transact'
expandedButton.classList.add('btn-danger')
expandedButton.setAttribute('data-id', (title + ' - transact (payable)'))
funcButton.setAttribute('title', (title + ' - transact (payable)'))
funcButton.classList.add('btn-danger')
funcButton.setAttribute('data-id', (title + ' - transact (payable)'))
@ -200,6 +202,7 @@ class MultiParamManager {
expandedButton.setAttribute('title', (title + ' - transact (not payable)'))
expandedButton.innerHTML = 'transact'
expandedButton.classList.add('btn-warning')
expandedButton.setAttribute('data-id', (title + ' - transact (not payable)'))
funcButton.classList.add('btn-warning')
funcButton.setAttribute('title', (title + ' - transact (not payable)'))
funcButton.setAttribute('data-id', (title + ' - transact (not payable)'))

@ -215,7 +215,7 @@ function renderKnownTransaction (self, data, blockchain) {
${checkTxStatus(data.receipt, txType)}
${context(self, {from, to, data}, blockchain)}
<div class=${css.buttons}>
<button data-shared="txLoggerDebugButton" class="${css.debug} btn btn-primary btn-sm" onclick=${(e) => debug(e, data, self)}>Debug</div>
<button data-shared="txLoggerDebugButton" data-id="txLoggerDebugButton${data.tx.hash}" class="${css.debug} btn btn-primary btn-sm" onclick=${(e) => debug(e, data, self)}>Debug</div>
</div>
<i class="${css.arrow} fas fa-angle-down"></i>
</div>

@ -28,7 +28,7 @@ function goToVMtraceStep (browser, step, incr, done) {
browser.click('#intoforward')
.perform(() => {
setTimeout(() => {
goToVMtraceStep(browser, step, done, incr)
goToVMtraceStep(browser, step, incr, done)
}, 200)
})
}

@ -0,0 +1,73 @@
const EventEmitter = require('events')
const deepequal = require('deep-equal')
class TestFunction extends EventEmitter {
command (fnFullName, txHash, expectedReturn, input) {
const browser = this.api
const logs = {}
const setLog = (index, value) => logs[Object.keys(logs)[index]] = value;
browser.waitForElementPresent(`*[data-id="${fnFullName}"]`)
.perform(function (client, done) {
client.execute(function () {
document.querySelector('*[data-id="runTabView"]').scrollTop = document.querySelector('*[data-id="runTabView"]').scrollHeight
}, [], function () {
if (input) {
client.setValue(`*[data-id="multiParamManagerBasicInputField${input.types}"]`, input.values, function () {})
}
done()
})
})
.click(`*[data-id="${fnFullName}"]`)
.pause(500)
.waitForElementVisible(`*[data-id="txLogger${txHash}"]`)
.click(`*[data-id="txLogger${txHash}"]`)
.waitForElementVisible(`*[data-id="txLoggerTable${txHash}"]`)
.click(`*[data-id="txLoggerTable${txHash}"]`)
// fetch and format transaction logs as key => pair object
.elements('css selector', `*[data-shared="key_${txHash}"]`, (res) => {
res.value.forEach(function (jsonWebElement) {
const jsonWebElementId = jsonWebElement.ELEMENT
browser.elementIdText(jsonWebElementId, (jsonElement) => {
const key = jsonElement.value.trim()
logs[key] = null
})
})
})
.elements('css selector', `*[data-shared="pair_${txHash}"]`, (res) => {
res.value.forEach(function (jsonWebElement, index) {
const jsonWebElementId = jsonWebElement.ELEMENT
browser.elementIdText(jsonWebElementId, (jsonElement) => {
let value = jsonElement.value
try{
value = JSON.parse(jsonElement.value)
setLog(index, value)
}catch(e){
setLog(index, value)
}
})
})
})
browser.perform(() => {
Object.keys(expectedReturn).forEach(key => {
const equal = deepequal(logs[key], expectedReturn[key])
if (!equal) {
browser.assert.fail(`Expected ${expectedReturn[key]} but got ${logs[key]}`)
}else{
browser.assert.ok(true, `Expected value matched returned value ${expectedReturn[key]}`)
}
})
this.emit('complete')
})
return this
}
}
module.exports = TestFunction

@ -7,6 +7,19 @@ class testTransactionLog extends EventEmitter {
const logs = {}
const setLog = (index, value) => logs[Object.keys(logs)[index]] = value;
browser.waitForElementPresent('.instance button[title="' + fnFullName + '"]')
.perform(function (client, done) {
client.execute(function () {
document.querySelector('#runTabView').scrollTop = document.querySelector('#runTabView').scrollHeight
}, [], function () {
if (expectedInput) {
client.setValue('#runTabView input[title="' + expectedInput.types + '"]', expectedInput.values, function () {})
}
done()
})
})
.click('.instance button[title="' + fnFullName + '"]')
.pause(500)
browser.waitForElementVisible(`*[data-id="txLogger${txHash}"]`)
.click(`*[data-id="txLogger${txHash}"]`)
.waitForElementVisible(`*[data-id="txLoggerTable${txHash}"]`)

@ -16,23 +16,24 @@ module.exports = {
},
'Deploy Ballot': function (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('solidity')
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.clickLaunchIcon('udapp')
.selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c')
.setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]')
.click('#runTabView button[class^="instanceButton"]')
.click('*[data-id="Deploy - transact (not payable)"]')
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
.createContract(["0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3"])
.testTransactionLog('0x57f7ac07a894739a8bbf059248f47aa49935bfcf673494114b1c5c0c183890f0', {
status: '0x1 Transaction mined and execution succeed',
'transaction hash': '0x57f7ac07a894739a8bbf059248f47aa49935bfcf673494114b1c5c0c183890f0',
'decoded input': {
'bytes32[] proposalNames': [ '0x48656c6c6f20576f726c64210000000000000000000000000000000000000000' ]
}
})
.click('*[data-id="universalDappUiTitleExpander"]')
.testFunction(
'delegate - transact (not payable)',
'0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
{
status: '0x1 Transaction mined and execution succeed',
'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
},
{types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
},
'Debug Ballot / delegate': function (browser) {

Loading…
Cancel
Save