From 8e91078d76df0e0b015e56348153bcf59717797d Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Sat, 21 Mar 2020 16:12:29 +0000 Subject: [PATCH] Debug Transaction Command --- src/app/ui/multiParamManager.js | 11 +++++++--- src/app/ui/txLogger.js | 2 +- test-browser/commands/debugTransaction.js | 25 +++++++++++++++++++++++ test-browser/tests/debugger.js | 10 ++++----- 4 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 test-browser/commands/debugTransaction.js diff --git a/src/app/ui/multiParamManager.js b/src/app/ui/multiParamManager.js index 1f5211bc86..cc8b7007c5 100644 --- a/src/app/ui/multiParamManager.js +++ b/src/app/ui/multiParamManager.js @@ -116,14 +116,15 @@ class MultiParamManager { title = this.funABI.type === 'receive' ? '(receive)' : '(fallback)' } - this.basicInputField = yo`` + this.basicInputField = yo`` this.basicInputField.setAttribute('placeholder', this.inputs) this.basicInputField.setAttribute('title', this.inputs) + this.basicInputField.setAttribute('data-id', this.inputs) var onClick = () => { this.clickCallBack(this.funABI.inputs, this.basicInputField.value) } - let funcButton = yo`` + let funcButton = yo`` this.contractActionsContainerSingle = yo`
${funcButton} @@ -142,7 +143,7 @@ class MultiParamManager { } } - var expandedButton = yo`` + var expandedButton = yo`` this.contractActionsContainerMulti = yo`
@@ -185,6 +186,7 @@ class MultiParamManager { expandedButton.classList.add('btn-info') funcButton.setAttribute('title', (title + ' - call')) funcButton.classList.add('btn-info') + funcButton.setAttribute('data-id', (title + ' - call')) } else if (this.funABI.stateMutability === 'payable' || this.funABI.payable) { // transact. stateMutability = payable expandedButton.setAttribute('title', (title + ' - transact (payable)')) @@ -192,6 +194,7 @@ class MultiParamManager { expandedButton.classList.add('btn-danger') funcButton.setAttribute('title', (title + ' - transact (payable)')) funcButton.classList.add('btn-danger') + funcButton.setAttribute('data-id', (title + ' - transact (payable)')) } else { // transact. stateMutability = nonpayable expandedButton.setAttribute('title', (title + ' - transact (not payable)')) @@ -199,6 +202,7 @@ class MultiParamManager { expandedButton.classList.add('btn-warning') funcButton.classList.add('btn-warning') funcButton.setAttribute('title', (title + ' - transact (not payable)')) + funcButton.setAttribute('data-id', (title + ' - transact (not payable)')) } if (this.funABI.inputs && this.funABI.inputs.length > 0) { @@ -207,6 +211,7 @@ class MultiParamManager { contractProperty.classList.add(css.hasArgs) this.basicInputField.setAttribute('title', `'(${this.funABI.type}')`) // probably should pass name instead this.contractActionsContainerSingle.querySelector('i').style.visibility = 'hidden' + this.basicInputField.setAttribute('data-id', `'(${this.funABI.type}')`) } else { this.contractActionsContainerSingle.querySelector('i').style.visibility = 'hidden' this.basicInputField.style.visibility = 'hidden' diff --git a/src/app/ui/txLogger.js b/src/app/ui/txLogger.js index 4ab75bdc34..dee59fad1f 100644 --- a/src/app/ui/txLogger.js +++ b/src/app/ui/txLogger.js @@ -205,7 +205,7 @@ function log (self, tx, receipt) { } function renderKnownTransaction (self, data, blockchain) { - var from = data.tx.from + var from = data.tx.from var to = data.resolvedData.contractName + '.' + data.resolvedData.fn var obj = {from, to} var txType = 'knownTx' diff --git a/test-browser/commands/debugTransaction.js b/test-browser/commands/debugTransaction.js new file mode 100644 index 0000000000..7ef32af5a3 --- /dev/null +++ b/test-browser/commands/debugTransaction.js @@ -0,0 +1,25 @@ +const EventEmitter = require('events') + +class debugTransaction extends EventEmitter { + command (index = 0) { + this.api.perform((done) => { + checkStyle(this.api, index, () => { + done() + this.emit('complete') + }) + }) + return this + } +} + +function checkStyle (browser, index, callback) { + browser.pause(2000).execute(function (index) { + const debugBtn = document.querySelectorAll('*[data-shared="txLoggerDebugButton"]')[index] + + debugBtn.click() + }, [index], function () { + callback() + }) +} + +module.exports = debugTransaction diff --git a/test-browser/tests/debugger.js b/test-browser/tests/debugger.js index e09fb36aee..083ba7fbca 100644 --- a/test-browser/tests/debugger.js +++ b/test-browser/tests/debugger.js @@ -17,8 +17,7 @@ module.exports = { .clickLaunchIcon('udapp') .waitForElementPresent('*[title="Deploy - transact (not payable)"]') .click('*[title="Deploy - transact (not payable)"]') - .waitForElementPresent('*[data-shared="txLoggerDebugButton"]:nth-of-type(1)') - .click('*[data-shared="txLoggerDebugButton"]:nth-of-type(1)') + .debugTransaction(0) .assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'DEBUGGER') }, @@ -27,9 +26,10 @@ module.exports = { .clickLaunchIcon('udapp') .waitForElementPresent('*[data-id="universalDappUiTitleExpander"]') .click('*[data-id="universalDappUiTitleExpander"]') - .waitForElementPresent('*[data-shared="multiParamManagerBasicInputField"]:nth-of-type(1)') - .sendKeys('*[data-shared="multiParamManagerBasicInputField"]:nth-of-type(1)', '"toast", 999') - .pause(100000) + .scrollAndClick('*[title="string name, uint256 goal"]') + .setValue('*[title="string name, uint256 goal"]', '"toast", 999') + .click('*[data-id="createProject - transact (not payable)"]') + .debugTransaction(1) .end() },