tests browser

pull/7/head
yann300 9 years ago
parent 6a09650f54
commit 732c21efd9
  1. 1
      .gitignore
  2. 48
      nightwatch.json
  3. 5
      package.json
  4. 10
      src/ButtonNavigator.js
  5. 1
      src/Slider.js
  6. 11
      src/TxBrowser.js
  7. 2
      src/VmDebugger.js
  8. 6
      src/index.js
  9. 55
      test-browser/index.js
  10. 54
      test/resources/testWeb3.js

1
.gitignore vendored

@ -3,3 +3,4 @@ node_modules
npm-debug.log
lint.xml
.vscode
test-browser/reports/*

@ -0,0 +1,48 @@
{
"src_folders" : ["./test-browser"],
"output_folder" : "./test-browser/reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"globals_path" : "",
"page_objects_path" : "",
"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"chrome" : {
"desiredCapabilities" : {
"browserName" : "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
}
}
}

@ -19,7 +19,7 @@
"yo-yo": "^1.2.1"
},
"devDependencies": {
"nightwatch": "^0.9.4",
"nightwatch": "^0.9.5",
"standard": "^7.0.1",
"standard-reporter": "^1.0.5",
"tape": "^4.6.0"
@ -28,7 +28,8 @@
"start_node": "eth --rpccorsdomain \"*\" -j -v 0",
"build": "mkdir -p build; browserify src/index.js -o build/app.js",
"test": "standard && tape ./test/tests.js",
"serve": "http-server ."
"serve": "http-server .",
"nightwatch": "nightwatch"
},
"repository": {
"type": "git",

@ -21,19 +21,19 @@ module.exports = ButtonNavigator
ButtonNavigator.prototype.render = function () {
var self = this
var view = yo`<div>
<button ref='intoback' onclick=${function () { self.trigger('stepIntoBack') }} disabled=${this.intoBackDisabled} >
<button id='intoback' onclick=${function () { self.trigger('stepIntoBack') }} disabled=${this.intoBackDisabled} >
Step Into Back
</button>
<button ref='overback' onclick=${function () { self.trigger('stepOverBack') }} disabled=${this.overBackDisabled} >
<button id='overback' onclick=${function () { self.trigger('stepOverBack') }} disabled=${this.overBackDisabled} >
Step Over Back
</button>
<button ref='overforward' onclick=${function () { self.trigger('stepOverForward') }} disabled=${this.overForwardDisabled} >
<button id='overforward' onclick=${function () { self.trigger('stepOverForward') }} disabled=${this.overForwardDisabled} >
Step Over Forward
</button>
<button ref='intoforward' onclick=${function () { self.trigger('stepIntoForward') }} disabled=${this.intoForwardDisabled} >
<button id='intoforward' onclick=${function () { self.trigger('stepIntoForward') }} disabled=${this.intoForwardDisabled} >
Step Into Forward
</button>
<button ref='nextcall' onclick=${function () { self.trigger('jumpNextCall') }} disabled=${this.nextCallDisabled} >
<button id='nextcall' onclick=${function () { self.trigger('jumpNextCall') }} disabled=${this.nextCallDisabled} >
Jump Next Call
</button>
</div>`

@ -17,7 +17,6 @@ Slider.prototype.render = function () {
var self = this
var view = yo`<div>
<input
ref='rule'
id='slider'
style=${ui.formatCss(style.rule)}
type='range'

@ -78,7 +78,6 @@ TxBrowser.prototype.updateWeb3Url = function (ev) {
TxBrowser.prototype.checkWeb3 = function () {
try {
console.log('block ' + this.web3.eth.blockNumber)
this.connectInfo = 'Connected to ' + this.web3.currentProvider.host
} catch (e) {
console.log(e)
@ -107,8 +106,8 @@ TxBrowser.prototype.render = function () {
<br />
<br />
<input onkeyup=${function () { self.updateBlockN(arguments[0]) }} type='text' placeholder=${'Block number (default 1000110)' + this.blockNumber} />
<input onkeyup=${function () { self.updateTxN(arguments[0]) }} type='text' value=${this.txNumber} placeholder=${'Transaction Number or hash (default 2) ' + this.txNumber} />
<button onclick=${function () { self.submit() }}>
<input id='txinput' onkeyup=${function () { self.updateTxN(arguments[0]) }} type='text' value=${this.txNumber} placeholder=${'Transaction Number or hash (default 2) ' + this.txNumber} />
<button id='load' onclick=${function () { self.submit() }}>
Get
</button>
<button onclick=${function () { self.trigger('unloadRequested') }}>Unload</button>
@ -119,7 +118,7 @@ TxBrowser.prototype.render = function () {
<td>
Hash:
</td>
<td>
<td id='txhash' >
${this.hash}
</td>
</tr>
@ -127,7 +126,7 @@ TxBrowser.prototype.render = function () {
<td>
From:
</td>
<td>
<td id='txfrom'>
${this.from}
</td>
</tr>
@ -135,7 +134,7 @@ TxBrowser.prototype.render = function () {
<td>
To:
</td>
<td>
<td id='txto' >
${this.to}
</td>
</tr>

@ -27,7 +27,7 @@ function VmDebugger (_parent, _traceManager, _web3) {
}
VmDebugger.prototype.render = function () {
var view = yo`<div style='display:none'>
var view = yo`<div id='vmdebugger' style='display:none'>
<div style=${ui.formatCss(style.container)}>
<table>
<tbody>

@ -1,9 +1,9 @@
'use strict'
var Debugger = require('./Ethdebugger')
function init () {
var ethdebugger = new Debugger()
document.getElementById('app').appendChild(ethdebugger.render())
var container = document.getElementById('app')
container.vmdebugger = new Debugger()
container.appendChild(container.vmdebugger.render())
}
init()

@ -1,7 +1,58 @@
module.exports = {
'Page Load': function (browser) {
beforeEach: function (browser, done) {
init(browser, done)
},
'Load Trace - not found': function (browser) {
browser
.url('http://127.0.0.1:8080')
.clearValue('#txinput')
.setValue('#txinput', '0x20ef65b8b186ca942zcccd634f37074dde49b541c27994fc7596740ef44cfd51')
.click('#load')
.assert.containsText('#txhash', '<not found>')
.end()
},
'Load Trace - found': function (browser) {
browser
.clearValue('#txinput')
.setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
.click('#load')
.waitForElementVisible('#vmdebugger', 1000)
.assert.containsText('#txhash', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
.assert.containsText('#txfrom', '0x00101c5bfa3fc8bad02c9f5fd65b069306251915')
.assert.containsText('#txto', '0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5')
.end()
}
}
function init (browser, callback) {
browser
.url('http://127.0.0.1:8080')
injectScript('./test/resources/testWeb3.js', browser, function () {
callback()
})
}
function readFile (filename, callback) {
var fs = require('fs')
try {
console.log('reading ' + filename)
fs.readFile(filename, 'utf8', callback)
} catch (e) {
console.log(e)
callback(e)
}
}
function injectScript (file, browser, callback) {
readFile(file, function (error, result) {
if (!error) {
browser.execute(function (data) {
eval.call(null, data) // eslint-disable-line
}, [result], function () {
callback()
})
}
})
}

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save