Commit 4bb44b8d authored by ioedeveloper's avatar ioedeveloper

Added tests to terminal.js and created journalChildIncludes command to check if…

Added tests to terminal.js and created journalChildIncludes command to check if any child element of journal (console) contains a value.
parent fc2f947c
...@@ -3,6 +3,7 @@ const EventEmitter = require('events') ...@@ -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)
......
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') ...@@ -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
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment