Added tests to terminal.js and created journalChildIncludes command to check if any child element of journal (console) contains a value.

pull/1/head
ioedeveloper 5 years ago
parent fc2f947c42
commit 4bb44b8d04
  1. 1
      test-browser/commands/executeScript.js
  2. 30
      test-browser/commands/journalChildIncludes.js
  3. 46
      test-browser/tests/terminal.js

@ -3,6 +3,7 @@ const EventEmitter = require('events')
class ExecuteScript extends EventEmitter { class ExecuteScript extends EventEmitter {
command (script) { command (script) {
this.api this.api
.clearValue('#terminalCliInput')
.click('#terminalCli') .click('#terminalCli')
.keys(script) .keys(script)
.keys(this.api.Keys.ENTER) .keys(this.api.Keys.ENTER)

@ -0,0 +1,30 @@
const EventEmitter = require('events')
/*
Checks if any child elements of journal (console) contains a value.
*/
class JournalChildIncludes extends EventEmitter {
command (val) {
let isTextFound = false
const browser = this.api
this.api.elements('css selector', '#journal', (res) => {
res.value.forEach(function (jsonWebElement) {
const jsonWebElementId = jsonWebElement.ELEMENT
browser.elementIdText(jsonWebElementId, (jsonElement) => {
const text = jsonElement.value
if (text.indexOf(val) !== -1) isTextFound = true
})
})
})
browser.perform(() => {
browser.assert.ok(isTextFound, isTextFound ? `<#journal> contains ${val}.` : `${val} not found in <#journal > div:last-child>`)
this.emit('complete')
})
return this
}
}
module.exports = JournalChildIncludes

@ -4,14 +4,56 @@ var sauce = require('./sauce')
module.exports = { module.exports = {
before: function (browser, done) { before: function (browser, done) {
init(browser, done) init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false)
}, },
'SimpleExecutionConsole': function (browser) {
'Should execution a simple console command': function (browser) {
browser browser
.waitForElementVisible('#terminalCli', 10000) .waitForElementVisible('#terminalCli', 10000)
.executeScript('1+1') .executeScript('1+1')
.journalLastChild('2') .journalLastChild('2')
},
'Should clear console': function (browser) {
browser
.waitForElementVisible('#terminalCli')
.journalChildIncludes('Welcome to Remix')
.click('#clearConsole')
.assert.containsText('#journal', '')
},
'Should display auto-complete menu': function (browser) {
browser
.waitForElementVisible('#terminalCli')
.click('#terminalCli')
.keys('remix.')
.assert.visible('div[class^="autoCompleteItem"]')
},
'Should execute remix.help() command': function (browser) {
browser
.waitForElementVisible('#terminalCli')
.executeScript('remix.help()')
.journalChildIncludes('remix.call(message: {name, key, payload})')
.journalChildIncludes('remix.getFile(path)')
.journalChildIncludes('remix.debug(hash)')
.journalChildIncludes('remix.loadgist(id)')
.journalChildIncludes('remix.loadurl(url)')
.journalChildIncludes('remix.setproviderurl(url)')
.journalChildIncludes('remix.execute(filepath)')
.journalChildIncludes('remix.exeCurrent()')
.journalChildIncludes('remix.help()')
.journalChildIncludes('remix.debugHelp()')
},
'Should execute remix.debugHelp() command': function (browser) {
browser
.waitForElementVisible('#terminalCli')
.executeScript('remix.debugHelp()')
.journalChildIncludes('Here are some examples of scripts that can be run (using remix.exeCurrent() or directly from the console)')
.journalChildIncludes('Please see https://www.npmjs.com/package/remix-debug for more informations')
.end() .end()
}, },
tearDown: sauce tearDown: sauce
} }

Loading…
Cancel
Save