From a13feb3e4512250735df727102d174840ee63d28 Mon Sep 17 00:00:00 2001 From: Rob Stupay Date: Mon, 1 Jul 2019 10:21:58 +0200 Subject: [PATCH] update tests to include 1 for checking if the console works --- README.md | 2 ++ package.json | 1 + src/app/panels/terminal.js | 5 +++-- test-browser/commands/executeScript.js | 15 +++++++++++++++ test-browser/commands/journalLastChild.js | 13 +++++++++++++ test-browser/tests/console.js | 18 ++++++++++++++++++ 6 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 test-browser/commands/executeScript.js create mode 100644 test-browser/commands/journalLastChild.js create mode 100644 test-browser/tests/console.js diff --git a/README.md b/README.md index d6f3789766..926c6f9f62 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,8 @@ To run the Selenium tests via Nightwatch: - npm run nightwatch_local_staticAnalysis - npm run nightwatch_local_signingMessage + + - npm run nightwatch_local_console - npm run nightwatch_local_remixd # remixd needs to be run diff --git a/package.json b/package.json index 531e63b566..3db80e9a5a 100644 --- a/package.json +++ b/package.json @@ -163,6 +163,7 @@ "nightwatch_local_staticAnalysis": "nightwatch ./test-browser/tests/staticanalysis.js --config nightwatch.js --env chrome ", "nightwatch_local_signingMessage": "nightwatch ./test-browser/tests/signingMessage.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 ", "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", diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index f566fd3cf9..2ec6ab1c3f 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -109,16 +109,17 @@ class Terminal extends BaseApi { 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.innerText = '\n' self._view.cli = yo` -
+
${'>'} ${self._view.input}
diff --git a/test-browser/commands/executeScript.js b/test-browser/commands/executeScript.js new file mode 100644 index 0000000000..734a419e7a --- /dev/null +++ b/test-browser/commands/executeScript.js @@ -0,0 +1,15 @@ +const EventEmitter = require('events') + +class ExecuteScript extends EventEmitter { + command (script) { + this.api + .click('#terminalCli') + .keys(script) + .perform(() => { + this.emit('complete') + }) + return this + } +} + +module.exports = ExecuteScript diff --git a/test-browser/commands/journalLastChild.js b/test-browser/commands/journalLastChild.js new file mode 100644 index 0000000000..cc6a5fd896 --- /dev/null +++ b/test-browser/commands/journalLastChild.js @@ -0,0 +1,13 @@ +const EventEmitter = require('events') + +class JournalLastChild extends EventEmitter { + command (val) { + + this.api.assert.containsText('#journal div:last-child span.text-info', val).perform(() => { + this.emit('complete') + }) + return this + } +} + +module.exports = JournalLastChild diff --git a/test-browser/tests/console.js b/test-browser/tests/console.js new file mode 100644 index 0000000000..4dd424de0a --- /dev/null +++ b/test-browser/tests/console.js @@ -0,0 +1,18 @@ +'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(['\uE01B','\uE025','\uE01B','\uE006','\uE006','\uE006']) + .waitForElementVisible('#journal div:last-child span.text-info', 10000) + .journalLastChild('2') + .end() + }, + tearDown: sauce +}