add browser tests

pull/5370/head
yann300 5 years ago
parent a7e597bad0
commit a80bb04208
  1. 1
      package.json
  2. 4
      src/app/files/file-explorer.js
  3. 1
      test-browser/commands/executeScript.js
  4. 16
      test-browser/commands/getModalBody.js
  5. 17
      test-browser/commands/modalFooterCancelClick.js
  6. 2
      test-browser/commands/modalFooterOKClick.js
  7. 1
      test-browser/commands/switchFile.js
  8. 45
      test-browser/tests/gist.js

@ -170,6 +170,7 @@
"nightwatch_local_solidityUnittests": "nightwatch ./test-browser/tests/solidityUnittests.js --config nightwatch.js --env chrome ",
"nightwatch_local_remixd": "nightwatch ./test-browser/tests/remix.js --config nightwatch.js --env chrome ",
"nightwatch_local_console": "nightwatch ./test-browser/tests/console.js --config nightwatch.js --env chrome ",
"nightwatch_local_gist": "nightwatch ./test-browser/tests/gist.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",

@ -633,7 +633,7 @@ fileExplorer.prototype.renderMenuItems = function () {
items = this.menuItems.map(({action, title, icon}) => {
if (action === 'uploadFile') {
return yo`
<label class="${icon} ${css.newFile}" title="${title}">
<label id=${action} class="${icon} ${css.newFile}" title="${title}">
<input type="file" onchange=${(event) => {
event.stopPropagation()
this.uploadFile(event)
@ -642,7 +642,7 @@ fileExplorer.prototype.renderMenuItems = function () {
`
} else {
return yo`
<span onclick=${(event) => { event.stopPropagation(); this[ action ]() }} class="newFile ${icon} ${css.newFile}" title=${title}></span>
<span id=${action} onclick=${(event) => { event.stopPropagation(); this[ action ]() }} class="newFile ${icon} ${css.newFile}" title=${title}></span>
`
}
})

@ -6,6 +6,7 @@ class ExecuteScript extends EventEmitter {
.click('#terminalCli')
.keys(script)
.keys(this.api.Keys.ENTER)
.keys(this.api.Keys.ENTER) // that's a bug... sometimes we need to press 2 times to execute a command
.perform(() => {
this.emit('complete')
})

@ -0,0 +1,16 @@
const EventEmitter = require('events')
class GetModalBody extends EventEmitter {
command (callback) {
this.api.waitForElementVisible('.modal-body')
.getText('.modal-body', (result) => {
console.log(result)
callback(result.value, () => {
this.emit('complete')
})
})
return this
}
}
module.exports = GetModalBody

@ -0,0 +1,17 @@
const EventEmitter = require('events')
class ModalFooterOKClick extends EventEmitter {
command () {
this.api.waitForElementVisible('#modal-footer-cancel').perform((client, done) => {
this.api.execute(function () {
document.querySelector('#modal-footer-cancel').click()
}, [], (result) => {
done()
this.emit('complete')
})
})
return this
}
}
module.exports = ModalFooterOKClick

@ -2,7 +2,7 @@ const EventEmitter = require('events')
class ModalFooterOKClick extends EventEmitter {
command () {
this.api.perform((client, done) => {
this.api.waitForElementVisible('#modal-footer-ok').perform((client, done) => {
this.api.execute(function () {
document.querySelector('#modal-footer-ok').click()
}, [], (result) => {

@ -15,6 +15,7 @@ class SwitchFile extends EventEmitter {
// click on fileExplorer can toggle it. We go through settings to be sure FE is open
function switchFile (browser, name, done) {
browser.clickLaunchIcon('settings').clickLaunchIcon('fileExplorers')
.waitForElementVisible('li[key="' + name + '"]')
.click('li[key="' + name + '"]')
.pause(2000)
.perform(() => {

@ -0,0 +1,45 @@
'use strict'
const init = require('../helpers/init')
const sauce = require('./sauce')
// 99266d6da54cc12f37f11586e8171546c7700d67
module.exports = {
before: function (browser, done) {
init(browser, done)
},
'UploadToGists': function (browser) {
/*
- set the access token
- publish to gist
- retrieve the gist
- switch to a file in the new gist
*/
console.log('token', process.env.gist_token)
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('settings')
.setValue('#gistaccesstoken', process.env.gist_token)
.click('#savegisttoken')
.clickLaunchIcon('fileExplorers')
.click('#publishToGist')
.modalFooterOKClick()
.getModalBody((value, done) => {
const reg = /gist.github.com\/([^.]+)/
const id = value.match(reg)
console.log('gist regex', id)
if (!id) {
browser.assert.fail('cannot get the gist id', '', '')
} else {
let gistid = id[1]
browser
.modalFooterCancelClick()
.executeScript(`remix.loadgist('${gistid}')`)
.switchFile('browser/gists')
.switchFile(`browser/gists/${gistid}`)
.switchFile(`browser/gists/${gistid}/1_Storage.sol`)
.end()
}
})
},
tearDown: sauce
}
Loading…
Cancel
Save