diff --git a/package.json b/package.json index 791de96a81..3fcd8992cf 100644 --- a/package.json +++ b/package.json @@ -182,6 +182,7 @@ "nightwatch_local_publishContract": "nightwatch ./test-browser/tests/publishContract.js --config nightwatch.js --env chrome ", "nightwatch_local_generalSettings": "nightwatch ./test-browser/tests/generalSettings.js --config nightwatch.js --env chrome ", "nightwatch_local_fileExplorer": "nightwatch ./test-browser/tests/fileExplorer.js --config nightwatch.js --env chrome ", + "nightwatch_local_debugger": "nightwatch ./test-browser/tests/debugger.js --config nightwatch.js --env chrome ", "onchange": "onchange build/app.js -- npm-run-all lint", "prepublish": "mkdirp build; npm-run-all -ls downloadsolc_root build", "remixd": "remixd -s ./contracts --remix-ide http://127.0.0.1:8080", diff --git a/src/app/editor/editor.js b/src/app/editor/editor.js index 976d242d43..d418e48c16 100644 --- a/src/app/editor/editor.js +++ b/src/app/editor/editor.js @@ -91,7 +91,7 @@ class Editor extends Plugin { } // Editor Setup - const el = yo`
` + const el = yo`
` this.editor = ace.edit(el) ace.acequire('ace/ext/language_tools') diff --git a/src/app/tabs/debugger/debuggerUI/ButtonNavigator.js b/src/app/tabs/debugger/debuggerUI/ButtonNavigator.js index d65d815eef..8c03ae4aa7 100644 --- a/src/app/tabs/debugger/debuggerUI/ButtonNavigator.js +++ b/src/app/tabs/debugger/debuggerUI/ButtonNavigator.js @@ -47,15 +47,15 @@ ButtonNavigator.prototype.render = function () { var view = yo`
- - + +
- + - +
+
diff --git a/src/app/ui/universal-dapp-ui.js b/src/app/ui/universal-dapp-ui.js index 59381cbd23..975a6a46fd 100644 --- a/src/app/ui/universal-dapp-ui.js +++ b/src/app/ui/universal-dapp-ui.js @@ -60,7 +60,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address var shortAddress = helper.shortenAddress(address) var title = yo`
-
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 new file mode 100644 index 0000000000..65353b055f --- /dev/null +++ b/test-browser/tests/debugger.js @@ -0,0 +1,115 @@ +'use strict' +var init = require('../helpers/init') +var sauce = require('./sauce') + +module.exports = { + + before: function (browser, done) { + init(browser, done) + }, + + '@sources': function () { + return sources + }, + + 'Should launch debugger': function (browser) { + browser.addFile('blah.sol', sources[0]['browser/blah.sol']) + .clickLaunchIcon('udapp') + .waitForElementPresent('*[title="Deploy - transact (not payable)"]') + .click('*[title="Deploy - transact (not payable)"]') + .debugTransaction(0) + .assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'DEBUGGER') + }, + + 'Should debug failing transaction': function (browser) { + browser.waitForElementVisible('*[data-id="verticalIconsKindudapp"]') + .clickLaunchIcon('udapp') + .waitForElementPresent('*[data-id="universalDappUiTitleExpander"]') + .click('*[data-id="universalDappUiTitleExpander"]') + .scrollAndClick('*[title="string name, uint256 goal"]') + .setValue('*[title="string name, uint256 goal"]', '"toast", 999') + .click('*[data-id="createProject - transact (not payable)"]') + .debugTransaction(1) + .pause(2000) + .scrollAndClick('*[data-id="solidityLocals"]') + .assert.containsText('*[data-id="solidityLocals"]', 'toast') + .assert.containsText('*[data-id="solidityLocals"]', '999') + }, + + 'Should debug transaction using slider': function (browser) { + browser.waitForElementVisible('*[data-id="verticalIconsKindudapp"]') + .waitForElementVisible('*[data-id="slider"]') + .click('*[data-id="slider"]') + .setValue('*[data-id="slider"]', 50) + .pause(2000) + .assert.containsText('*[data-id="solidityLocals"]', 'no locals') + .assert.containsText('*[data-id="stepdetail"]', 'vm trace step: 92') + }, + + 'Should step back and forward transaction': function (browser) { + browser.waitForElementVisible('*[data-id="verticalIconsKindudapp"]') + .waitForElementPresent('*[data-id="buttonNavigatorIntoBack"]') + .scrollAndClick('*[data-id="buttonNavigatorIntoBack"]') + .pause(2000) + .assert.containsText('*[data-id="stepdetail"]', 'vm trace step: 91') + .assert.containsText('*[data-id="stepdetail"]', 'execution step: 91') + .click('*[data-id="buttonNavigatorIntoForward"]') + .pause(2000) + .assert.containsText('*[data-id="stepdetail"]', 'vm trace step: 92') + .assert.containsText('*[data-id="stepdetail"]', 'execution step: 92') + }, + + 'Should jump through breakpoints': function (browser) { + browser.waitForElementVisible('*[data-id="editorInput"]') + .click('.ace_gutter-cell:nth-of-type(10)') + .click('.ace_gutter-cell:nth-of-type(20)') + .waitForElementVisible('*[data-id="buttonNavigatorJumpPreviousBreakpoint"]') + .click('*[data-id="buttonNavigatorJumpPreviousBreakpoint"]') + .pause(2000) + .assert.containsText('*[data-id="stepdetail"]', 'vm trace step: 0') + .assert.containsText('*[data-id="stepdetail"]', 'execution step: 0') + .click('*[data-id="buttonNavigatorJumpNextBreakpoint"]') + .pause(2000) + .assert.containsText('*[data-id="stepdetail"]', 'vm trace step: 140') + .assert.containsText('*[data-id="stepdetail"]', 'execution step: 140') + .end() + }, + + tearDown: sauce +} + +var sources = [ + { + 'browser/blah.sol': { + content: ` + pragma solidity >=0.4.22 <0.6.0; + + contract Kickstarter { + + enum State { Started, Completed } + + struct Project { + address owner; + string name; + uint goal; + State state; + } + + Project[] public projects; + + constructor() public { + + } + + function createProject(string memory name, uint goal) public { + Project storage project = projects[projects.length]; + project.name = name; + project.owner = msg.sender; + project.state = State.Started; + project.goal = goal; + } + } + ` + } + } +]