From c74697de399d389f6d5a51cd3684d6cdc94bc341 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 16 Mar 2020 15:09:55 +0000 Subject: [PATCH 1/5] File Explorer Tests --- package.json | 1 + src/app/ui/TreeView.js | 8 +-- test-browser/commands/switchBrowserWindow.js | 25 +++++++ test-browser/tests/fileExplorer.js | 69 ++++++++++++++++++++ 4 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 test-browser/commands/switchBrowserWindow.js create mode 100644 test-browser/tests/fileExplorer.js diff --git a/package.json b/package.json index c5af7283e0..791de96a81 100644 --- a/package.json +++ b/package.json @@ -181,6 +181,7 @@ "nightwatch_local_pluginManager": "nightwatch ./test-browser/tests/pluginManager.js --config nightwatch.js --env chrome ", "nightwatch_local_publishContract": "nightwatch ./test-browser/tests/publishContract.js --config nightwatch.js --env chrome ", "nightwatch_local_generalSettings": "nightwatch ./test-browser/tests/generalSettings.js --config nightwatch.js --env chrome ", + "nightwatch_local_fileExplorer": "nightwatch ./test-browser/tests/fileExplorer.js --config nightwatch.js --env chrome ", "onchange": "onchange build/app.js -- npm-run-all lint", "prepublish": "mkdirp build; npm-run-all -ls downloadsolc_root build", "remixd": "remixd -s ./contracts --remix-ide http://127.0.0.1:8080", diff --git a/src/app/ui/TreeView.js b/src/app/ui/TreeView.js index 391f8be10d..c1db3c1f92 100644 --- a/src/app/ui/TreeView.js +++ b/src/app/ui/TreeView.js @@ -74,21 +74,21 @@ class TreeView { var children = Object.keys(json).map((innerkey) => { return this.renderObject(json[innerkey], json, innerkey, expand, innerkey) }) - return yo`` + return yo`` } formatData (key, data, children, expand, keyPath) { var self = this - var li = yo`
  • ` + var li = yo`
  • ` var caret = yo`
    ` var label = yo` -
    +
    ${caret} ${self.formatSelf(key, data, li)}
    ` li.appendChild(label) if (data.children) { - var list = yo`` + var list = yo`` list.style.display = 'none' caret.className = list.style.display === 'none' ? `fas fa-caret-right caret ${css.caret_tv}` : `fas fa-caret-down caret ${css.caret_tv}` caret.setAttribute('data-id', `treeViewToggle${keyPath}`) diff --git a/test-browser/commands/switchBrowserWindow.js b/test-browser/commands/switchBrowserWindow.js new file mode 100644 index 0000000000..53de905023 --- /dev/null +++ b/test-browser/commands/switchBrowserWindow.js @@ -0,0 +1,25 @@ +const EventEmitter = require('events') + +class SwitchBrowserWindow extends EventEmitter { + command (url, windowName) { + this.api.perform((done) => { + switchWindow(this.api, url, windowName, () => { + done() + this.emit('complete') + }) + }) + return this + } +} + +function switchWindow (browser, url, windowName, callback) { + browser.execute(function (url, windowName) { + window.open(url, windowName, 'width=2560, height=1440') + }, [url, windowName], function () { + browser.switchWindow(windowName) + .assert.urlContains(url) + callback() + }) +} + +module.exports = SwitchBrowserWindow diff --git a/test-browser/tests/fileExplorer.js b/test-browser/tests/fileExplorer.js new file mode 100644 index 0000000000..f87c35d550 --- /dev/null +++ b/test-browser/tests/fileExplorer.js @@ -0,0 +1,69 @@ +'use strict' +const init = require('../helpers/init') +const sauce = require('./sauce') + +module.exports = { + + before: function (browser, done) { + init(browser, done, 'http://127.0.0.1:8080', false) + }, + + 'Should create a new file `5_New_contract.sol` in file explorer': function (browser) { + browser.waitForElementVisible('div[data-id="remixIdeSidePanel"]') + .assert.containsText('h6[data-id="sidePanelSwapitTitle"]', 'FILE EXPLORERS') + .click('*[data-id="fileExplorerNewFilecreateNewFile"]') + .waitForElementVisible('*[data-id="modalDialogContainer"]') + .setValue('*[data-id="modalDialogCustomPromptText"]', '5_New_contract.sol') + .modalFooterOKClick() + .pause(2000) + .waitForElementVisible('*[data-id="treeViewLibrowser/5_New_contract.sol"]') + }, + + 'Should remove file `1_Storage.sol` from file explorer': function (browser) { + browser + .moveToElement('*[data-id="treeViewLibrowser/1_Storage.sol"]', 5, 5) + .mouseButtonClick('right') + .click('#menuitemdelete') + .waitForElementVisible('*[data-id="modalDialogContainer"]') + .modalFooterOKClick() + .waitForElementNotPresent('*[data-id="treeViewLibrowser/1_Storage.sol"') + }, + + 'Should create a new folder': function (browser) { + browser + .waitForElementVisible('*[data-id="treeViewLibrowser/5_New_contract.sol"]') + .moveToElement('*[data-id="treeViewLibrowser/5_New_contract.sol"]', 5, 5) + .mouseButtonClick('right') + .click('*[id="menuitemcreate folder"]') + .waitForElementVisible('*[data-id="modalDialogContainer"]') + .setValue('*[data-id="modalDialogCustomPromptText"]', 'Browser_Tests') + .modalFooterOKClick() + .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]') + }, + + 'Should create files in folder Browser_Tests': function (browser) { + browser + .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]') + .moveToElement('*[data-id="treeViewLibrowser/Browser_Tests"]', 5, 5) + .mouseButtonClick('right') + .click('*[id="menuitemcreate file"]') + .waitForElementVisible('*[data-id="modalDialogContainer"]') + .setValue('*[data-id="modalDialogCustomPromptText"]', '1_Test.sol') + .modalFooterOKClick() + .switchFile('browser/Browser_Tests') + .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests/1_Test.sol"]') + }, + + 'Should delete Browser_Tests folder': function (browser) { + browser + .moveToElement('*[data-id="treeViewLibrowser/Browser_Tests"]', 5, 5) + .mouseButtonClick('right') + .click('*[id="menuitemdelete"]') + .waitForElementVisible('*[data-id="modalDialogContainer"]') + .modalFooterOKClick() + .waitForElementNotPresent('*[data-id="treeViewLibrowser/Browser_Tests"]') + .end() + }, + + tearDown: sauce +} From fa111cc027cd053a2e03c0d6e2a5f27d7f5d12a1 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 16 Mar 2020 16:13:34 +0000 Subject: [PATCH 2/5] Debug rename folder --- src/app/files/fileManager.js | 2 +- test-browser/tests/fileExplorer.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index fc04454455..24c609ba35 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -282,7 +282,7 @@ class FileManager extends Plugin { this.editor.open(file, content) } // TODO: Only keep `this.emit` (issue#2210) - this.emit('currentFileChanged', file) + // this.emit('currentFileChanged', file) this.events.emit('currentFileChanged', file) } }) diff --git a/test-browser/tests/fileExplorer.js b/test-browser/tests/fileExplorer.js index f87c35d550..41c919f366 100644 --- a/test-browser/tests/fileExplorer.js +++ b/test-browser/tests/fileExplorer.js @@ -23,7 +23,7 @@ module.exports = { browser .moveToElement('*[data-id="treeViewLibrowser/1_Storage.sol"]', 5, 5) .mouseButtonClick('right') - .click('#menuitemdelete') + .click('*[id="menuitemdelete"]') .waitForElementVisible('*[data-id="modalDialogContainer"]') .modalFooterOKClick() .waitForElementNotPresent('*[data-id="treeViewLibrowser/1_Storage.sol"') @@ -54,8 +54,24 @@ module.exports = { .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests/1_Test.sol"]') }, + 'Should rename Browser_Tests folder to Browser_E2E_Tests': function (browser) { + browser + .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]') + .moveToElement('*[data-id="treeViewLibrowser/Browser_Tests"]', 5, 5) + .mouseButtonClick('right') + .click('*[id="menuitemrename"]') + .keys('Browser_E2E_Tests') + .keys(browser.Keys.ENTER) + .pause(100000) + .waitForElementVisible('*[data-id="modalDialogContainer"]') + .click('*[data-id="modalDialogContainer"]') + .modalFooterOKClick() + .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_E2E_Tests"]') + }, + 'Should delete Browser_Tests folder': function (browser) { browser + .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]') .moveToElement('*[data-id="treeViewLibrowser/Browser_Tests"]', 5, 5) .mouseButtonClick('right') .click('*[id="menuitemdelete"]') From 71be5788829b96c226bf8d11a58a7d59f2542452 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 17 Mar 2020 10:09:19 +0000 Subject: [PATCH 3/5] Test folder and file actions in file explorer --- test-browser/tests/fileExplorer.js | 46 +++++++++++++----------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/test-browser/tests/fileExplorer.js b/test-browser/tests/fileExplorer.js index 41c919f366..6b79f173b3 100644 --- a/test-browser/tests/fileExplorer.js +++ b/test-browser/tests/fileExplorer.js @@ -19,20 +19,31 @@ module.exports = { .waitForElementVisible('*[data-id="treeViewLibrowser/5_New_contract.sol"]') }, - 'Should remove file `1_Storage.sol` from file explorer': function (browser) { + 'Should rename `5_New_contract.sol` to 5_Renamed_Contract.sol': function (browser) { browser - .moveToElement('*[data-id="treeViewLibrowser/1_Storage.sol"]', 5, 5) + .waitForElementVisible('*[data-id="treeViewLibrowser/5_New_contract.sol"]') + .moveToElement('*[data-id="treeViewLibrowser/5_New_contract.sol"]', 5, 5) + .mouseButtonClick('right') + .click('*[id="menuitemrename"]') + .keys('5_Renamed_Contract.sol') + .keys(browser.Keys.ENTER) + .waitForElementVisible('*[data-id="treeViewLibrowser/5_Renamed_Contract.sol"]') + }, + + 'Should delete file `5_Renamed_Contract.sol` from file explorer': function (browser) { + browser + .moveToElement('*[data-id="treeViewLibrowser/5_Renamed_Contract.sol"]', 5, 5) .mouseButtonClick('right') .click('*[id="menuitemdelete"]') .waitForElementVisible('*[data-id="modalDialogContainer"]') .modalFooterOKClick() - .waitForElementNotPresent('*[data-id="treeViewLibrowser/1_Storage.sol"') + .waitForElementNotPresent('*[data-id="treeViewLibrowser/5_Renamed_Contract.sol"') }, 'Should create a new folder': function (browser) { browser - .waitForElementVisible('*[data-id="treeViewLibrowser/5_New_contract.sol"]') - .moveToElement('*[data-id="treeViewLibrowser/5_New_contract.sol"]', 5, 5) + .waitForElementVisible('*[data-id="treeViewLibrowser/1_Storage.sol"]') + .moveToElement('*[data-id="treeViewLibrowser/1_Storage.sol"]', 5, 5) .mouseButtonClick('right') .click('*[id="menuitemcreate folder"]') .waitForElementVisible('*[data-id="modalDialogContainer"]') @@ -41,19 +52,6 @@ module.exports = { .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]') }, - 'Should create files in folder Browser_Tests': function (browser) { - browser - .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]') - .moveToElement('*[data-id="treeViewLibrowser/Browser_Tests"]', 5, 5) - .mouseButtonClick('right') - .click('*[id="menuitemcreate file"]') - .waitForElementVisible('*[data-id="modalDialogContainer"]') - .setValue('*[data-id="modalDialogCustomPromptText"]', '1_Test.sol') - .modalFooterOKClick() - .switchFile('browser/Browser_Tests') - .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests/1_Test.sol"]') - }, - 'Should rename Browser_Tests folder to Browser_E2E_Tests': function (browser) { browser .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]') @@ -62,22 +60,18 @@ module.exports = { .click('*[id="menuitemrename"]') .keys('Browser_E2E_Tests') .keys(browser.Keys.ENTER) - .pause(100000) - .waitForElementVisible('*[data-id="modalDialogContainer"]') - .click('*[data-id="modalDialogContainer"]') - .modalFooterOKClick() .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_E2E_Tests"]') }, - 'Should delete Browser_Tests folder': function (browser) { + 'Should delete Browser_E2E_Tests folder': function (browser) { browser - .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]') - .moveToElement('*[data-id="treeViewLibrowser/Browser_Tests"]', 5, 5) + .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_E2E_Tests"]') + .moveToElement('*[data-id="treeViewLibrowser/Browser_E2E_Tests"]', 5, 5) .mouseButtonClick('right') .click('*[id="menuitemdelete"]') .waitForElementVisible('*[data-id="modalDialogContainer"]') .modalFooterOKClick() - .waitForElementNotPresent('*[data-id="treeViewLibrowser/Browser_Tests"]') + .waitForElementNotPresent('*[data-id="treeViewLibrowser/Browser_E2E_Tests"]') .end() }, From 17a6463bdb31e248a5d1ff085b24c4229f7b653f Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 17 Mar 2020 10:49:47 +0000 Subject: [PATCH 4/5] Publish all explorer files to gist --- test-browser/tests/fileExplorer.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test-browser/tests/fileExplorer.js b/test-browser/tests/fileExplorer.js index 6b79f173b3..932693956a 100644 --- a/test-browser/tests/fileExplorer.js +++ b/test-browser/tests/fileExplorer.js @@ -5,11 +5,12 @@ const sauce = require('./sauce') module.exports = { before: function (browser, done) { - init(browser, done, 'http://127.0.0.1:8080', false) + init(browser, done) }, 'Should create a new file `5_New_contract.sol` in file explorer': function (browser) { browser.waitForElementVisible('div[data-id="remixIdeSidePanel"]') + .clickLaunchIcon('fileExplorers') .assert.containsText('h6[data-id="sidePanelSwapitTitle"]', 'FILE EXPLORERS') .click('*[data-id="fileExplorerNewFilecreateNewFile"]') .waitForElementVisible('*[data-id="modalDialogContainer"]') @@ -72,6 +73,20 @@ module.exports = { .waitForElementVisible('*[data-id="modalDialogContainer"]') .modalFooterOKClick() .waitForElementNotPresent('*[data-id="treeViewLibrowser/Browser_E2E_Tests"]') + }, + + 'Should publish all explorer files to github gist': function (browser) { + browser + .waitForElementVisible('*[data-id="fileExplorerNewFilepublishToGist"]') + .click('*[data-id="fileExplorerNewFilepublishToGist"]') + .waitForElementVisible('*[data-id="modalDialogContainer"]') + .modalFooterOKClick() + .pause(10000) + .waitForElementVisible('*[data-id="modalDialogContainer"]') + .modalFooterOKClick() + .pause(2000) + .switchBrowserTab(1) + .assert.urlContains('https://gist.github.com') .end() }, From 74466b0f76fbae77f714bb3994f127e5864da7e4 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 17 Mar 2020 10:58:40 +0000 Subject: [PATCH 5/5] Undo comment in fileManager --- src/app/files/fileManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 24c609ba35..fc04454455 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -282,7 +282,7 @@ class FileManager extends Plugin { this.editor.open(file, content) } // TODO: Only keep `this.emit` (issue#2210) - // this.emit('currentFileChanged', file) + this.emit('currentFileChanged', file) this.events.emit('currentFileChanged', file) } })