From 572adc2af50f3947a0beecaea30cd873ccc4e1f4 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Fri, 15 May 2020 11:18:34 +0000 Subject: [PATCH] changed nightwatch switchFile command to openFile --- src/app/files/fileManager.js | 18 +++++++++--------- .../commands/{switchFile.js => openFile.js} | 8 ++++---- test-browser/tests/defaultLayout.test.js | 2 +- test-browser/tests/editor.test.js | 12 ++++++------ test-browser/tests/generalSettings.test.js | 6 +++--- test-browser/tests/gist.test.js | 10 +++++----- test-browser/tests/libraryDeployment.test.js | 8 ++++---- test-browser/tests/pluginManager.test.js | 2 +- test-browser/tests/publishContract.test.js | 6 +++--- test-browser/tests/runAndDeploy.js | 4 ++-- test-browser/tests/signingMessage.test.js | 2 +- test-browser/tests/solidityImport.test.js | 2 +- test-browser/tests/solidityUnittests.test.js | 10 +++++----- test-browser/tests/terminal.test.js | 4 ++-- 14 files changed, 47 insertions(+), 47 deletions(-) rename test-browser/commands/{switchFile.js => openFile.js} (76%) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index e6013c958c..6256aa3bbb 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -143,7 +143,7 @@ class FileManager extends Plugin { async open (path) { await this._handleExists(path, `Cannot open file ${path}`) await this._handleIsFile(path, `Cannot open file ${path}`) - return this.switchFile(path) + return this.openFile(path) } /** @@ -274,7 +274,7 @@ class FileManager extends Plugin { delete this.openedFiles[oldName] this.openedFiles[newName] = newName } - this.switchFile(newName) + this.openFile(newName) } else { var newFocus for (var k in this.openedFiles) { @@ -288,7 +288,7 @@ class FileManager extends Plugin { } } if (newFocus) { - this.switchFile(newFocus) + this.openFile(newFocus) } } // TODO: Only keep `this.emit` (issue#2210) @@ -390,7 +390,7 @@ class FileManager extends Plugin { copyName = path + '.' + this.currentRequest.from } this._setFileInternal(copyName, content) - this.switchFile(copyName) + this.openFile(copyName) }) } } @@ -413,7 +413,7 @@ class FileManager extends Plugin { // TODO: Only keep `this.emit` (issue#2210) this.emit('fileRemoved', path) this.events.emit('fileRemoved', path) - this.switchFile() + this.openFile() } unselectCurrentFile () { @@ -424,8 +424,8 @@ class FileManager extends Plugin { this.events.emit('noFileSelected') } - switchFile (file) { - const _switchFile = (file) => { + openFile (file) { + const _openFile = (file) => { this.saveCurrentFile() this._deps.config.set('currentFile', file) this.openedFiles[file] = file @@ -444,14 +444,14 @@ class FileManager extends Plugin { } }) } - if (file) return _switchFile(file) + if (file) return _openFile(file) else { var browserProvider = this._deps.filesProviders['browser'] browserProvider.resolveDirectory('browser', (error, filesProvider) => { if (error) console.error(error) var fileList = Object.keys(filesProvider) if (fileList.length) { - _switchFile(browserProvider.type + '/' + fileList[0]) + _openFile(browserProvider.type + '/' + fileList[0]) } else { // TODO: Only keep `this.emit` (issue#2210) this.emit('noFileSelected') diff --git a/test-browser/commands/switchFile.js b/test-browser/commands/openFile.js similarity index 76% rename from test-browser/commands/switchFile.js rename to test-browser/commands/openFile.js index 004697b8fe..3812afa0ed 100644 --- a/test-browser/commands/switchFile.js +++ b/test-browser/commands/openFile.js @@ -1,9 +1,9 @@ const EventEmitter = require('events') -class SwitchFile extends EventEmitter { +class OpenFile extends EventEmitter { command (name) { this.api.perform((done) => { - switchFile(this.api, name, () => { + openFile(this.api, name, () => { done() this.emit('complete') }) @@ -13,7 +13,7 @@ class SwitchFile extends EventEmitter { } // click on fileExplorer can toggle it. We go through settings to be sure FE is open -function switchFile (browser, name, done) { +function openFile (browser, name, done) { browser.clickLaunchIcon('settings').clickLaunchIcon('fileExplorers') .waitForElementVisible('li[key="' + name + '"]') .click('li[key="' + name + '"]') @@ -23,4 +23,4 @@ function switchFile (browser, name, done) { }) } -module.exports = SwitchFile +module.exports = OpenFile diff --git a/test-browser/tests/defaultLayout.test.js b/test-browser/tests/defaultLayout.test.js index 16f9af6aa7..f4857c7f86 100644 --- a/test-browser/tests/defaultLayout.test.js +++ b/test-browser/tests/defaultLayout.test.js @@ -66,7 +66,7 @@ module.exports = { 'Switch Tabs using tabs icon': function (browser) { browser .waitForElementVisible('div[data-id="filePanelFileExplorerTree"]') - .switchFile('browser/3_Ballot.sol') + .openFile('browser/3_Ballot.sol') .assert.containsText('div[title="browser/3_Ballot.sol"]', '3_Ballot.sol') .click('span[class^=dropdownCaret]') .click('#homeItem') diff --git a/test-browser/tests/editor.test.js b/test-browser/tests/editor.test.js index 92dcfb24ba..de926370d7 100644 --- a/test-browser/tests/editor.test.js +++ b/test-browser/tests/editor.test.js @@ -10,7 +10,7 @@ module.exports = { 'Should zoom in editor': function (browser) { browser.waitForElementVisible('div[data-id="mainPanelPluginsContainer"]') - .switchFile('browser/1_Storage.sol') + .openFile('browser/1_Storage.sol') .waitForElementVisible('*[data-id="editorInput"]') .checkElementStyle('*[data-id="editorInput"]', 'font-size', '12px') .click('*[data-id="tabProxyZoomIn"]') @@ -74,7 +74,7 @@ module.exports = { 'Should highlight source code': function (browser) { browser.addFile('sourcehighlight.js', sourcehighlightScript) - .switchFile('browser/sourcehighlight.js') + .openFile('browser/sourcehighlight.js') .executeScript('remix.exeCurrent()') .editorScroll('down', 60) .waitForElementPresent('.highlightLine32') @@ -87,9 +87,9 @@ module.exports = { 'Should remove 1 highlight from source code': function (browser) { browser.addFile('removeSourcehighlightScript.js', removeSourcehighlightScript) - .switchFile('browser/removeSourcehighlightScript.js') + .openFile('browser/removeSourcehighlightScript.js') .executeScript('remix.exeCurrent()') - .switchFile('browser/3_Ballot.sol') + .openFile('browser/3_Ballot.sol') .editorScroll('down', 60) .waitForElementNotPresent('.highlightLine32') .checkElementStyle('.highlightLine40', 'background-color', 'rgb(8, 108, 181)') @@ -98,9 +98,9 @@ module.exports = { 'Should remove all highlights from source code': function (browser) { browser.addFile('removeAllSourcehighlightScript.js', removeAllSourcehighlightScript) - .switchFile('browser/removeAllSourcehighlightScript.js') + .openFile('browser/removeAllSourcehighlightScript.js') .executeScript('remix.exeCurrent()') - .switchFile('browser/3_Ballot.sol') + .openFile('browser/3_Ballot.sol') .editorScroll('down', 60) .waitForElementNotPresent('.highlightLine32') .waitForElementNotPresent('.highlightLine40') diff --git a/test-browser/tests/generalSettings.test.js b/test-browser/tests/generalSettings.test.js index f25e144894..2e43472769 100644 --- a/test-browser/tests/generalSettings.test.js +++ b/test-browser/tests/generalSettings.test.js @@ -31,14 +31,14 @@ module.exports = { .waitForElementVisible('*[data-id="settingsTabGenerateContractMetadata"]', 5000) .click('*[data-id="settingsTabGenerateContractMetadata"]') .click('*[data-id="verticalIconsFileExplorerIcons"]') - .switchFile('browser/3_Ballot.sol') + .openFile('browser/3_Ballot.sol') .click('*[data-id="verticalIconsKindsolidity"]') .pause(2000) .click('*[data-id="compilerContainerCompileBtn"]') .pause(3000) .click('*[data-id="verticalIconsKindfileExplorers"]') - .switchFile('browser/artifacts') - .switchFile('browser/artifacts/Ballot.json') + .openFile('browser/artifacts') + .openFile('browser/artifacts/Ballot.json') }, 'Should add new github access token': function (browser) { diff --git a/test-browser/tests/gist.test.js b/test-browser/tests/gist.test.js index a91ed02537..5c01f6f5a9 100644 --- a/test-browser/tests/gist.test.js +++ b/test-browser/tests/gist.test.js @@ -44,9 +44,9 @@ module.exports = { browser .modalFooterCancelClick() .executeScript(`remix.loadgist('${gistid}')`) - .perform((done) => { if (runtimeBrowser === 'chrome') { browser.switchFile('browser/gists') } done() }) - .switchFile(`browser/gists/${gistid}`) - .switchFile(`browser/gists/${gistid}/1_Storage.sol`) + .perform((done) => { if (runtimeBrowser === 'chrome') { browser.openFile('browser/gists') } done() }) + .openFile(`browser/gists/${gistid}`) + .openFile(`browser/gists/${gistid}/1_Storage.sol`) .perform(done) } }) @@ -86,8 +86,8 @@ module.exports = { .waitForElementVisible('*[data-id="modalDialogCustomPromptText"]') .setValue('*[data-id="modalDialogCustomPromptText"]', testData.validGistId) .modalFooterOKClick() - .switchFile(`browser/gists/${testData.validGistId}`) - .switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) + .openFile(`browser/gists/${testData.validGistId}`) + .openFile(`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() diff --git a/test-browser/tests/libraryDeployment.test.js b/test-browser/tests/libraryDeployment.test.js index eccea3d6bf..463dc47d65 100644 --- a/test-browser/tests/libraryDeployment.test.js +++ b/test-browser/tests/libraryDeployment.test.js @@ -59,7 +59,7 @@ module.exports = { function checkDeployShouldFail (browser, callback) { let config - browser.switchFile('browser/artifacts').switchFile('browser/artifacts/test.json') + browser.openFile('browser/artifacts').openFile('browser/artifacts/test.json') .getEditorValue((content) => { config = JSON.parse(content) config.deploy['VM:-'].autoDeployLib = false @@ -67,7 +67,7 @@ function checkDeployShouldFail (browser, callback) { .perform(() => { browser.setEditorValue(JSON.stringify(config)) }) - .switchFile('browser/Untitled5.sol') + .openFile('browser/Untitled5.sol') .selectContract('test') // deploy lib .createContract('') .assert.containsText('div[class^="terminal"]', '
is not a valid address') @@ -77,7 +77,7 @@ function checkDeployShouldFail (browser, callback) { function checkDeployShouldSucceed (browser, address, callback) { let addressRef let config - browser.switchFile('browser/artifacts').switchFile('browser/artifacts/test.json') + browser.openFile('browser/artifacts').openFile('browser/artifacts/test.json') .getEditorValue((content) => { config = JSON.parse(content) config.deploy['VM:-'].autoDeployLib = false @@ -86,7 +86,7 @@ function checkDeployShouldSucceed (browser, address, callback) { .perform(() => { browser.setEditorValue(JSON.stringify(config)) }) - .switchFile('browser/Untitled5.sol') + .openFile('browser/Untitled5.sol') .selectContract('test') // deploy lib .createContract('') .getAddressAtPosition(1, (address) => { diff --git a/test-browser/tests/pluginManager.test.js b/test-browser/tests/pluginManager.test.js index f2ccd4bfcd..e374d65c69 100644 --- a/test-browser/tests/pluginManager.test.js +++ b/test-browser/tests/pluginManager.test.js @@ -66,7 +66,7 @@ module.exports = { .assert.containsText('*[data-id="pluginManagerSettingsPermissionForm"]', 'No Permission requested yet') .modalFooterOKClick() .click('*[data-id="verticalIconsFileExplorerIcons"]') - .switchFile('browser/3_Ballot.sol') + .openFile('browser/3_Ballot.sol') .click('*[plugin="ZoKrates"]') .pause(5000) .frame(0) diff --git a/test-browser/tests/publishContract.test.js b/test-browser/tests/publishContract.test.js index f5fa6242cf..eab1d26fdb 100644 --- a/test-browser/tests/publishContract.test.js +++ b/test-browser/tests/publishContract.test.js @@ -13,7 +13,7 @@ module.exports = { browser .waitForElementVisible('#icon-panel', 10000) .clickLaunchIcon('fileExplorers') - .switchFile('browser/3_Ballot.sol') + .openFile('browser/3_Ballot.sol') .verifyContracts(['Ballot']) .click('#publishOnIpfs') .getModalBody((value, done) => { @@ -37,7 +37,7 @@ module.exports = { browser .waitForElementVisible('#icon-panel') .clickLaunchIcon('fileExplorers') - .switchFile('browser/1_Storage.sol') + .openFile('browser/1_Storage.sol') .clickLaunchIcon('udapp') .waitForElementVisible('*[data-id="contractDropdownIpfsCheckbox"]') .click('*[data-id="contractDropdownIpfsCheckbox"]') @@ -49,7 +49,7 @@ module.exports = { 'Should remember choice after page refresh': function (browser) { browser .refresh() - .switchFile('browser/1_Storage.sol') + .openFile('browser/1_Storage.sol') .clickLaunchIcon('udapp') .waitForElementVisible('*[data-id="contractDropdownIpfsCheckbox"]') .verify.elementPresent('*[data-id="contractDropdownIpfsCheckbox"]:checked') diff --git a/test-browser/tests/runAndDeploy.js b/test-browser/tests/runAndDeploy.js index b1b8240609..5e0c05ed2a 100644 --- a/test-browser/tests/runAndDeploy.js +++ b/test-browser/tests/runAndDeploy.js @@ -90,7 +90,7 @@ module.exports = { 'Should deploy contract on Goerli Test Network using MetaMask': function (browser) { browser.waitForElementPresent('*[data-id="runTabSelectAccount"] option') .clickLaunchIcon('fileExplorers') - .switchFile('browser/Greet.sol') + .openFile('browser/Greet.sol') .clickLaunchIcon('udapp') .waitForElementPresent('*[data-id="Deploy - transact (not payable)"]') .click('*[data-id="Deploy - transact (not payable)"]') @@ -141,7 +141,7 @@ module.exports = { 'Should deploy contract on Ethereum Main Network using MetaMask': function (browser) { browser.waitForElementPresent('*[data-id="runTabSelectAccount"] option') .clickLaunchIcon('fileExplorers') - .switchFile('browser/Greet.sol') + .openFile('browser/Greet.sol') .clickLaunchIcon('udapp') .waitForElementPresent('*[data-id="Deploy - transact (not payable)"]') .click('*[data-id="Deploy - transact (not payable)"]') diff --git a/test-browser/tests/signingMessage.test.js b/test-browser/tests/signingMessage.test.js index 1fe8d1dc5c..a5a7c78433 100644 --- a/test-browser/tests/signingMessage.test.js +++ b/test-browser/tests/signingMessage.test.js @@ -23,7 +23,7 @@ module.exports = { browser.assert.ok(typeof signature.value === 'string', 'type of signature.value must be String') }) .addFile('signMassage.sol', sources[0]['browser/signMassage.sol']) - .switchFile('browser/signMassage.sol') + .openFile('browser/signMassage.sol') .pause(5000) .selectContract('ECVerify') .createContract('') diff --git a/test-browser/tests/solidityImport.test.js b/test-browser/tests/solidityImport.test.js index ad871dde8e..3a1290c88e 100644 --- a/test-browser/tests/solidityImport.test.js +++ b/test-browser/tests/solidityImport.test.js @@ -15,7 +15,7 @@ module.exports = { 'Test Success Import': function (browser) { browser.addFile('Untitled1.sol', sources[1]['browser/Untitled1.sol']) .addFile('Untitled2.sol', sources[1]['browser/Untitled2.sol']) - .switchFile('browser/Untitled1.sol') + .openFile('browser/Untitled1.sol') .verifyContracts(['test6', 'test4', 'test5']) }, diff --git a/test-browser/tests/solidityUnittests.test.js b/test-browser/tests/solidityUnittests.test.js index 9f2235ed76..3a4882ad51 100644 --- a/test-browser/tests/solidityUnittests.test.js +++ b/test-browser/tests/solidityUnittests.test.js @@ -27,7 +27,7 @@ module.exports = { 'Should generate test file': function (browser) { browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]') .clickLaunchIcon('fileExplorers') - .switchFile('browser/simple_storage.sol') + .openFile('browser/simple_storage.sol') .click('*[data-id="verticalIconsKindsolidityUnitTesting"]') .waitForElementPresent('*[data-id="testTabGenerateTestFile"]') .click('*[data-id="testTabGenerateTestFile"]') @@ -100,7 +100,7 @@ module.exports = { browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]') .addFile('compilationError_test.sol', sources[0]['browser/compilationError_test.sol']) .clickLaunchIcon('fileExplorers') - .switchFile('browser/compilationError_test.sol') + .openFile('browser/compilationError_test.sol') .clickLaunchIcon('solidityUnitTesting') .click('*[data-id="testTabCheckAllTests"]') .clickElementAtPosition('.singleTestLabel', 3) @@ -115,7 +115,7 @@ module.exports = { browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]') .addFile('deployError_test.sol', sources[0]['browser/deployError_test.sol']) .clickLaunchIcon('fileExplorers') - .switchFile('browser/deployError_test.sol') + .openFile('browser/deployError_test.sol') .clickLaunchIcon('solidityUnitTesting') .click('*[data-id="testTabCheckAllTests"]') .clickElementAtPosition('.singleTestLabel', 4) @@ -129,7 +129,7 @@ module.exports = { browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]') .addFile('methodFailure_test.sol', sources[0]['browser/methodFailure_test.sol']) .clickLaunchIcon('fileExplorers') - .switchFile('browser/methodFailure_test.sol') + .openFile('browser/methodFailure_test.sol') .clickLaunchIcon('solidityUnitTesting') .click('*[data-id="testTabCheckAllTests"]') .clickElementAtPosition('.singleTestLabel', 5) @@ -150,7 +150,7 @@ function runTests (browser) { browser .waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]') .clickLaunchIcon('fileExplorers') - .switchFile('browser/3_Ballot.sol') + .openFile('browser/3_Ballot.sol') .clickLaunchIcon('solidityUnitTesting') .pause(500) .scrollAndClick('#runTestsTabRunAction') diff --git a/test-browser/tests/terminal.test.js b/test-browser/tests/terminal.test.js index 3515e74092..135fd59a1b 100644 --- a/test-browser/tests/terminal.test.js +++ b/test-browser/tests/terminal.test.js @@ -57,7 +57,7 @@ module.exports = { 'Async/Await Script': function (browser) { browser .addFile('asyncAwait.js', { content: asyncAwait }) - .switchFile('browser/asyncAwait.js') + .openFile('browser/asyncAwait.js') .executeScript(`remix.execute('browser/asyncAwait.js')`) .journalLastChild('Waiting Promise') .pause(5500) @@ -67,7 +67,7 @@ module.exports = { 'Call Remix File Manager from a script': function (browser) { browser .addFile('asyncAwaitWithFileManagerAccess.js', { content: asyncAwaitWithFileManagerAccess }) - .switchFile('browser/asyncAwaitWithFileManagerAccess.js') + .openFile('browser/asyncAwaitWithFileManagerAccess.js') .pause(5000) .executeScript(`remix.execute('browser/asyncAwaitWithFileManagerAccess.js')`) .pause(6000)