Added debugger tests

pull/5370/head
ioedeveloper 5 years ago
parent dfa5671d38
commit f496b978d6
  1. 1
      apps/remix-ide-e2e/.eslintrc
  2. 2
      apps/remix-ide-e2e/src/commands/clearEditableContent.ts
  3. 2
      apps/remix-ide-e2e/src/commands/clickLaunchIcon.ts
  4. 26
      apps/remix-ide-e2e/src/commands/debugTransaction.ts
  5. 32
      apps/remix-ide-e2e/src/commands/journalChildIncludes.ts
  6. 4
      apps/remix-ide-e2e/src/tests/compiler_api.test.ts
  7. 116
      apps/remix-ide-e2e/src/tests/debugger.test.ts
  8. 7
      apps/remix-ide-e2e/src/types/index.d.ts

@ -9,6 +9,5 @@
}
}
],
"extends": ["../../.eslintrc"],
"ignorePatterns": ["!**/*"]
}

@ -13,7 +13,7 @@ class clearEditablecontent extends EventEmitter {
}
}
function clearContent (browser, cssSelector, callback) {
function clearContent (browser: NightwatchBrowser, cssSelector: string, callback: VoidFunction) {
browser.execute(function (cssSelector) {
const selection = window.getSelection()
const range = document.createRange()

@ -11,4 +11,4 @@ class ClickLaunchIcon extends EventEmitter {
}
}
module.exports = ClickLaunchIcon
module.exports = ClickLaunchIcon

@ -0,0 +1,26 @@
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class debugTransaction extends EventEmitter {
command (this: NightwatchBrowser, index = 0): NightwatchBrowser {
this.api.perform((done) => {
checkStyle(this.api, index, () => {
done()
this.emit('complete')
})
})
return this
}
}
function checkStyle (browser: NightwatchBrowser, index: number, callback: VoidFunction) {
browser.pause(2000).execute(function (index: number) {
const debugBtn = document.querySelectorAll('*[data-shared="txLoggerDebugButton"]')[index] as HTMLInputElement
debugBtn.click()
}, [index], function () {
callback()
})
}
module.exports = debugTransaction

@ -0,0 +1,32 @@
import { NightwatchBrowser } from "nightwatch"
const EventEmitter = require('events')
/*
Checks if any child elements of journal (console) contains a matching value.
*/
class JournalChildIncludes extends EventEmitter {
command (this: NightwatchBrowser, val: string): NightwatchBrowser {
let isTextFound = false
const browser = this.api
this.api.elements('css selector', '*[data-id="terminalJournal"]', (res) => {
Array.isArray(res.value) && res.value.forEach(function (jsonWebElement) {
const jsonWebElementId = jsonWebElement.ELEMENT || jsonWebElement[Object.keys(jsonWebElement)[0]]
browser.elementIdText(jsonWebElementId, (jsonElement) => {
const text = jsonElement.value
if (typeof text === 'string' && text.indexOf(val) !== -1) isTextFound = true
})
})
})
browser.perform(() => {
browser.assert.ok(isTextFound, isTextFound ? `<*[data-id="terminalJournal"]> contains ${val}.` : `${val} not found in <*[data-id="terminalJournal"]> div:last-child>`)
this.emit('complete')
})
return this
}
}
module.exports = JournalChildIncludes

@ -9,11 +9,11 @@ const sources = [
{'browser/Untitled.sol': { content: examples.ballot.content }}
]
module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
@ -32,7 +32,7 @@ module.exports = {
.executeScript('remix.exeCurrent()')
.pause(5000)
.addFile('test_updateConfiguration.sol', { content: simpleContract })
.verifyContracts(['StorageTestUpdateConfiguration'], {wait: 5000, version: '0.6.8+commit.0bbfe453'})
.verifyContracts(['StorageTestUpdateConfiguration'], { wait: 5000, version: '0.6.8+commit.0bbfe453' })
.end()
},

@ -0,0 +1,116 @@
'use strict'
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Should launch debugger': function (browser: NightwatchBrowser) {
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: NightwatchBrowser) {
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: NightwatchBrowser) {
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:\n92')
},
'Should step back and forward transaction': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindudapp"]')
.waitForElementPresent('*[data-id="buttonNavigatorIntoBack"]')
.scrollAndClick('*[data-id="buttonNavigatorIntoBack"]')
.pause(2000)
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n91')
.assert.containsText('*[data-id="stepdetail"]', 'execution step:\n91')
.click('*[data-id="buttonNavigatorIntoForward"]')
.pause(2000)
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n92')
.assert.containsText('*[data-id="stepdetail"]', 'execution step:\n92')
},
'Should jump through breakpoints': function (browser: NightwatchBrowser) {
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:\n0')
.assert.containsText('*[data-id="stepdetail"]', 'execution step:\n0')
.click('*[data-id="buttonNavigatorJumpNextBreakpoint"]')
.pause(2000)
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n184')
.assert.containsText('*[data-id="stepdetail"]', 'execution step:\n184')
.end()
},
tearDown: sauce
}
const 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;
}
}
`
}
}
]

@ -11,7 +11,7 @@ declare module "nightwatch" {
testContracts(fileName: string, contractCode: NightwatchContractContent, compiledContractNames: string[]): NightwatchBrowser,
setEditorValue(value: string, callback?: () => void): NightwatchBrowser,
addFile(name: string, content: NightwatchContractContent): NightwatchBrowser,
verifyContracts(compiledContractNames: string[]): NightwatchBrowser,
verifyContracts(compiledContractNames: string[], opts?: { wait: number, version: string }): NightwatchBrowser,
selectAccount(account?: string): NightwatchBrowser,
clickFunction(fnFullName: string, expectedInput?: NightwatchClickFunctionExpectedInput): NightwatchBrowser,
testFunction(txHash: string, expectedInput: NightwatchTestFunctionExpectedInput): NightwatchBrowser,
@ -21,7 +21,10 @@ declare module "nightwatch" {
modalFooterOKClick(): NightwatchBrowser,
clickInstance(index: number): NightwatchBrowser,
journalLastChildIncludes(val: string): NightwatchBrowser,
executeScript(script: string): NightwatchBrowser
executeScript(script: string): NightwatchBrowser,
clearEditableContent(cssSelector: string): NightwatchBrowser,
journalChildIncludes(val: string): NightwatchBrowser,
debugTransaction(index: number): NightwatchBrowser
}
export interface NightwatchBrowser {

Loading…
Cancel
Save