diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index 578976cc1b..ec65abce49 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -144,6 +144,29 @@ module.exports = { .click('*[data-id="testTabGenerateTestFolder"]') }, + 'Changing current path when workspace changed': function (browser: NightwatchBrowser) { + browser + .waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') + .clickLaunchIcon('settings') + .clickLaunchIcon('solidityUnitTesting') + .waitForElementPresent('*[data-id="uiPathInput"]', 3000) + .clearValue('*[data-id="uiPathInput"]') + .setValue('*[data-id="uiPathInput"]', 'tests1') + .click('*[data-id="testTabGenerateTestFolder"]') + .clickLaunchIcon('filePanel') + // creating a new workspace + .click('*[data-id="workspaceCreate"]') + .waitForElementVisible('*[data-id="modalDialogCustomPromptTextCreate"]') + // eslint-disable-next-line dot-notation + .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_new' }) + .click('*[data-id="workspacesModalDialogModalDialogModalFooter-react"] .modal-ok') + .click('*[data-id="workspacesSelect"] option[value="workspace_new"]') + // end of creating + .clickLaunchIcon('solidityUnitTesting') + .pause(2000) + .verify.attributeEquals('*[data-id="uiPathInput"]', 'value', 'tests') + }, + 'Solidity Unittests': function (browser: NightwatchBrowser) { runTests(browser) } @@ -157,6 +180,8 @@ function runTests (browser: NightwatchBrowser) { .openFile('contracts/3_Ballot.sol') .clickLaunchIcon('solidityUnitTesting') .pause(500) + .setValue('*[data-id="uiPathInput"]', 'tests') + .pause(2000) .scrollAndClick('#runTestsTabRunAction') .waitForElementVisible('*[data-id="testTabSolidityUnitTestsOutputheader"]', 120000) .waitForElementPresent('#solidityUnittestsOutput div[class^="testPass"]', 60000) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index a7052c2a1a..f1ff124df5 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -60,6 +60,12 @@ module.exports = class TestTab extends ViewPlugin { this.data.selectedTests.push(file) }) + this.on('filePanel', 'setWorkspace', () => { + this.testTabLogic.setCurrentPath(this.defaultPath) + this.inputPath.value = this.defaultPath + this.updateForNewCurrent() + }) + this.fileManager.events.on('noFileSelected', () => { }) @@ -67,8 +73,9 @@ module.exports = class TestTab extends ViewPlugin { } updateForNewCurrent (file) { - this.updateGenerateFileAction(file) + this.updateGenerateFileAction() if (!this.areTestsRunning) this.updateRunAction(file) + this.updateTestFileList() this.testTabLogic.getTests((error, tests) => { if (error) return tooltip(error) this.data.allTests = tests @@ -415,11 +422,16 @@ module.exports = class TestTab extends ViewPlugin { }) } - updateCurrentPath (e) { - const newValue = e.target.value === '' ? this.defaultPath : e.target.value - this.testTabLogic.setCurrentPath(newValue) + handleCreateFolder () { + this.inputPath.value = this.trimTestDirInput(this.inputPath.value) + if (this.inputPath.value === '') this.inputPath.value = this.defaultPath + this.testTabLogic.generateTestFolder(this.inputPath.value) + this.createTestFolder.disabled = true + this.updateGenerateFileAction().disabled = false + this.testTabLogic.setCurrentPath(this.inputPath.value) this.updateRunAction() this.updateForNewCurrent() + this.uiPathList.appendChild(yo``) } runTests () { @@ -456,7 +468,7 @@ module.exports = class TestTab extends ViewPlugin { runBtn.setAttribute('disabled', 'disabled') } - updateGenerateFileAction (currentFile) { + updateGenerateFileAction () { const el = yo` ` + this.createTestFolder = yo` + + ` const availablePaths = yo`
-
- ${this.inputPath} - ${createTestFolder} - ${this.uiPathList} -
+
+ ${this.inputPath} + ${this.createTestFolder} + ${this.uiPathList} +
` - this.updateDirList() + this.updateDirList('/') this.testsExecutionStopped.hidden = true this.testsExecutionStoppedError.hidden = true this.resultStatistics = this.createResultLabel() diff --git a/apps/remix-ide/src/app/tabs/testTab/testTab.js b/apps/remix-ide/src/app/tabs/testTab/testTab.js index 9b18732950..1cfdff91be 100644 --- a/apps/remix-ide/src/app/tabs/testTab/testTab.js +++ b/apps/remix-ide/src/app/tabs/testTab/testTab.js @@ -21,6 +21,13 @@ class TestTabLogic { fileProvider.exists(path, (e, res) => { if (!res) fileProvider.createDir(path) }) } + pathExists (path) { + // Checking to ignore the value which contains only whitespaces + if (!path || !(/\S/.test(path))) return + const fileProvider = this.fileManager.fileProviderOf(path.split('/')[0]) + return fileProvider.exists(path, (e, res) => { return res }) + } + generateTestFile () { let fileName = this.fileManager.currentFile() const hasCurrent = !!fileName && this.fileManager.currentFile().split('.').pop().toLowerCase() === 'sol'