Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal e2e tests #2593

Merged
merged 25 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
09c397e
Created terminal.js
ioedeveloper Feb 9, 2020
dc06097
Refactored ModalFooterClick command and merged importFromGist test wi…
ioedeveloper Feb 10, 2020
69a9543
Undo ModalFooterClick Changes
ioedeveloper Feb 10, 2020
802f300
Change console.js in package.json to terminal.js
ioedeveloper Feb 10, 2020
afbb359
Added tests to terminal.js and created journalChildIncludes command t…
ioedeveloper Feb 10, 2020
a96f9fb
Merge branch 'master' of https://github.com/ethereum/remix-ide into t…
ioedeveloper Feb 12, 2020
f04f1eb
Undo gist.js and importFrom.js tests merge and added unique identifie…
ioedeveloper Feb 12, 2020
bb5d454
Undo removal of nightwatch_local_importFromGist
ioedeveloper Feb 12, 2020
44cc887
Fixed linting error
ioedeveloper Feb 12, 2020
61faa0f
Add .end() to gist file
ioedeveloper Feb 12, 2020
a2853a8
Updated executeScript to use data-attributes
ioedeveloper Feb 13, 2020
8f4e33a
Modified data-attribute selector
ioedeveloper Feb 14, 2020
7689163
Created terminal.js
ioedeveloper Feb 9, 2020
7f27800
Refactored ModalFooterClick command and merged importFromGist test wi…
ioedeveloper Feb 10, 2020
d8ef0be
Undo ModalFooterClick Changes
ioedeveloper Feb 10, 2020
fc2f947
Change console.js in package.json to terminal.js
ioedeveloper Feb 10, 2020
4bb44b8
Added tests to terminal.js and created journalChildIncludes command t…
ioedeveloper Feb 10, 2020
b647c43
Undo gist.js and importFrom.js tests merge and added unique identifie…
ioedeveloper Feb 12, 2020
1c85855
Undo removal of nightwatch_local_importFromGist
ioedeveloper Feb 12, 2020
ead9f69
Fixed linting error
ioedeveloper Feb 12, 2020
2f01de2
Add .end() to gist file
ioedeveloper Feb 12, 2020
05cd906
Updated executeScript to use data-attributes
ioedeveloper Feb 13, 2020
244fa96
Modified data-attribute selector
ioedeveloper Feb 14, 2020
c804aa5
Merge branch 'terminal-e2e-tests' of https://github.com/ethereum/remi…
ioedeveloper Feb 20, 2020
83c517e
Merge branch 'master' of https://github.com/ethereum/remix-ide into t…
ioedeveloper Feb 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",
Expand Down
3 changes: 2 additions & 1 deletion src/app/panels/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ class Terminal extends Plugin {
render () {
var self = this
if (self._view.el) return self._view.el
self._view.journal = yo`<div id="journal" class=${css.journal}></div>`
self._view.journal = yo`<div id="journal" class=${css.journal} data-id="terminalJournal"></div>`
self._view.input = yo`
<span class=${css.input} onload=${() => { this.focus() }} onpaste=${paste} onkeydown=${change}></span>
`
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`
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/auto-complete-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AutoCompletePopup {
<div>
${self.data._options.map((item, index) => {
return yo`
<div class="${css.autoCompleteItem} ${css.listHandlerHide} item ${self._selectedElement === index ? 'border border-primary' : ''}">
<div data-id="autoCompletePopUpAutoCompleteItem" class="${css.autoCompleteItem} ${css.listHandlerHide} item ${self._selectedElement === index ? 'border border-primary' : ''}">
<div value=${index} onclick=${(event) => { self.handleSelect(event.srcElement.innerText) }}>
${getKeyOf(item)}
</div>
Expand Down
3 changes: 2 additions & 1 deletion test-browser/commands/executeScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions test-browser/commands/journalChildIncludes.js
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions test-browser/commands/journalLastChild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test-browser/commands/journalLastChildIncludes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 0 additions & 17 deletions test-browser/tests/console.js

This file was deleted.

1 change: 1 addition & 0 deletions test-browser/tests/gist.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ module.exports = {
})
.end()
},

tearDown: sauce
}
1 change: 1 addition & 0 deletions test-browser/tests/importFromGist.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
before: function (browser, done) {
init(browser, done)
},

'Load Gist Modal': function (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
Expand Down
59 changes: 59 additions & 0 deletions test-browser/tests/terminal.js
Original file line number Diff line number Diff line change
@@ -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
}