From f3069aadd2b0dcfa680d0dc062b8366a807ed394 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Sun, 9 Feb 2020 19:07:05 +0000 Subject: [PATCH 01/23] Created terminal.js --- test-browser/tests/terminal.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test-browser/tests/terminal.js diff --git a/test-browser/tests/terminal.js b/test-browser/tests/terminal.js new file mode 100644 index 0000000000..e69de29bb2 From 74b7c1af2ff8ea8d8b4ae6a5d396c114afca0145 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 10 Feb 2020 03:26:43 +0000 Subject: [PATCH 02/23] Refactored ModalFooterClick command and merged importFromGist test with gist test. --- package.json | 2 +- .../commands/modalFooterCancelClick.js | 17 ------ test-browser/commands/modalFooterClick.js | 17 ++++++ test-browser/commands/modalFooterOKClick.js | 17 ------ test-browser/tests/ballot.js | 2 +- test-browser/tests/console.js | 17 ------ test-browser/tests/gist.js | 47 +++++++++++++++- test-browser/tests/importFromGist.js | 56 ------------------- test-browser/tests/publishContract.js | 2 +- test-browser/tests/recorder.js | 2 +- test-browser/tests/terminal.js | 17 ++++++ 11 files changed, 83 insertions(+), 113 deletions(-) delete mode 100644 test-browser/commands/modalFooterCancelClick.js create mode 100644 test-browser/commands/modalFooterClick.js delete mode 100644 test-browser/commands/modalFooterOKClick.js delete mode 100644 test-browser/tests/console.js delete mode 100644 test-browser/tests/importFromGist.js diff --git a/package.json b/package.json index c85a1146c9..52aed0431b 100644 --- a/package.json +++ b/package.json @@ -172,7 +172,7 @@ "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/console.js --config nightwatch.js --env chrome ", "nightwatch_local_gist": "nightwatch ./test-browser/tests/gist.js --config nightwatch.js --env chrome ", "nightwatch_local_workspace": "nightwatch ./test-browser/tests/workspace.js --config nightwatch.js --env chrome ", "onchange": "onchange build/app.js -- npm-run-all lint", diff --git a/test-browser/commands/modalFooterCancelClick.js b/test-browser/commands/modalFooterCancelClick.js deleted file mode 100644 index 86adbc63b3..0000000000 --- a/test-browser/commands/modalFooterCancelClick.js +++ /dev/null @@ -1,17 +0,0 @@ -const EventEmitter = require('events') - -class ModalFooterOKClick extends EventEmitter { - command () { - this.api.waitForElementVisible('#modal-footer-cancel').perform((client, done) => { - this.api.execute(function () { - document.querySelector('#modal-footer-cancel').click() - }, [], (result) => { - done() - this.emit('complete') - }) - }) - return this - } -} - -module.exports = ModalFooterOKClick diff --git a/test-browser/commands/modalFooterClick.js b/test-browser/commands/modalFooterClick.js new file mode 100644 index 0000000000..132f70c905 --- /dev/null +++ b/test-browser/commands/modalFooterClick.js @@ -0,0 +1,17 @@ +const EventEmitter = require('events') + +class ModalFooterClick extends EventEmitter { + command (cssSelector) { + this.api.waitForElementVisible(cssSelector).perform((client, done) => { + this.api.execute(function () { + document.querySelector(cssSelector).click() + }, [], (result) => { + done() + this.emit('complete') + }) + }) + return this + } +} + +module.exports = ModalFooterClick diff --git a/test-browser/commands/modalFooterOKClick.js b/test-browser/commands/modalFooterOKClick.js deleted file mode 100644 index b6c0db5b7c..0000000000 --- a/test-browser/commands/modalFooterOKClick.js +++ /dev/null @@ -1,17 +0,0 @@ -const EventEmitter = require('events') - -class ModalFooterOKClick extends EventEmitter { - command () { - this.api.waitForElementVisible('#modal-footer-ok').perform((client, done) => { - this.api.execute(function () { - document.querySelector('#modal-footer-ok').click() - }, [], (result) => { - done() - this.emit('complete') - }) - }) - return this - } -} - -module.exports = ModalFooterOKClick diff --git a/test-browser/tests/ballot.js b/test-browser/tests/ballot.js index 061f52bc42..e0c3cd0160 100644 --- a/test-browser/tests/ballot.js +++ b/test-browser/tests/ballot.js @@ -60,7 +60,7 @@ module.exports = { 'Deploy and use Ballot using external web3': function (browser) { browser .click('#selectExEnvOptions #web3-mode') - .modalFooterOKClick() + .modalFooterClick('#modal-footer-ok') .clickLaunchIcon('solidity') .testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot']) .clickLaunchIcon('udapp') 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..b2217d750a 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -1,6 +1,10 @@ 'use strict' const init = require('../helpers/init') const sauce = require('./sauce') +const testData = { + validGistId: '1859c97c6e1efc91047d725d5225888e', + invalidGistId: '6368b389f9302v32902msk2402' +} // 99266d6da54cc12f37f11586e8171546c7700d67 module.exports = { @@ -19,7 +23,7 @@ module.exports = { .waitForElementVisible('#icon-panel', 10000) .clickLaunchIcon('fileExplorers') .click('#publishToGist') - .modalFooterOKClick() + .modalFooterClick('#modal-footer-ok') .getModalBody((value, done) => { const reg = /gist.github.com\/([^.]+)/ const id = value.match(reg) @@ -29,7 +33,7 @@ module.exports = { } else { let gistid = id[1] browser - .modalFooterCancelClick() + .modalFooterClick('#modal-footer-cancel') .executeScript(`remix.loadgist('${gistid}')`) .switchFile('browser/gists') .switchFile(`browser/gists/${gistid}`) @@ -37,6 +41,45 @@ module.exports = { .perform(done) } }) + }, + 'Load Gist Modal': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('h6.modal-title') + .assert.containsText('h6.modal-title', 'Load a Gist') + .waitForElementVisible('div.modal-body > div') + .assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.') + .waitForElementVisible('#prompt_text') + .click('#modal-footer-cancel') + }, + + 'Display Error Message For Invalid Gist ID': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('#prompt_text') + .setValue('#prompt_text', testData.invalidGistId) + .modalFooterClick('#modal-footer-ok') + .waitForElementVisible('div.modal-body > div') + .assert.containsText('div.modal-body > div', 'Gist load error: Not Found') + .modalFooterClick('#modal-footer-ok') + }, + + 'Import From Gist For Valid Gist ID': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('#prompt_text') + .setValue('#prompt_text', testData.validGistId) + .modalFooterClick('#modal-footer-ok') + .switchFile(`browser/gists/${testData.validGistId}`) + .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) + .waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) + .assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') .end() }, tearDown: sauce diff --git a/test-browser/tests/importFromGist.js b/test-browser/tests/importFromGist.js deleted file mode 100644 index 9099495830..0000000000 --- a/test-browser/tests/importFromGist.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict' -const init = require('../helpers/init') -const sauce = require('./sauce') - -const testData = { - validGistId: '1859c97c6e1efc91047d725d5225888e', - invalidGistId: '6368b389f9302v32902msk2402' -} - -module.exports = { - before: function (browser, done) { - init(browser, done) - }, - 'Load Gist Modal': function (browser) { - browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('h6.modal-title') - .assert.containsText('h6.modal-title', 'Load a Gist') - .waitForElementVisible('div.modal-body > div') - .assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.') - .waitForElementVisible('#prompt_text') - .click('#modal-footer-cancel') - }, - - 'Display Error Message For Invalid Gist ID': function (browser) { - browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('#prompt_text') - .setValue('#prompt_text', testData.invalidGistId) - .modalFooterOKClick() - .waitForElementVisible('div.modal-body > div') - .assert.containsText('div.modal-body > div', 'Gist load error: Not Found') - .modalFooterOKClick() - }, - - 'Import From Gist For Valid Gist ID': function (browser) { - browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('#prompt_text') - .setValue('#prompt_text', testData.validGistId) - .modalFooterOKClick() - .switchFile(`browser/gists/${testData.validGistId}`) - .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) - .waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) - .assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') - .end() - }, - - tearDown: sauce -} diff --git a/test-browser/tests/publishContract.js b/test-browser/tests/publishContract.js index 9636d990a9..1722790ee2 100644 --- a/test-browser/tests/publishContract.js +++ b/test-browser/tests/publishContract.js @@ -21,7 +21,7 @@ module.exports = { if (value.indexOf('dweb:/ipfs') === -1) browser.assert.fail('ipfs deploy failed', '', '') done() }) - .modalFooterOKClick() + .modalFooterClick('#modal-footer-ok') }, 'Publish on Swarm': function (browser) { browser diff --git a/test-browser/tests/recorder.js b/test-browser/tests/recorder.js index 66d5da1cca..260dc026e7 100644 --- a/test-browser/tests/recorder.js +++ b/test-browser/tests/recorder.js @@ -38,7 +38,7 @@ module.exports = { .click('.instance:nth-of-type(2) > div > button') .clickFunction('set - transact (not payable)', {types: 'uint256 _p', values: '34'}) .click('i.savetransaction') - .modalFooterOKClick() + .modalFooterClick('#modal-footer-ok') .getEditorValue(function (result) { var parsed = JSON.parse(result) browser.assert.equal(JSON.stringify(parsed.transactions[0].record.parameters), JSON.stringify(scenario.transactions[0].record.parameters)) diff --git a/test-browser/tests/terminal.js b/test-browser/tests/terminal.js index e69de29bb2..5a31c9dcad 100644 --- a/test-browser/tests/terminal.js +++ b/test-browser/tests/terminal.js @@ -0,0 +1,17 @@ +'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 +} From 0445d8c23199599eb9c4b921fcddf316e01b9e7f Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 10 Feb 2020 04:28:43 +0000 Subject: [PATCH 03/23] Undo ModalFooterClick Changes --- test-browser/commands/modalFooterCancelClick.js | 17 +++++++++++++++++ test-browser/commands/modalFooterClick.js | 17 ----------------- test-browser/commands/modalFooterOKClick.js | 17 +++++++++++++++++ test-browser/tests/ballot.js | 2 +- test-browser/tests/gist.js | 14 +++++++------- test-browser/tests/publishContract.js | 2 +- test-browser/tests/recorder.js | 2 +- 7 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 test-browser/commands/modalFooterCancelClick.js delete mode 100644 test-browser/commands/modalFooterClick.js create mode 100644 test-browser/commands/modalFooterOKClick.js diff --git a/test-browser/commands/modalFooterCancelClick.js b/test-browser/commands/modalFooterCancelClick.js new file mode 100644 index 0000000000..86adbc63b3 --- /dev/null +++ b/test-browser/commands/modalFooterCancelClick.js @@ -0,0 +1,17 @@ +const EventEmitter = require('events') + +class ModalFooterOKClick extends EventEmitter { + command () { + this.api.waitForElementVisible('#modal-footer-cancel').perform((client, done) => { + this.api.execute(function () { + document.querySelector('#modal-footer-cancel').click() + }, [], (result) => { + done() + this.emit('complete') + }) + }) + return this + } +} + +module.exports = ModalFooterOKClick diff --git a/test-browser/commands/modalFooterClick.js b/test-browser/commands/modalFooterClick.js deleted file mode 100644 index 132f70c905..0000000000 --- a/test-browser/commands/modalFooterClick.js +++ /dev/null @@ -1,17 +0,0 @@ -const EventEmitter = require('events') - -class ModalFooterClick extends EventEmitter { - command (cssSelector) { - this.api.waitForElementVisible(cssSelector).perform((client, done) => { - this.api.execute(function () { - document.querySelector(cssSelector).click() - }, [], (result) => { - done() - this.emit('complete') - }) - }) - return this - } -} - -module.exports = ModalFooterClick diff --git a/test-browser/commands/modalFooterOKClick.js b/test-browser/commands/modalFooterOKClick.js new file mode 100644 index 0000000000..b6c0db5b7c --- /dev/null +++ b/test-browser/commands/modalFooterOKClick.js @@ -0,0 +1,17 @@ +const EventEmitter = require('events') + +class ModalFooterOKClick extends EventEmitter { + command () { + this.api.waitForElementVisible('#modal-footer-ok').perform((client, done) => { + this.api.execute(function () { + document.querySelector('#modal-footer-ok').click() + }, [], (result) => { + done() + this.emit('complete') + }) + }) + return this + } +} + +module.exports = ModalFooterOKClick diff --git a/test-browser/tests/ballot.js b/test-browser/tests/ballot.js index e0c3cd0160..061f52bc42 100644 --- a/test-browser/tests/ballot.js +++ b/test-browser/tests/ballot.js @@ -60,7 +60,7 @@ module.exports = { 'Deploy and use Ballot using external web3': function (browser) { browser .click('#selectExEnvOptions #web3-mode') - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() .clickLaunchIcon('solidity') .testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot']) .clickLaunchIcon('udapp') diff --git a/test-browser/tests/gist.js b/test-browser/tests/gist.js index b2217d750a..24761f9803 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -23,7 +23,7 @@ module.exports = { .waitForElementVisible('#icon-panel', 10000) .clickLaunchIcon('fileExplorers') .click('#publishToGist') - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() .getModalBody((value, done) => { const reg = /gist.github.com\/([^.]+)/ const id = value.match(reg) @@ -33,7 +33,7 @@ module.exports = { } else { let gistid = id[1] browser - .modalFooterClick('#modal-footer-cancel') + .modalFooterCancelClick() .executeScript(`remix.loadgist('${gistid}')`) .switchFile('browser/gists') .switchFile(`browser/gists/${gistid}`) @@ -44,8 +44,8 @@ module.exports = { }, 'Load Gist Modal': function (browser) { browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') + .waitForElementVisible('#icon-panel') + .clickLaunchIcon('home') .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') .waitForElementVisible('h6.modal-title') .assert.containsText('h6.modal-title', 'Load a Gist') @@ -62,10 +62,10 @@ module.exports = { .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') .waitForElementVisible('#prompt_text') .setValue('#prompt_text', testData.invalidGistId) - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() .waitForElementVisible('div.modal-body > div') .assert.containsText('div.modal-body > div', 'Gist load error: Not Found') - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() }, 'Import From Gist For Valid Gist ID': function (browser) { @@ -75,7 +75,7 @@ module.exports = { .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') .waitForElementVisible('#prompt_text') .setValue('#prompt_text', testData.validGistId) - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() .switchFile(`browser/gists/${testData.validGistId}`) .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) .waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) diff --git a/test-browser/tests/publishContract.js b/test-browser/tests/publishContract.js index 1722790ee2..9636d990a9 100644 --- a/test-browser/tests/publishContract.js +++ b/test-browser/tests/publishContract.js @@ -21,7 +21,7 @@ module.exports = { if (value.indexOf('dweb:/ipfs') === -1) browser.assert.fail('ipfs deploy failed', '', '') done() }) - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() }, 'Publish on Swarm': function (browser) { browser diff --git a/test-browser/tests/recorder.js b/test-browser/tests/recorder.js index 260dc026e7..66d5da1cca 100644 --- a/test-browser/tests/recorder.js +++ b/test-browser/tests/recorder.js @@ -38,7 +38,7 @@ module.exports = { .click('.instance:nth-of-type(2) > div > button') .clickFunction('set - transact (not payable)', {types: 'uint256 _p', values: '34'}) .click('i.savetransaction') - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() .getEditorValue(function (result) { var parsed = JSON.parse(result) browser.assert.equal(JSON.stringify(parsed.transactions[0].record.parameters), JSON.stringify(scenario.transactions[0].record.parameters)) From 4942d3895da54d3ffdd1344e68237136a3225107 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 10 Feb 2020 07:48:21 +0000 Subject: [PATCH 04/23] Change console.js in package.json to terminal.js --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 52aed0431b..a82e294f05 100644 --- a/package.json +++ b/package.json @@ -172,7 +172,7 @@ "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_terminal": "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_workspace": "nightwatch ./test-browser/tests/workspace.js --config nightwatch.js --env chrome ", "onchange": "onchange build/app.js -- npm-run-all lint", From 6bc390ff7dac1bed0388d7a27227365a1821da6b Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 10 Feb 2020 15:11:55 +0000 Subject: [PATCH 05/23] Added tests to terminal.js and created journalChildIncludes command to check if any child element of journal (console) contains a value. --- test-browser/commands/executeScript.js | 1 + test-browser/commands/journalChildIncludes.js | 30 ++++++++++++ test-browser/tests/terminal.js | 46 ++++++++++++++++++- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 test-browser/commands/journalChildIncludes.js 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 } From 6fe27cc4448f91db26f142a07d88996d7ee21946 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 12 Feb 2020 11:33:52 +0000 Subject: [PATCH 06/23] Undo gist.js and importFrom.js tests merge and added unique identifiers for terminal tests --- src/app/panels/terminal.js | 2 +- src/app/ui/auto-complete-popup.js | 2 +- test-browser/commands/journalChildIncludes.js | 6 +- test-browser/commands/journalLastChild.js | 4 +- .../commands/journalLastChildIncludes.js | 6 +- test-browser/tests/gist.js | 45 +-------------- test-browser/tests/importFromGist.js | 57 +++++++++++++++++++ test-browser/tests/terminal.js | 16 +++--- 8 files changed, 76 insertions(+), 62 deletions(-) create mode 100644 test-browser/tests/importFromGist.js diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 40f3635359..7db0dfe53c 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -113,7 +113,7 @@ 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}> ` 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/journalChildIncludes.js b/test-browser/commands/journalChildIncludes.js index 812ecd51af..d0e1c9ab43 100644 --- a/test-browser/commands/journalChildIncludes.js +++ b/test-browser/commands/journalChildIncludes.js @@ -1,14 +1,14 @@ const EventEmitter = require('events') /* - Checks if any child elements of journal (console) contains a value. + 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', '#journal', (res) => { + this.api.elements('css selector', 'div[data-id="terminalJournal"]', (res) => { res.value.forEach(function (jsonWebElement) { const jsonWebElementId = jsonWebElement.ELEMENT @@ -20,7 +20,7 @@ class JournalChildIncludes extends EventEmitter { }) }) browser.perform(() => { - browser.assert.ok(isTextFound, isTextFound ? `<#journal> contains ${val}.` : `${val} not found in <#journal > div:last-child>`) + browser.assert.ok(isTextFound, isTextFound ? ` contains ${val}.` : `${val} not found in div:last-child>`) this.emit('complete') }) return this diff --git a/test-browser/commands/journalLastChild.js b/test-browser/commands/journalLastChild.js index 5b343dc1fd..0db26ec726 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('div[data-id="terminalJournal"] > div:last-child', 10000) + .assert.containsText('div[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..b8b6e19635 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('div[data-id="terminalJournal"] > div:last-child', 10000) + .getText('div[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(` div:last-child> contains ${val}.`) this.emit('complete') }) return this diff --git a/test-browser/tests/gist.js b/test-browser/tests/gist.js index 24761f9803..013acc984f 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -1,10 +1,6 @@ 'use strict' const init = require('../helpers/init') const sauce = require('./sauce') -const testData = { - validGistId: '1859c97c6e1efc91047d725d5225888e', - invalidGistId: '6368b389f9302v32902msk2402' -} // 99266d6da54cc12f37f11586e8171546c7700d67 module.exports = { @@ -42,45 +38,6 @@ module.exports = { } }) }, - 'Load Gist Modal': function (browser) { - browser - .waitForElementVisible('#icon-panel') - .clickLaunchIcon('home') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('h6.modal-title') - .assert.containsText('h6.modal-title', 'Load a Gist') - .waitForElementVisible('div.modal-body > div') - .assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.') - .waitForElementVisible('#prompt_text') - .click('#modal-footer-cancel') - }, - - 'Display Error Message For Invalid Gist ID': function (browser) { - browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('#prompt_text') - .setValue('#prompt_text', testData.invalidGistId) - .modalFooterOKClick() - .waitForElementVisible('div.modal-body > div') - .assert.containsText('div.modal-body > div', 'Gist load error: Not Found') - .modalFooterOKClick() - }, - - 'Import From Gist For Valid Gist ID': function (browser) { - browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('#prompt_text') - .setValue('#prompt_text', testData.validGistId) - .modalFooterOKClick() - .switchFile(`browser/gists/${testData.validGistId}`) - .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) - .waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) - .assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') - .end() - }, + tearDown: sauce } diff --git a/test-browser/tests/importFromGist.js b/test-browser/tests/importFromGist.js new file mode 100644 index 0000000000..473bd4ea7e --- /dev/null +++ b/test-browser/tests/importFromGist.js @@ -0,0 +1,57 @@ +'use strict' +const init = require('../helpers/init') +const sauce = require('./sauce') + +const testData = { + validGistId: '1859c97c6e1efc91047d725d5225888e', + invalidGistId: '6368b389f9302v32902msk2402' +} + +module.exports = { + before: function (browser, done) { + init(browser, done) + }, + + 'Load Gist Modal': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('h6.modal-title') + .assert.containsText('h6.modal-title', 'Load a Gist') + .waitForElementVisible('div.modal-body > div') + .assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.') + .waitForElementVisible('#prompt_text') + .click('#modal-footer-cancel') + }, + + 'Display Error Message For Invalid Gist ID': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('#prompt_text') + .setValue('#prompt_text', testData.invalidGistId) + .modalFooterOKClick() + .waitForElementVisible('div.modal-body > div') + .assert.containsText('div.modal-body > div', 'Gist load error: Not Found') + .modalFooterOKClick() + }, + + 'Import From Gist For Valid Gist ID': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('#prompt_text') + .setValue('#prompt_text', testData.validGistId) + .modalFooterOKClick() + .switchFile(`browser/gists/${testData.validGistId}`) + .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) + .waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) + .assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') + .end() + }, + + tearDown: sauce +} diff --git a/test-browser/tests/terminal.js b/test-browser/tests/terminal.js index 8e39ecd9ae..1ec097b729 100644 --- a/test-browser/tests/terminal.js +++ b/test-browser/tests/terminal.js @@ -9,30 +9,30 @@ module.exports = { 'Should execution a simple console command': function (browser) { browser - .waitForElementVisible('#terminalCli', 10000) + .waitForElementVisible('div[data-id="terminalCli"]', 10000) .executeScript('1+1') .journalLastChild('2') }, 'Should clear console': function (browser) { browser - .waitForElementVisible('#terminalCli') + .waitForElementVisible('div[data-id="terminalCli"]') .journalChildIncludes('Welcome to Remix') .click('#clearConsole') - .assert.containsText('#journal', '') + .assert.containsText('div[data-id="terminalJournal"]', '') }, 'Should display auto-complete menu': function (browser) { browser - .waitForElementVisible('#terminalCli') - .click('#terminalCli') + .waitForElementVisible('div[data-id="terminalCli"]') + .click('div[data-id="terminalCli"]') .keys('remix.') - .assert.visible('div[class^="autoCompleteItem"]') + .assert.visible('div[data-id="autoCompletePopUpAutoCompleteItem"]') }, 'Should execute remix.help() command': function (browser) { browser - .waitForElementVisible('#terminalCli') + .waitForElementVisible('div[data-id="terminalCli"]') .executeScript('remix.help()') .journalChildIncludes('remix.call(message: {name, key, payload})') .journalChildIncludes('remix.getFile(path)') @@ -48,7 +48,7 @@ module.exports = { 'Should execute remix.debugHelp() command': function (browser) { browser - .waitForElementVisible('#terminalCli') + .waitForElementVisible('div[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') From ba5ace21a6bfaf8ababa5b30e0a4efdabbc9d563 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 12 Feb 2020 11:36:44 +0000 Subject: [PATCH 07/23] Undo removal of nightwatch_local_importFromGist --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 2a91edf0e4..9ebb27902f 100644 --- a/package.json +++ b/package.json @@ -174,6 +174,7 @@ "nightwatch_local_remixd": "nightwatch ./test-browser/tests/remixd.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 ", "onchange": "onchange build/app.js -- npm-run-all lint", From b7ec0527321fa5a15e12ecc4fdb7f0377ed20c75 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 12 Feb 2020 11:46:38 +0000 Subject: [PATCH 08/23] Fixed linting error --- test-browser/tests/gist.js | 2 +- test-browser/tests/importFromGist.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test-browser/tests/gist.js b/test-browser/tests/gist.js index 013acc984f..7a46cfcf97 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -38,6 +38,6 @@ module.exports = { } }) }, - + tearDown: sauce } diff --git a/test-browser/tests/importFromGist.js b/test-browser/tests/importFromGist.js index 473bd4ea7e..67c46bf285 100644 --- a/test-browser/tests/importFromGist.js +++ b/test-browser/tests/importFromGist.js @@ -11,7 +11,7 @@ module.exports = { before: function (browser, done) { init(browser, done) }, - + 'Load Gist Modal': function (browser) { browser .waitForElementVisible('#icon-panel', 10000) From 4979e31485732b96638bae5b058dc6b68d851356 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 12 Feb 2020 13:11:37 +0000 Subject: [PATCH 09/23] Add .end() to gist file --- test-browser/tests/gist.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test-browser/tests/gist.js b/test-browser/tests/gist.js index 7a46cfcf97..d552045284 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -37,6 +37,7 @@ module.exports = { .perform(done) } }) + .end() }, tearDown: sauce From 2a5f1975807f057893fc1a77d84ff4f20aba6391 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 13 Feb 2020 07:48:10 +0000 Subject: [PATCH 10/23] Updated executeScript to use data-attributes --- src/app/panels/terminal.js | 1 + test-browser/commands/executeScript.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 7db0dfe53c..f9ea36f932 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -120,6 +120,7 @@ class Terminal extends Plugin { 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/test-browser/commands/executeScript.js b/test-browser/commands/executeScript.js index b33370ae98..cfa8d9b562 100644 --- a/test-browser/commands/executeScript.js +++ b/test-browser/commands/executeScript.js @@ -3,8 +3,8 @@ const EventEmitter = require('events') class ExecuteScript extends EventEmitter { command (script) { this.api - .clearValue('#terminalCliInput') - .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 From c035c19f282083d9045af83d15bb6fc263c47907 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Fri, 14 Feb 2020 13:43:03 +0000 Subject: [PATCH 11/23] Modified data-attribute selector --- test-browser/commands/journalChildIncludes.js | 4 ++-- test-browser/commands/journalLastChild.js | 4 ++-- .../commands/journalLastChildIncludes.js | 6 +++--- test-browser/tests/terminal.js | 16 ++++++++-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test-browser/commands/journalChildIncludes.js b/test-browser/commands/journalChildIncludes.js index d0e1c9ab43..123365edfc 100644 --- a/test-browser/commands/journalChildIncludes.js +++ b/test-browser/commands/journalChildIncludes.js @@ -8,7 +8,7 @@ class JournalChildIncludes extends EventEmitter { let isTextFound = false const browser = this.api - this.api.elements('css selector', 'div[data-id="terminalJournal"]', (res) => { + this.api.elements('css selector', '*[data-id="terminalJournal"]', (res) => { res.value.forEach(function (jsonWebElement) { const jsonWebElementId = jsonWebElement.ELEMENT @@ -20,7 +20,7 @@ class JournalChildIncludes extends EventEmitter { }) }) browser.perform(() => { - browser.assert.ok(isTextFound, isTextFound ? ` contains ${val}.` : `${val} not found in div:last-child>`) + 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 diff --git a/test-browser/commands/journalLastChild.js b/test-browser/commands/journalLastChild.js index 0db26ec726..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('div[data-id="terminalJournal"] > div:last-child', 10000) - .assert.containsText('div[data-id="terminalJournal"] > 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 b8b6e19635..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('div[data-id="terminalJournal"] > div:last-child', 10000) - .getText('div[data-id="terminalJournal"] > 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(` 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/terminal.js b/test-browser/tests/terminal.js index 1ec097b729..efede033d6 100644 --- a/test-browser/tests/terminal.js +++ b/test-browser/tests/terminal.js @@ -9,30 +9,30 @@ module.exports = { 'Should execution a simple console command': function (browser) { browser - .waitForElementVisible('div[data-id="terminalCli"]', 10000) + .waitForElementVisible('*[data-id="terminalCli"]', 10000) .executeScript('1+1') .journalLastChild('2') }, 'Should clear console': function (browser) { browser - .waitForElementVisible('div[data-id="terminalCli"]') + .waitForElementVisible('*[data-id="terminalCli"]') .journalChildIncludes('Welcome to Remix') .click('#clearConsole') - .assert.containsText('div[data-id="terminalJournal"]', '') + .assert.containsText('*[data-id="terminalJournal"]', '') }, 'Should display auto-complete menu': function (browser) { browser - .waitForElementVisible('div[data-id="terminalCli"]') - .click('div[data-id="terminalCli"]') + .waitForElementVisible('*[data-id="terminalCli"]') + .click('*[data-id="terminalCli"]') .keys('remix.') - .assert.visible('div[data-id="autoCompletePopUpAutoCompleteItem"]') + .assert.visible('*[data-id="autoCompletePopUpAutoCompleteItem"]') }, 'Should execute remix.help() command': function (browser) { browser - .waitForElementVisible('div[data-id="terminalCli"]') + .waitForElementVisible('*[data-id="terminalCli"]') .executeScript('remix.help()') .journalChildIncludes('remix.call(message: {name, key, payload})') .journalChildIncludes('remix.getFile(path)') @@ -48,7 +48,7 @@ module.exports = { 'Should execute remix.debugHelp() command': function (browser) { browser - .waitForElementVisible('div[data-id="terminalCli"]') + .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') From cc9fccb39a63fc8176ca48c0a642bceb4ca2477d Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Sun, 9 Feb 2020 19:07:05 +0000 Subject: [PATCH 12/23] Created terminal.js --- test-browser/tests/terminal.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test-browser/tests/terminal.js diff --git a/test-browser/tests/terminal.js b/test-browser/tests/terminal.js new file mode 100644 index 0000000000..e69de29bb2 From 996aaaddcde97209710b2e5023d0d62abb2b7902 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 10 Feb 2020 03:26:43 +0000 Subject: [PATCH 13/23] Refactored ModalFooterClick command and merged importFromGist test with gist test. --- package.json | 2 +- .../commands/modalFooterCancelClick.js | 17 ------ test-browser/commands/modalFooterClick.js | 17 ++++++ test-browser/commands/modalFooterOKClick.js | 17 ------ test-browser/tests/ballot.js | 2 +- test-browser/tests/console.js | 17 ------ test-browser/tests/gist.js | 47 +++++++++++++++- test-browser/tests/importFromGist.js | 56 ------------------- test-browser/tests/publishContract.js | 2 +- test-browser/tests/recorder.js | 2 +- test-browser/tests/terminal.js | 17 ++++++ 11 files changed, 83 insertions(+), 113 deletions(-) delete mode 100644 test-browser/commands/modalFooterCancelClick.js create mode 100644 test-browser/commands/modalFooterClick.js delete mode 100644 test-browser/commands/modalFooterOKClick.js delete mode 100644 test-browser/tests/console.js delete mode 100644 test-browser/tests/importFromGist.js diff --git a/package.json b/package.json index 58d8473d26..e41886cd83 100644 --- a/package.json +++ b/package.json @@ -172,7 +172,7 @@ "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/console.js --config nightwatch.js --env chrome ", "nightwatch_local_gist": "nightwatch ./test-browser/tests/gist.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 ", diff --git a/test-browser/commands/modalFooterCancelClick.js b/test-browser/commands/modalFooterCancelClick.js deleted file mode 100644 index 86adbc63b3..0000000000 --- a/test-browser/commands/modalFooterCancelClick.js +++ /dev/null @@ -1,17 +0,0 @@ -const EventEmitter = require('events') - -class ModalFooterOKClick extends EventEmitter { - command () { - this.api.waitForElementVisible('#modal-footer-cancel').perform((client, done) => { - this.api.execute(function () { - document.querySelector('#modal-footer-cancel').click() - }, [], (result) => { - done() - this.emit('complete') - }) - }) - return this - } -} - -module.exports = ModalFooterOKClick diff --git a/test-browser/commands/modalFooterClick.js b/test-browser/commands/modalFooterClick.js new file mode 100644 index 0000000000..132f70c905 --- /dev/null +++ b/test-browser/commands/modalFooterClick.js @@ -0,0 +1,17 @@ +const EventEmitter = require('events') + +class ModalFooterClick extends EventEmitter { + command (cssSelector) { + this.api.waitForElementVisible(cssSelector).perform((client, done) => { + this.api.execute(function () { + document.querySelector(cssSelector).click() + }, [], (result) => { + done() + this.emit('complete') + }) + }) + return this + } +} + +module.exports = ModalFooterClick diff --git a/test-browser/commands/modalFooterOKClick.js b/test-browser/commands/modalFooterOKClick.js deleted file mode 100644 index b6c0db5b7c..0000000000 --- a/test-browser/commands/modalFooterOKClick.js +++ /dev/null @@ -1,17 +0,0 @@ -const EventEmitter = require('events') - -class ModalFooterOKClick extends EventEmitter { - command () { - this.api.waitForElementVisible('#modal-footer-ok').perform((client, done) => { - this.api.execute(function () { - document.querySelector('#modal-footer-ok').click() - }, [], (result) => { - done() - this.emit('complete') - }) - }) - return this - } -} - -module.exports = ModalFooterOKClick diff --git a/test-browser/tests/ballot.js b/test-browser/tests/ballot.js index 061f52bc42..e0c3cd0160 100644 --- a/test-browser/tests/ballot.js +++ b/test-browser/tests/ballot.js @@ -60,7 +60,7 @@ module.exports = { 'Deploy and use Ballot using external web3': function (browser) { browser .click('#selectExEnvOptions #web3-mode') - .modalFooterOKClick() + .modalFooterClick('#modal-footer-ok') .clickLaunchIcon('solidity') .testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot']) .clickLaunchIcon('udapp') 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..b2217d750a 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -1,6 +1,10 @@ 'use strict' const init = require('../helpers/init') const sauce = require('./sauce') +const testData = { + validGistId: '1859c97c6e1efc91047d725d5225888e', + invalidGistId: '6368b389f9302v32902msk2402' +} // 99266d6da54cc12f37f11586e8171546c7700d67 module.exports = { @@ -19,7 +23,7 @@ module.exports = { .waitForElementVisible('#icon-panel', 10000) .clickLaunchIcon('fileExplorers') .click('#publishToGist') - .modalFooterOKClick() + .modalFooterClick('#modal-footer-ok') .getModalBody((value, done) => { const reg = /gist.github.com\/([^.]+)/ const id = value.match(reg) @@ -29,7 +33,7 @@ module.exports = { } else { let gistid = id[1] browser - .modalFooterCancelClick() + .modalFooterClick('#modal-footer-cancel') .executeScript(`remix.loadgist('${gistid}')`) .switchFile('browser/gists') .switchFile(`browser/gists/${gistid}`) @@ -37,6 +41,45 @@ module.exports = { .perform(done) } }) + }, + 'Load Gist Modal': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('h6.modal-title') + .assert.containsText('h6.modal-title', 'Load a Gist') + .waitForElementVisible('div.modal-body > div') + .assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.') + .waitForElementVisible('#prompt_text') + .click('#modal-footer-cancel') + }, + + 'Display Error Message For Invalid Gist ID': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('#prompt_text') + .setValue('#prompt_text', testData.invalidGistId) + .modalFooterClick('#modal-footer-ok') + .waitForElementVisible('div.modal-body > div') + .assert.containsText('div.modal-body > div', 'Gist load error: Not Found') + .modalFooterClick('#modal-footer-ok') + }, + + 'Import From Gist For Valid Gist ID': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('#prompt_text') + .setValue('#prompt_text', testData.validGistId) + .modalFooterClick('#modal-footer-ok') + .switchFile(`browser/gists/${testData.validGistId}`) + .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) + .waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) + .assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') .end() }, tearDown: sauce diff --git a/test-browser/tests/importFromGist.js b/test-browser/tests/importFromGist.js deleted file mode 100644 index 9099495830..0000000000 --- a/test-browser/tests/importFromGist.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict' -const init = require('../helpers/init') -const sauce = require('./sauce') - -const testData = { - validGistId: '1859c97c6e1efc91047d725d5225888e', - invalidGistId: '6368b389f9302v32902msk2402' -} - -module.exports = { - before: function (browser, done) { - init(browser, done) - }, - 'Load Gist Modal': function (browser) { - browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('h6.modal-title') - .assert.containsText('h6.modal-title', 'Load a Gist') - .waitForElementVisible('div.modal-body > div') - .assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.') - .waitForElementVisible('#prompt_text') - .click('#modal-footer-cancel') - }, - - 'Display Error Message For Invalid Gist ID': function (browser) { - browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('#prompt_text') - .setValue('#prompt_text', testData.invalidGistId) - .modalFooterOKClick() - .waitForElementVisible('div.modal-body > div') - .assert.containsText('div.modal-body > div', 'Gist load error: Not Found') - .modalFooterOKClick() - }, - - 'Import From Gist For Valid Gist ID': function (browser) { - browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('#prompt_text') - .setValue('#prompt_text', testData.validGistId) - .modalFooterOKClick() - .switchFile(`browser/gists/${testData.validGistId}`) - .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) - .waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) - .assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') - .end() - }, - - tearDown: sauce -} diff --git a/test-browser/tests/publishContract.js b/test-browser/tests/publishContract.js index 9636d990a9..1722790ee2 100644 --- a/test-browser/tests/publishContract.js +++ b/test-browser/tests/publishContract.js @@ -21,7 +21,7 @@ module.exports = { if (value.indexOf('dweb:/ipfs') === -1) browser.assert.fail('ipfs deploy failed', '', '') done() }) - .modalFooterOKClick() + .modalFooterClick('#modal-footer-ok') }, 'Publish on Swarm': function (browser) { browser diff --git a/test-browser/tests/recorder.js b/test-browser/tests/recorder.js index 66d5da1cca..260dc026e7 100644 --- a/test-browser/tests/recorder.js +++ b/test-browser/tests/recorder.js @@ -38,7 +38,7 @@ module.exports = { .click('.instance:nth-of-type(2) > div > button') .clickFunction('set - transact (not payable)', {types: 'uint256 _p', values: '34'}) .click('i.savetransaction') - .modalFooterOKClick() + .modalFooterClick('#modal-footer-ok') .getEditorValue(function (result) { var parsed = JSON.parse(result) browser.assert.equal(JSON.stringify(parsed.transactions[0].record.parameters), JSON.stringify(scenario.transactions[0].record.parameters)) diff --git a/test-browser/tests/terminal.js b/test-browser/tests/terminal.js index e69de29bb2..5a31c9dcad 100644 --- a/test-browser/tests/terminal.js +++ b/test-browser/tests/terminal.js @@ -0,0 +1,17 @@ +'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 +} From b220ba2d5e0fc40c13e5373691ae5dc7fcdd8c09 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 10 Feb 2020 04:28:43 +0000 Subject: [PATCH 14/23] Undo ModalFooterClick Changes --- test-browser/commands/modalFooterCancelClick.js | 17 +++++++++++++++++ test-browser/commands/modalFooterClick.js | 17 ----------------- test-browser/commands/modalFooterOKClick.js | 17 +++++++++++++++++ test-browser/tests/ballot.js | 2 +- test-browser/tests/gist.js | 14 +++++++------- test-browser/tests/publishContract.js | 2 +- test-browser/tests/recorder.js | 2 +- 7 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 test-browser/commands/modalFooterCancelClick.js delete mode 100644 test-browser/commands/modalFooterClick.js create mode 100644 test-browser/commands/modalFooterOKClick.js diff --git a/test-browser/commands/modalFooterCancelClick.js b/test-browser/commands/modalFooterCancelClick.js new file mode 100644 index 0000000000..86adbc63b3 --- /dev/null +++ b/test-browser/commands/modalFooterCancelClick.js @@ -0,0 +1,17 @@ +const EventEmitter = require('events') + +class ModalFooterOKClick extends EventEmitter { + command () { + this.api.waitForElementVisible('#modal-footer-cancel').perform((client, done) => { + this.api.execute(function () { + document.querySelector('#modal-footer-cancel').click() + }, [], (result) => { + done() + this.emit('complete') + }) + }) + return this + } +} + +module.exports = ModalFooterOKClick diff --git a/test-browser/commands/modalFooterClick.js b/test-browser/commands/modalFooterClick.js deleted file mode 100644 index 132f70c905..0000000000 --- a/test-browser/commands/modalFooterClick.js +++ /dev/null @@ -1,17 +0,0 @@ -const EventEmitter = require('events') - -class ModalFooterClick extends EventEmitter { - command (cssSelector) { - this.api.waitForElementVisible(cssSelector).perform((client, done) => { - this.api.execute(function () { - document.querySelector(cssSelector).click() - }, [], (result) => { - done() - this.emit('complete') - }) - }) - return this - } -} - -module.exports = ModalFooterClick diff --git a/test-browser/commands/modalFooterOKClick.js b/test-browser/commands/modalFooterOKClick.js new file mode 100644 index 0000000000..b6c0db5b7c --- /dev/null +++ b/test-browser/commands/modalFooterOKClick.js @@ -0,0 +1,17 @@ +const EventEmitter = require('events') + +class ModalFooterOKClick extends EventEmitter { + command () { + this.api.waitForElementVisible('#modal-footer-ok').perform((client, done) => { + this.api.execute(function () { + document.querySelector('#modal-footer-ok').click() + }, [], (result) => { + done() + this.emit('complete') + }) + }) + return this + } +} + +module.exports = ModalFooterOKClick diff --git a/test-browser/tests/ballot.js b/test-browser/tests/ballot.js index e0c3cd0160..061f52bc42 100644 --- a/test-browser/tests/ballot.js +++ b/test-browser/tests/ballot.js @@ -60,7 +60,7 @@ module.exports = { 'Deploy and use Ballot using external web3': function (browser) { browser .click('#selectExEnvOptions #web3-mode') - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() .clickLaunchIcon('solidity') .testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot']) .clickLaunchIcon('udapp') diff --git a/test-browser/tests/gist.js b/test-browser/tests/gist.js index b2217d750a..24761f9803 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -23,7 +23,7 @@ module.exports = { .waitForElementVisible('#icon-panel', 10000) .clickLaunchIcon('fileExplorers') .click('#publishToGist') - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() .getModalBody((value, done) => { const reg = /gist.github.com\/([^.]+)/ const id = value.match(reg) @@ -33,7 +33,7 @@ module.exports = { } else { let gistid = id[1] browser - .modalFooterClick('#modal-footer-cancel') + .modalFooterCancelClick() .executeScript(`remix.loadgist('${gistid}')`) .switchFile('browser/gists') .switchFile(`browser/gists/${gistid}`) @@ -44,8 +44,8 @@ module.exports = { }, 'Load Gist Modal': function (browser) { browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') + .waitForElementVisible('#icon-panel') + .clickLaunchIcon('home') .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') .waitForElementVisible('h6.modal-title') .assert.containsText('h6.modal-title', 'Load a Gist') @@ -62,10 +62,10 @@ module.exports = { .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') .waitForElementVisible('#prompt_text') .setValue('#prompt_text', testData.invalidGistId) - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() .waitForElementVisible('div.modal-body > div') .assert.containsText('div.modal-body > div', 'Gist load error: Not Found') - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() }, 'Import From Gist For Valid Gist ID': function (browser) { @@ -75,7 +75,7 @@ module.exports = { .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') .waitForElementVisible('#prompt_text') .setValue('#prompt_text', testData.validGistId) - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() .switchFile(`browser/gists/${testData.validGistId}`) .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) .waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) diff --git a/test-browser/tests/publishContract.js b/test-browser/tests/publishContract.js index 1722790ee2..9636d990a9 100644 --- a/test-browser/tests/publishContract.js +++ b/test-browser/tests/publishContract.js @@ -21,7 +21,7 @@ module.exports = { if (value.indexOf('dweb:/ipfs') === -1) browser.assert.fail('ipfs deploy failed', '', '') done() }) - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() }, 'Publish on Swarm': function (browser) { browser diff --git a/test-browser/tests/recorder.js b/test-browser/tests/recorder.js index 260dc026e7..66d5da1cca 100644 --- a/test-browser/tests/recorder.js +++ b/test-browser/tests/recorder.js @@ -38,7 +38,7 @@ module.exports = { .click('.instance:nth-of-type(2) > div > button') .clickFunction('set - transact (not payable)', {types: 'uint256 _p', values: '34'}) .click('i.savetransaction') - .modalFooterClick('#modal-footer-ok') + .modalFooterOKClick() .getEditorValue(function (result) { var parsed = JSON.parse(result) browser.assert.equal(JSON.stringify(parsed.transactions[0].record.parameters), JSON.stringify(scenario.transactions[0].record.parameters)) From 2de4d79b4a3397252d9779fe252d059f1fac90a0 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 10 Feb 2020 07:48:21 +0000 Subject: [PATCH 15/23] Change console.js in package.json to terminal.js --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e41886cd83..2a91edf0e4 100644 --- a/package.json +++ b/package.json @@ -172,7 +172,7 @@ "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_terminal": "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_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 ", From b20914e3939ac71aa3b69a939dc4a4d97ee7f783 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 10 Feb 2020 15:11:55 +0000 Subject: [PATCH 16/23] Added tests to terminal.js and created journalChildIncludes command to check if any child element of journal (console) contains a value. --- test-browser/commands/executeScript.js | 1 + test-browser/commands/journalChildIncludes.js | 30 ++++++++++++ test-browser/tests/terminal.js | 46 ++++++++++++++++++- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 test-browser/commands/journalChildIncludes.js 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 } From cdaeda458987597ddcd681752e65d31b41368931 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 12 Feb 2020 11:33:52 +0000 Subject: [PATCH 17/23] Undo gist.js and importFrom.js tests merge and added unique identifiers for terminal tests --- src/app/panels/terminal.js | 2 +- src/app/ui/auto-complete-popup.js | 2 +- test-browser/commands/journalChildIncludes.js | 6 +- test-browser/commands/journalLastChild.js | 4 +- .../commands/journalLastChildIncludes.js | 6 +- test-browser/tests/gist.js | 45 +-------------- test-browser/tests/importFromGist.js | 57 +++++++++++++++++++ test-browser/tests/terminal.js | 16 +++--- 8 files changed, 76 insertions(+), 62 deletions(-) create mode 100644 test-browser/tests/importFromGist.js diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 40f3635359..7db0dfe53c 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -113,7 +113,7 @@ 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}> ` 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/journalChildIncludes.js b/test-browser/commands/journalChildIncludes.js index 812ecd51af..d0e1c9ab43 100644 --- a/test-browser/commands/journalChildIncludes.js +++ b/test-browser/commands/journalChildIncludes.js @@ -1,14 +1,14 @@ const EventEmitter = require('events') /* - Checks if any child elements of journal (console) contains a value. + 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', '#journal', (res) => { + this.api.elements('css selector', 'div[data-id="terminalJournal"]', (res) => { res.value.forEach(function (jsonWebElement) { const jsonWebElementId = jsonWebElement.ELEMENT @@ -20,7 +20,7 @@ class JournalChildIncludes extends EventEmitter { }) }) browser.perform(() => { - browser.assert.ok(isTextFound, isTextFound ? `<#journal> contains ${val}.` : `${val} not found in <#journal > div:last-child>`) + browser.assert.ok(isTextFound, isTextFound ? ` contains ${val}.` : `${val} not found in div:last-child>`) this.emit('complete') }) return this diff --git a/test-browser/commands/journalLastChild.js b/test-browser/commands/journalLastChild.js index 5b343dc1fd..0db26ec726 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('div[data-id="terminalJournal"] > div:last-child', 10000) + .assert.containsText('div[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..b8b6e19635 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('div[data-id="terminalJournal"] > div:last-child', 10000) + .getText('div[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(` div:last-child> contains ${val}.`) this.emit('complete') }) return this diff --git a/test-browser/tests/gist.js b/test-browser/tests/gist.js index 24761f9803..013acc984f 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -1,10 +1,6 @@ 'use strict' const init = require('../helpers/init') const sauce = require('./sauce') -const testData = { - validGistId: '1859c97c6e1efc91047d725d5225888e', - invalidGistId: '6368b389f9302v32902msk2402' -} // 99266d6da54cc12f37f11586e8171546c7700d67 module.exports = { @@ -42,45 +38,6 @@ module.exports = { } }) }, - 'Load Gist Modal': function (browser) { - browser - .waitForElementVisible('#icon-panel') - .clickLaunchIcon('home') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('h6.modal-title') - .assert.containsText('h6.modal-title', 'Load a Gist') - .waitForElementVisible('div.modal-body > div') - .assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.') - .waitForElementVisible('#prompt_text') - .click('#modal-footer-cancel') - }, - - 'Display Error Message For Invalid Gist ID': function (browser) { - browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('#prompt_text') - .setValue('#prompt_text', testData.invalidGistId) - .modalFooterOKClick() - .waitForElementVisible('div.modal-body > div') - .assert.containsText('div.modal-body > div', 'Gist load error: Not Found') - .modalFooterOKClick() - }, - - 'Import From Gist For Valid Gist ID': function (browser) { - browser - .waitForElementVisible('#icon-panel', 10000) - .clickLaunchIcon('fileExplorers') - .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') - .waitForElementVisible('#prompt_text') - .setValue('#prompt_text', testData.validGistId) - .modalFooterOKClick() - .switchFile(`browser/gists/${testData.validGistId}`) - .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) - .waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) - .assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') - .end() - }, + tearDown: sauce } diff --git a/test-browser/tests/importFromGist.js b/test-browser/tests/importFromGist.js new file mode 100644 index 0000000000..473bd4ea7e --- /dev/null +++ b/test-browser/tests/importFromGist.js @@ -0,0 +1,57 @@ +'use strict' +const init = require('../helpers/init') +const sauce = require('./sauce') + +const testData = { + validGistId: '1859c97c6e1efc91047d725d5225888e', + invalidGistId: '6368b389f9302v32902msk2402' +} + +module.exports = { + before: function (browser, done) { + init(browser, done) + }, + + 'Load Gist Modal': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('h6.modal-title') + .assert.containsText('h6.modal-title', 'Load a Gist') + .waitForElementVisible('div.modal-body > div') + .assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.') + .waitForElementVisible('#prompt_text') + .click('#modal-footer-cancel') + }, + + 'Display Error Message For Invalid Gist ID': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('#prompt_text') + .setValue('#prompt_text', testData.invalidGistId) + .modalFooterOKClick() + .waitForElementVisible('div.modal-body > div') + .assert.containsText('div.modal-body > div', 'Gist load error: Not Found') + .modalFooterOKClick() + }, + + 'Import From Gist For Valid Gist ID': function (browser) { + browser + .waitForElementVisible('#icon-panel', 10000) + .clickLaunchIcon('fileExplorers') + .scrollAndClick('div.file > div.btn-group > button:nth-child(1)') + .waitForElementVisible('#prompt_text') + .setValue('#prompt_text', testData.validGistId) + .modalFooterOKClick() + .switchFile(`browser/gists/${testData.validGistId}`) + .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) + .waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) + .assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') + .end() + }, + + tearDown: sauce +} diff --git a/test-browser/tests/terminal.js b/test-browser/tests/terminal.js index 8e39ecd9ae..1ec097b729 100644 --- a/test-browser/tests/terminal.js +++ b/test-browser/tests/terminal.js @@ -9,30 +9,30 @@ module.exports = { 'Should execution a simple console command': function (browser) { browser - .waitForElementVisible('#terminalCli', 10000) + .waitForElementVisible('div[data-id="terminalCli"]', 10000) .executeScript('1+1') .journalLastChild('2') }, 'Should clear console': function (browser) { browser - .waitForElementVisible('#terminalCli') + .waitForElementVisible('div[data-id="terminalCli"]') .journalChildIncludes('Welcome to Remix') .click('#clearConsole') - .assert.containsText('#journal', '') + .assert.containsText('div[data-id="terminalJournal"]', '') }, 'Should display auto-complete menu': function (browser) { browser - .waitForElementVisible('#terminalCli') - .click('#terminalCli') + .waitForElementVisible('div[data-id="terminalCli"]') + .click('div[data-id="terminalCli"]') .keys('remix.') - .assert.visible('div[class^="autoCompleteItem"]') + .assert.visible('div[data-id="autoCompletePopUpAutoCompleteItem"]') }, 'Should execute remix.help() command': function (browser) { browser - .waitForElementVisible('#terminalCli') + .waitForElementVisible('div[data-id="terminalCli"]') .executeScript('remix.help()') .journalChildIncludes('remix.call(message: {name, key, payload})') .journalChildIncludes('remix.getFile(path)') @@ -48,7 +48,7 @@ module.exports = { 'Should execute remix.debugHelp() command': function (browser) { browser - .waitForElementVisible('#terminalCli') + .waitForElementVisible('div[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') From 3df69b14d4ec6e78f38d16649c16d09271057016 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 12 Feb 2020 11:36:44 +0000 Subject: [PATCH 18/23] Undo removal of nightwatch_local_importFromGist --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 2a91edf0e4..9ebb27902f 100644 --- a/package.json +++ b/package.json @@ -174,6 +174,7 @@ "nightwatch_local_remixd": "nightwatch ./test-browser/tests/remixd.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 ", "onchange": "onchange build/app.js -- npm-run-all lint", From c58aaed6ae5a16ee273487ae8ec82b8c6f61590a Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 12 Feb 2020 11:46:38 +0000 Subject: [PATCH 19/23] Fixed linting error --- test-browser/tests/gist.js | 2 +- test-browser/tests/importFromGist.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test-browser/tests/gist.js b/test-browser/tests/gist.js index 013acc984f..7a46cfcf97 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -38,6 +38,6 @@ module.exports = { } }) }, - + tearDown: sauce } diff --git a/test-browser/tests/importFromGist.js b/test-browser/tests/importFromGist.js index 473bd4ea7e..67c46bf285 100644 --- a/test-browser/tests/importFromGist.js +++ b/test-browser/tests/importFromGist.js @@ -11,7 +11,7 @@ module.exports = { before: function (browser, done) { init(browser, done) }, - + 'Load Gist Modal': function (browser) { browser .waitForElementVisible('#icon-panel', 10000) From f81d845010897af69629a70931ce1df500ef2962 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 12 Feb 2020 13:11:37 +0000 Subject: [PATCH 20/23] Add .end() to gist file --- test-browser/tests/gist.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test-browser/tests/gist.js b/test-browser/tests/gist.js index 7a46cfcf97..d552045284 100644 --- a/test-browser/tests/gist.js +++ b/test-browser/tests/gist.js @@ -37,6 +37,7 @@ module.exports = { .perform(done) } }) + .end() }, tearDown: sauce From cd8cf797a4a75e83f7c9b531a4a3cc25612e1c34 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 13 Feb 2020 07:48:10 +0000 Subject: [PATCH 21/23] Updated executeScript to use data-attributes --- src/app/panels/terminal.js | 1 + test-browser/commands/executeScript.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 7db0dfe53c..f9ea36f932 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -120,6 +120,7 @@ class Terminal extends Plugin { 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/test-browser/commands/executeScript.js b/test-browser/commands/executeScript.js index b33370ae98..cfa8d9b562 100644 --- a/test-browser/commands/executeScript.js +++ b/test-browser/commands/executeScript.js @@ -3,8 +3,8 @@ const EventEmitter = require('events') class ExecuteScript extends EventEmitter { command (script) { this.api - .clearValue('#terminalCliInput') - .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 From 835ffb4509f77b3b06ea1c1e80f601051253b112 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Fri, 14 Feb 2020 13:43:03 +0000 Subject: [PATCH 22/23] Modified data-attribute selector --- test-browser/commands/journalChildIncludes.js | 4 ++-- test-browser/commands/journalLastChild.js | 4 ++-- .../commands/journalLastChildIncludes.js | 6 +++--- test-browser/tests/terminal.js | 16 ++++++++-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test-browser/commands/journalChildIncludes.js b/test-browser/commands/journalChildIncludes.js index d0e1c9ab43..123365edfc 100644 --- a/test-browser/commands/journalChildIncludes.js +++ b/test-browser/commands/journalChildIncludes.js @@ -8,7 +8,7 @@ class JournalChildIncludes extends EventEmitter { let isTextFound = false const browser = this.api - this.api.elements('css selector', 'div[data-id="terminalJournal"]', (res) => { + this.api.elements('css selector', '*[data-id="terminalJournal"]', (res) => { res.value.forEach(function (jsonWebElement) { const jsonWebElementId = jsonWebElement.ELEMENT @@ -20,7 +20,7 @@ class JournalChildIncludes extends EventEmitter { }) }) browser.perform(() => { - browser.assert.ok(isTextFound, isTextFound ? ` contains ${val}.` : `${val} not found in div:last-child>`) + 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 diff --git a/test-browser/commands/journalLastChild.js b/test-browser/commands/journalLastChild.js index 0db26ec726..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('div[data-id="terminalJournal"] > div:last-child', 10000) - .assert.containsText('div[data-id="terminalJournal"] > 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 b8b6e19635..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('div[data-id="terminalJournal"] > div:last-child', 10000) - .getText('div[data-id="terminalJournal"] > 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(` 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/terminal.js b/test-browser/tests/terminal.js index 1ec097b729..efede033d6 100644 --- a/test-browser/tests/terminal.js +++ b/test-browser/tests/terminal.js @@ -9,30 +9,30 @@ module.exports = { 'Should execution a simple console command': function (browser) { browser - .waitForElementVisible('div[data-id="terminalCli"]', 10000) + .waitForElementVisible('*[data-id="terminalCli"]', 10000) .executeScript('1+1') .journalLastChild('2') }, 'Should clear console': function (browser) { browser - .waitForElementVisible('div[data-id="terminalCli"]') + .waitForElementVisible('*[data-id="terminalCli"]') .journalChildIncludes('Welcome to Remix') .click('#clearConsole') - .assert.containsText('div[data-id="terminalJournal"]', '') + .assert.containsText('*[data-id="terminalJournal"]', '') }, 'Should display auto-complete menu': function (browser) { browser - .waitForElementVisible('div[data-id="terminalCli"]') - .click('div[data-id="terminalCli"]') + .waitForElementVisible('*[data-id="terminalCli"]') + .click('*[data-id="terminalCli"]') .keys('remix.') - .assert.visible('div[data-id="autoCompletePopUpAutoCompleteItem"]') + .assert.visible('*[data-id="autoCompletePopUpAutoCompleteItem"]') }, 'Should execute remix.help() command': function (browser) { browser - .waitForElementVisible('div[data-id="terminalCli"]') + .waitForElementVisible('*[data-id="terminalCli"]') .executeScript('remix.help()') .journalChildIncludes('remix.call(message: {name, key, payload})') .journalChildIncludes('remix.getFile(path)') @@ -48,7 +48,7 @@ module.exports = { 'Should execute remix.debugHelp() command': function (browser) { browser - .waitForElementVisible('div[data-id="terminalCli"]') + .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') From c06b4f0ca4bd7cf70aaf843dcfd3736a50ed0c4f Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 20 Feb 2020 11:04:05 +0000 Subject: [PATCH 23/23] Disable Publish on Swarm Test --- package.json | 1 + test-browser/tests/publishContract.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 58d8473d26..d8f1ba481a 100644 --- a/package.json +++ b/package.json @@ -176,6 +176,7 @@ "nightwatch_local_gist": "nightwatch ./test-browser/tests/gist.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 ", "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/test-browser/tests/publishContract.js b/test-browser/tests/publishContract.js index 9636d990a9..6abbc18681 100644 --- a/test-browser/tests/publishContract.js +++ b/test-browser/tests/publishContract.js @@ -23,7 +23,7 @@ module.exports = { }) .modalFooterOKClick() }, - 'Publish on Swarm': function (browser) { + 'Publish on Swarm': '' + function (browser) { browser .click('#publishOnSwarm') .getModalBody((value, done) => {