From cdaeda458987597ddcd681752e65d31b41368931 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 12 Feb 2020 11:33:52 +0000 Subject: [PATCH] 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')