diff --git a/package.json b/package.json index d8f1ba481a..460a6631fb 100644 --- a/package.json +++ b/package.json @@ -172,8 +172,9 @@ "nightwatch_local_specialFunctions": "nightwatch ./test-browser/tests/specialFunctions.js --config nightwatch.js --env chrome ", "nightwatch_local_solidityUnittests": "nightwatch ./test-browser/tests/solidityUnittests.js --config nightwatch.js --env chrome ", "nightwatch_local_remixd": "nightwatch ./test-browser/tests/remixd.js --config nightwatch.js --env chrome ", - "nightwatch_local_console": "nightwatch ./test-browser/tests/console.js --config nightwatch.js --env chrome ", + "nightwatch_local_terminal": "nightwatch ./test-browser/tests/terminal.js --config nightwatch.js --env chrome ", "nightwatch_local_gist": "nightwatch ./test-browser/tests/gist.js --config nightwatch.js --env chrome ", + "nightwatch_local_importFromGist": "nightwatch ./test-browser/tests/importFromGist.js --config nightwatch.js --env chrome ", "nightwatch_local_workspace": "nightwatch ./test-browser/tests/workspace.js --config nightwatch.js --env chrome ", "nightwatch_local_defaultLayout": "nightwatch ./test-browser/tests/defaultLayout.js --config nightwatch.js --env chrome ", "nightwatch_local_publishContract": "nightwatch ./test-browser/tests/publishContract.js --config nightwatch.js --env chrome ", diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 40f3635359..f9ea36f932 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -113,13 +113,14 @@ class Terminal extends Plugin { render () { var self = this if (self._view.el) return self._view.el - self._view.journal = yo`
` + self._view.journal = yo`
` self._view.input = yo` { this.focus() }} onpaste=${paste} onkeydown=${change}> ` self._view.input.setAttribute('spellcheck', 'false') self._view.input.setAttribute('contenteditable', 'true') self._view.input.setAttribute('id', 'terminalCliInput') + self._view.input.setAttribute('data-id', 'terminalCliInput') self._view.input.innerText = '\n' self._view.cli = yo` diff --git a/src/app/ui/auto-complete-popup.js b/src/app/ui/auto-complete-popup.js index e87129d6ab..2163e83143 100644 --- a/src/app/ui/auto-complete-popup.js +++ b/src/app/ui/auto-complete-popup.js @@ -41,7 +41,7 @@ class AutoCompletePopup {
${self.data._options.map((item, index) => { return yo` -
+
{ self.handleSelect(event.srcElement.innerText) }}> ${getKeyOf(item)}
diff --git a/test-browser/commands/executeScript.js b/test-browser/commands/executeScript.js index eb673dad69..cfa8d9b562 100644 --- a/test-browser/commands/executeScript.js +++ b/test-browser/commands/executeScript.js @@ -3,7 +3,8 @@ const EventEmitter = require('events') class ExecuteScript extends EventEmitter { command (script) { this.api - .click('#terminalCli') + .clearValue('span[data-id="terminalCliInput"]') + .click('div[data-id="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 diff --git a/test-browser/commands/journalChildIncludes.js b/test-browser/commands/journalChildIncludes.js new file mode 100644 index 0000000000..123365edfc --- /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 matching value. +*/ +class JournalChildIncludes extends EventEmitter { + command (val) { + let isTextFound = false + const browser = this.api + + this.api.elements('css selector', '*[data-id="terminalJournal"]', (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 ? `<*[data-id="terminalJournal"]> contains ${val}.` : `${val} not found in <*[data-id="terminalJournal"]> div:last-child>`) + this.emit('complete') + }) + return this + } +} + +module.exports = JournalChildIncludes diff --git a/test-browser/commands/journalLastChild.js b/test-browser/commands/journalLastChild.js index 5b343dc1fd..49d0fb3516 100644 --- a/test-browser/commands/journalLastChild.js +++ b/test-browser/commands/journalLastChild.js @@ -3,8 +3,8 @@ const EventEmitter = require('events') class JournalLastChild extends EventEmitter { command (val) { this.api - .waitForElementVisible('#journal > div:last-child', 10000) - .assert.containsText('#journal > div:last-child', val).perform(() => { + .waitForElementVisible('*[data-id="terminalJournal"] > div:last-child', 10000) + .assert.containsText('*[data-id="terminalJournal"] > div:last-child', val).perform(() => { this.emit('complete') }) return this diff --git a/test-browser/commands/journalLastChildIncludes.js b/test-browser/commands/journalLastChildIncludes.js index 056d5dd45a..c480694fbe 100644 --- a/test-browser/commands/journalLastChildIncludes.js +++ b/test-browser/commands/journalLastChildIncludes.js @@ -6,11 +6,11 @@ const EventEmitter = require('events') class JournalLastChildIncludes extends EventEmitter { command (val) { this.api - .waitForElementVisible('#journal > div:last-child', 10000) - .getText('#journal > div:last-child', (result) => { + .waitForElementVisible('*[data-id="terminalJournal"] > div:last-child', 10000) + .getText('*[data-id="terminalJournal"] > div:last-child', (result) => { console.log('JournalLastChildIncludes', result.value) if (result.value.indexOf(val) === -1) return this.api.assert.fail(`wait for ${val} in ${result.value}`) - else this.api.assert.ok(`<#journal > div:last-child> contains ${val}.`) + else this.api.assert.ok(`<*[data-id="terminalJournal"] > div:last-child> contains ${val}.`) this.emit('complete') }) return this diff --git a/test-browser/tests/console.js b/test-browser/tests/console.js deleted file mode 100644 index 5a31c9dcad..0000000000 --- a/test-browser/tests/console.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict' -var init = require('../helpers/init') -var sauce = require('./sauce') - -module.exports = { - before: function (browser, done) { - init(browser, done) - }, - 'SimpleExecutionConsole': function (browser) { - browser - .waitForElementVisible('#terminalCli', 10000) - .executeScript('1+1') - .journalLastChild('2') - .end() - }, - tearDown: sauce -} diff --git a/test-browser/tests/gist.js b/test-browser/tests/gist.js index 0e75718373..d552045284 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -39,5 +39,6 @@ module.exports = { }) .end() }, + tearDown: sauce } diff --git a/test-browser/tests/importFromGist.js b/test-browser/tests/importFromGist.js index 9099495830..67c46bf285 100644 --- a/test-browser/tests/importFromGist.js +++ b/test-browser/tests/importFromGist.js @@ -11,6 +11,7 @@ module.exports = { before: function (browser, done) { init(browser, done) }, + 'Load Gist Modal': function (browser) { browser .waitForElementVisible('#icon-panel', 10000) diff --git a/test-browser/tests/terminal.js b/test-browser/tests/terminal.js new file mode 100644 index 0000000000..efede033d6 --- /dev/null +++ b/test-browser/tests/terminal.js @@ -0,0 +1,59 @@ +'use strict' +var init = require('../helpers/init') +var sauce = require('./sauce') + +module.exports = { + before: function (browser, done) { + init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false) + }, + + 'Should execution a simple console command': function (browser) { + browser + .waitForElementVisible('*[data-id="terminalCli"]', 10000) + .executeScript('1+1') + .journalLastChild('2') + }, + + 'Should clear console': function (browser) { + browser + .waitForElementVisible('*[data-id="terminalCli"]') + .journalChildIncludes('Welcome to Remix') + .click('#clearConsole') + .assert.containsText('*[data-id="terminalJournal"]', '') + }, + + 'Should display auto-complete menu': function (browser) { + browser + .waitForElementVisible('*[data-id="terminalCli"]') + .click('*[data-id="terminalCli"]') + .keys('remix.') + .assert.visible('*[data-id="autoCompletePopUpAutoCompleteItem"]') + }, + + 'Should execute remix.help() command': function (browser) { + browser + .waitForElementVisible('*[data-id="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('*[data-id="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 +}