diff --git a/test-browser/commands/executeScript.js b/test-browser/commands/executeScript.js index eb673dad69..b33370ae98 100644 --- a/test-browser/commands/executeScript.js +++ b/test-browser/commands/executeScript.js @@ -3,6 +3,7 @@ const EventEmitter = require('events') class ExecuteScript extends EventEmitter { command (script) { this.api + .clearValue('#terminalCliInput') .click('#terminalCli') .keys(script) .keys(this.api.Keys.ENTER) diff --git a/test-browser/commands/journalChildIncludes.js b/test-browser/commands/journalChildIncludes.js new file mode 100644 index 0000000000..812ecd51af --- /dev/null +++ b/test-browser/commands/journalChildIncludes.js @@ -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 diff --git a/test-browser/tests/terminal.js b/test-browser/tests/terminal.js index 5a31c9dcad..8e39ecd9ae 100644 --- a/test-browser/tests/terminal.js +++ b/test-browser/tests/terminal.js @@ -4,14 +4,56 @@ var sauce = require('./sauce') module.exports = { 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 .waitForElementVisible('#terminalCli', 10000) .executeScript('1+1') .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() }, + tearDown: sauce }