From 053d55c42633ee7e975b5438a8359010b38a7efe Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Thu, 18 Mar 2021 17:57:16 +0530 Subject: [PATCH 01/26] dynamic create button --- apps/remix-ide/src/app/tabs/test-tab.js | 39 +++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index a7052c2a1a..96a03f21aa 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -549,11 +549,28 @@ module.exports = class TestTab extends ViewPlugin { return yo`Progress: ${ready} finished (of ${this.runningTestsNumber})` } - updateDirList () { - for (var o of this.uiPathList.querySelectorAll('option')) o.remove() - this.testTabLogic.dirList('/').then((options) => { - options.forEach((path) => this.uiPathList.appendChild(yo``)) - }) + updateDirList (keycode = 'none') { + if (keycode === 'none') { + this.testTabLogic.dirList('/').then((options) => { + options.forEach((path) => this.uiPathList.appendChild(yo``)) + }) + } else { + const presentOptions = this.uiPathList.querySelectorAll('option') + if(keycode === 191) { + for (var o of presentOptions) o.remove() + this.testTabLogic.dirList('/').then((options) => { + options.forEach((path) => this.uiPathList.appendChild(yo``)) + }) + } else { + let matchFound = false + for (var option of presentOptions) { + if (option.innerHTML.startsWith(this.inputPath.value)) + matchFound = true + } + if(!matchFound) this.createTestFolder.disabled = false + } + } + /* It is not possible anymore to see folder from outside of the current workspace if (this.inputPath.value) { @@ -578,14 +595,18 @@ module.exports = class TestTab extends ViewPlugin { data-id="uiPathInput" name="utPath" style="background-image: var(--primary);" - onkeydown=${(e) => { if (e.keyCode === 191) this.updateDirList() }} + onkeyup=${(e) => this.updateDirList(e.keyCode)} onchange=${(e) => this.updateCurrentPath(e)}/>` - const createTestFolder = yo`` @@ -593,7 +614,7 @@ module.exports = class TestTab extends ViewPlugin {
${this.inputPath} - ${createTestFolder} + ${this.createTestFolder} ${this.uiPathList}
From 3e564b489a8c55e3ece6b470431cd729fc7bbf8f Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Thu, 18 Mar 2021 18:17:06 +0530 Subject: [PATCH 02/26] comments and linting --- apps/remix-ide/src/app/tabs/test-tab.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 96a03f21aa..8bab882840 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -550,13 +550,15 @@ module.exports = class TestTab extends ViewPlugin { } updateDirList (keycode = 'none') { + // Initial load if (keycode === 'none') { this.testTabLogic.dirList('/').then((options) => { options.forEach((path) => this.uiPathList.appendChild(yo``)) }) } else { const presentOptions = this.uiPathList.querySelectorAll('option') - if(keycode === 191) { + // if '/' is pressed + if (keycode === 191) { for (var o of presentOptions) o.remove() this.testTabLogic.dirList('/').then((options) => { options.forEach((path) => this.uiPathList.appendChild(yo``)) @@ -564,13 +566,13 @@ module.exports = class TestTab extends ViewPlugin { } else { let matchFound = false for (var option of presentOptions) { - if (option.innerHTML.startsWith(this.inputPath.value)) - matchFound = true + if (option.innerHTML.startsWith(this.inputPath.value)) { matchFound = true } } - if(!matchFound) this.createTestFolder.disabled = false + // If there is no matching folder in the workspace with entered text, enable create button + if (!matchFound) this.createTestFolder.disabled = false } } - + /* It is not possible anymore to see folder from outside of the current workspace if (this.inputPath.value) { @@ -603,9 +605,9 @@ module.exports = class TestTab extends ViewPlugin { data-id="testTabGenerateTestFolder" title="Create a test folder" disabled=true - onclick=${(e) => { + onclick=${(e) => { this.testTabLogic.generateTestFolder(this.inputPath.value) - this.createTestFolder.disabled = true + this.createTestFolder.disabled = true }}> Create ` From 484414a95fe357c8120e6c9139422efb507eb67e Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Thu, 18 Mar 2021 19:04:37 +0530 Subject: [PATCH 03/26] update dropdown with newly created dir --- apps/remix-ide/src/app/tabs/test-tab.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 8bab882840..f1c9caaf6a 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -608,6 +608,7 @@ module.exports = class TestTab extends ViewPlugin { onclick=${(e) => { this.testTabLogic.generateTestFolder(this.inputPath.value) this.createTestFolder.disabled = true + this.updateDirList() }}> Create ` From c5cf7c3e0ea59d6b39b4a926bc1052fe98020648 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 19 Mar 2021 00:35:54 +0530 Subject: [PATCH 04/26] how to use link updated --- apps/remix-ide/src/app/tabs/test-tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index f1c9caaf6a..1aa4bca82e 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -537,7 +537,7 @@ module.exports = class TestTab extends ViewPlugin { infoButton () { return yo` - + ` From fd36b40b206a26044dd9b35cd175e2ff2a0d637d Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 19 Mar 2021 00:50:34 +0530 Subject: [PATCH 05/26] generate button disabled for custom dir --- apps/remix-ide/src/app/tabs/test-tab.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 1aa4bca82e..654bf9e338 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -566,10 +566,18 @@ module.exports = class TestTab extends ViewPlugin { } else { let matchFound = false for (var option of presentOptions) { - if (option.innerHTML.startsWith(this.inputPath.value)) { matchFound = true } + if (option.innerHTML.startsWith(this.inputPath.value)) matchFound = true + } + // If there is no matching folder in the workspace with entered text, enable Create button + if (!matchFound) { + // Enable Create button + this.createTestFolder.disabled = false + // Disable Generate button because dir is not existing + this.updateGenerateFileAction().disabled = true + } else { + this.createTestFolder.disabled = true + this.updateGenerateFileAction().disabled = false } - // If there is no matching folder in the workspace with entered text, enable create button - if (!matchFound) this.createTestFolder.disabled = false } } @@ -608,6 +616,7 @@ module.exports = class TestTab extends ViewPlugin { onclick=${(e) => { this.testTabLogic.generateTestFolder(this.inputPath.value) this.createTestFolder.disabled = true + this.updateGenerateFileAction().disabled = false this.updateDirList() }}> Create From 349ffd292db77a597a51ceef9a181dd694af7101 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 19 Mar 2021 21:02:49 +0530 Subject: [PATCH 06/26] folder list improved --- apps/remix-ide/src/app/tabs/test-tab.js | 41 +++++++++++-------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 654bf9e338..3bb19cff38 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -550,34 +550,27 @@ module.exports = class TestTab extends ViewPlugin { } updateDirList (keycode = 'none') { + const presentOptions = this.uiPathList.querySelectorAll('option') // Initial load - if (keycode === 'none') { + if (keycode === 'none' || keycode === 191) { + for (var o of presentOptions) o.remove() this.testTabLogic.dirList('/').then((options) => { options.forEach((path) => this.uiPathList.appendChild(yo``)) }) } else { - const presentOptions = this.uiPathList.querySelectorAll('option') - // if '/' is pressed - if (keycode === 191) { - for (var o of presentOptions) o.remove() - this.testTabLogic.dirList('/').then((options) => { - options.forEach((path) => this.uiPathList.appendChild(yo``)) - }) + let matchFound = false + for (var option of presentOptions) { + if (option.innerHTML.startsWith(this.inputPath.value)) matchFound = true + } + // If there is no matching folder in the workspace with entered text, enable Create button + if (!matchFound) { + // Enable Create button + this.createTestFolder.disabled = false + // Disable Generate button because dir is not existing + this.updateGenerateFileAction().disabled = true } else { - let matchFound = false - for (var option of presentOptions) { - if (option.innerHTML.startsWith(this.inputPath.value)) matchFound = true - } - // If there is no matching folder in the workspace with entered text, enable Create button - if (!matchFound) { - // Enable Create button - this.createTestFolder.disabled = false - // Disable Generate button because dir is not existing - this.updateGenerateFileAction().disabled = true - } else { - this.createTestFolder.disabled = true - this.updateGenerateFileAction().disabled = false - } + this.createTestFolder.disabled = true + this.updateGenerateFileAction().disabled = false } } @@ -605,7 +598,9 @@ module.exports = class TestTab extends ViewPlugin { data-id="uiPathInput" name="utPath" style="background-image: var(--primary);" - onkeyup=${(e) => this.updateDirList(e.keyCode)} + onkeyup=${(e) => { + if (e.keyCode) this.updateDirList(e.keyCode) + }} onchange=${(e) => this.updateCurrentPath(e)}/>` this.createTestFolder = yo`` From 7ab2f207c68fd850d5df2365828dd846d6be8b97 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Mon, 22 Mar 2021 20:06:45 +0530 Subject: [PATCH 08/26] linting fix --- apps/remix-ide/src/app/tabs/test-tab.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 796c633345..57dde5121a 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -552,18 +552,17 @@ module.exports = class TestTab extends ViewPlugin { updateDirList (keycode = 'none') { const presentOptions = this.uiPathList.querySelectorAll('option') // Initial load - if (keycode === 'none' ) { - for (var o of presentOptions) o.remove() + if (keycode === 'none') { + for (const o of presentOptions) o.remove() this.testTabLogic.dirList('/').then((options) => { options.forEach((path) => this.uiPathList.appendChild(yo``)) }) } else if (this.inputPath.value && this.inputPath.value.endsWith('/')) { - for (var o of presentOptions) o.remove() + for (const o of presentOptions) o.remove() this.testTabLogic.dirList(this.inputPath.value).then((options) => { options.forEach((path) => this.uiPathList.appendChild(yo``)) }) - } - else { + } else { let matchFound = false for (var option of presentOptions) { if (option.innerHTML.startsWith(this.inputPath.value)) matchFound = true From 9d5c14e0b9bec0be40a2c3d35d7eaf9143aa62a7 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Mon, 22 Mar 2021 21:47:47 +0530 Subject: [PATCH 09/26] keycode check removed --- apps/remix-ide/src/app/tabs/test-tab.js | 38 +++++++++---------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 57dde5121a..1a45defae4 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -549,22 +549,19 @@ module.exports = class TestTab extends ViewPlugin { return yo`Progress: ${ready} finished (of ${this.runningTestsNumber})` } - updateDirList (keycode = 'none') { - const presentOptions = this.uiPathList.querySelectorAll('option') - // Initial load - if (keycode === 'none') { - for (const o of presentOptions) o.remove() - this.testTabLogic.dirList('/').then((options) => { - options.forEach((path) => this.uiPathList.appendChild(yo``)) - }) - } else if (this.inputPath.value && this.inputPath.value.endsWith('/')) { - for (const o of presentOptions) o.remove() - this.testTabLogic.dirList(this.inputPath.value).then((options) => { - options.forEach((path) => this.uiPathList.appendChild(yo``)) - }) + updateDirList (path) { + for (const o of this.uiPathList.querySelectorAll('option')) o.remove() + this.testTabLogic.dirList(path).then((options) => { + options.forEach((path) => this.uiPathList.appendChild(yo``)) + }) + } + + handleTestDirInput () { + if (this.inputPath.value && this.inputPath.value.endsWith('/')) { + this.updateDirList(this.inputPath.value) } else { let matchFound = false - for (var option of presentOptions) { + for (const option of this.uiPathList.querySelectorAll('option')) { if (option.innerHTML.startsWith(this.inputPath.value)) matchFound = true } // If there is no matching folder in the workspace with entered text, enable Create button @@ -578,15 +575,6 @@ module.exports = class TestTab extends ViewPlugin { this.updateGenerateFileAction().disabled = false } } - - /* - It is not possible anymore to see folder from outside of the current workspace - if (this.inputPath.value) { - this.testTabLogic.dirList(this.inputPath.value).then((options) => { - options.forEach((path) => this.uiPathList.appendChild(yo``)) - }) - } - */ } render () { @@ -604,7 +592,7 @@ module.exports = class TestTab extends ViewPlugin { name="utPath" style="background-image: var(--primary);" onkeyup=${(e) => { - if (e.keyCode) this.updateDirList(e.keyCode) + if (e.keyCode) this.handleTestDirInput() }} onchange=${(e) => this.updateCurrentPath(e)}/>` @@ -630,7 +618,7 @@ module.exports = class TestTab extends ViewPlugin { ` - this.updateDirList() + this.updateDirList('/') this.testsExecutionStopped.hidden = true this.testsExecutionStoppedError.hidden = true this.resultStatistics = this.createResultLabel() From 3c4d0dfe40ed11bdddd73a4fb10979e8da20492e Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 24 Mar 2021 14:19:33 +0530 Subject: [PATCH 10/26] add new folder in dir list --- apps/remix-ide/src/app/tabs/test-tab.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 1a45defae4..b396a102fd 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -605,6 +605,7 @@ module.exports = class TestTab extends ViewPlugin { this.testTabLogic.generateTestFolder(this.inputPath.value) this.createTestFolder.disabled = true this.updateGenerateFileAction().disabled = false + this.uiPathList.appendChild(yo``) }}> Create ` From 24bf64bf2ce7c5fe1dc0ba709d05dcabee1bd2a5 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 24 Mar 2021 14:29:08 +0530 Subject: [PATCH 11/26] enable create for each custom input --- apps/remix-ide/src/app/tabs/test-tab.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index b396a102fd..ceb2cd095e 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -562,7 +562,7 @@ module.exports = class TestTab extends ViewPlugin { } else { let matchFound = false for (const option of this.uiPathList.querySelectorAll('option')) { - if (option.innerHTML.startsWith(this.inputPath.value)) matchFound = true + if (option.innerHTML === this.inputPath.value) matchFound = true } // If there is no matching folder in the workspace with entered text, enable Create button if (!matchFound) { @@ -591,9 +591,7 @@ module.exports = class TestTab extends ViewPlugin { data-id="uiPathInput" name="utPath" style="background-image: var(--primary);" - onkeyup=${(e) => { - if (e.keyCode) this.handleTestDirInput() - }} + onkeyup=${(e) => this.handleTestDirInput()} onchange=${(e) => this.updateCurrentPath(e)}/>` this.createTestFolder = yo`` + onchange=${(e) => { if (!this.createTestFolder.disabled) this.handleCreateFolder() }} + />` + + this.createTestFolder = yo` + + ` const availablePaths = yo`
-
- ${this.inputPath} - ${this.createTestFolder} - ${this.uiPathList} -
+
+ ${this.inputPath} + ${this.createTestFolder} + ${this.uiPathList} +
` this.updateDirList('/') From 2851134c7e6a8487e14d40f94d508d19582cd7ca Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 19 Apr 2021 12:44:56 +0200 Subject: [PATCH 15/26] cleanup --- apps/remix-ide/src/app/tabs/test-tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index c4753b6f3f..617a5bf290 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -578,7 +578,7 @@ module.exports = class TestTab extends ViewPlugin { if (testDirInput) { if (testDirInput.endsWith('/')) { // check if the options list already contains the options - if (this.doesOptionAlreadyAdded(testDirInput) || this.testTabLogic.currentPath === testDirInput) { + if (this.testTabLogic.currentPath === testDirInput) { this.createTestFolder.disabled = true this.updateGenerateFileAction().disabled = true } From 1b0a4a5f51df0f5c36e08248f41d91b441f1991e Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 21 Apr 2021 17:54:01 +0200 Subject: [PATCH 16/26] fixed the current in test for SUT --- apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index 578976cc1b..b1d5479c63 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -152,11 +152,10 @@ module.exports = { function runTests (browser: NightwatchBrowser) { browser .waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') - .clickLaunchIcon('filePanel') - .click('*[data-id="treeViewLitreeViewItemcontracts"]') - .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) From cb370bbd5b74940aac23525233c3554628265eec Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 21 Apr 2021 18:29:20 +0200 Subject: [PATCH 17/26] clean the value before setting --- apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index b1d5479c63..165e632295 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -154,6 +154,7 @@ function runTests (browser: NightwatchBrowser) { .waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') .clickLaunchIcon('solidityUnitTesting') .pause(500) + .clearValue('*[data-id="uiPathInput"]') .setValue('*[data-id="uiPathInput"]', 'tests') .pause(2000) .scrollAndClick('#runTestsTabRunAction') From 908d897f9fb78e28bbecc56269798ea72d21ecf9 Mon Sep 17 00:00:00 2001 From: lianahus Date: Thu, 22 Apr 2021 09:24:29 +0200 Subject: [PATCH 18/26] fixing test --- apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index 165e632295..119d3ccc56 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -156,6 +156,7 @@ function runTests (browser: NightwatchBrowser) { .pause(500) .clearValue('*[data-id="uiPathInput"]') .setValue('*[data-id="uiPathInput"]', 'tests') + .click('*[data-id="testTabGenerateTestFolder"]') .pause(2000) .scrollAndClick('#runTestsTabRunAction') .waitForElementVisible('*[data-id="testTabSolidityUnitTestsOutputheader"]', 120000) From 80b7a7e2990276dbc4fa589335ca98f83c8a3c9b Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 26 Apr 2021 13:19:57 +0200 Subject: [PATCH 19/26] uodate current on enter --- apps/remix-ide/src/app/tabs/test-tab.js | 31 ++++++++++++++++--- .../remix-ide/src/app/tabs/testTab/testTab.js | 7 +++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 617a5bf290..801f69e120 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -69,6 +69,7 @@ module.exports = class TestTab extends ViewPlugin { updateForNewCurrent (file) { this.updateGenerateFileAction(file) if (!this.areTestsRunning) this.updateRunAction(file) + this.updateTestFileList() this.testTabLogic.getTests((error, tests) => { if (error) return tooltip(error) this.data.allTests = tests @@ -566,15 +567,24 @@ module.exports = class TestTab extends ViewPlugin { else return input.trim() } - doesOptionAlreadyAdded (text) { + pathAdded (text) { for (const option of this.uiPathList.querySelectorAll('option')) { if (option.innerHTML === text) return true } return false } - handleTestDirInput () { + async handleTestDirInput (e) { const testDirInput = this.trimTestDirInput(this.inputPath.value) + if (e.key === 'Enter') { + this.inputPath.value = this.trimTestDirInput(testDirInput) + if (await this.testTabLogic.pathExists(testDirInput)) { + this.testTabLogic.setCurrentPath(testDirInput) + this.updateForNewCurrent() + return + } + } + if (testDirInput) { if (testDirInput.endsWith('/')) { // check if the options list already contains the options @@ -585,7 +595,7 @@ module.exports = class TestTab extends ViewPlugin { this.updateDirList(testDirInput) } else { // If there is no matching folder in the workspace with entered text, enable Create button - if (this.doesOptionAlreadyAdded(testDirInput)) { + if (this.pathAdded(testDirInput)) { this.createTestFolder.disabled = true this.updateGenerateFileAction().disabled = false } else { @@ -614,8 +624,19 @@ module.exports = class TestTab extends ViewPlugin { data-id="uiPathInput" name="utPath" style="background-image: var(--primary);" - onkeyup=${(e) => this.handleTestDirInput()} - onchange=${(e) => { if (!this.createTestFolder.disabled) this.handleCreateFolder() }} + onkeyup=${(e) => this.handleTestDirInput(e)} + onchange=${(e) => { + console.log("onchange") + if (!this.createTestFolder.disabled) return // this.handleCreateFolder() + else { + this.inputPath.value = this.trimTestDirInput(this.inputPath.value) + if (this.testTabLogic.pathExists(this.inputPath.value)) { + this.inputPath.value = this.trimTestDirInput(this.inputPath.value) + this.testTabLogic.setCurrentPath(this.inputPath.value) + this.updateForNewCurrent() + } + } + }} />` this.createTestFolder = yo` diff --git a/apps/remix-ide/src/app/tabs/testTab/testTab.js b/apps/remix-ide/src/app/tabs/testTab/testTab.js index 9b18732950..4d9a1a19d7 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' From 6ac6b7ee2c6f97489485ca39fb0da51b627474ed Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 27 Apr 2021 14:19:38 +0200 Subject: [PATCH 20/26] linter fixed` --- apps/remix-ide/src/app/tabs/test-tab.js | 4 +--- apps/remix-ide/src/app/tabs/testTab/testTab.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 801f69e120..fdeb287c0b 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -626,9 +626,7 @@ module.exports = class TestTab extends ViewPlugin { style="background-image: var(--primary);" onkeyup=${(e) => this.handleTestDirInput(e)} onchange=${(e) => { - console.log("onchange") - if (!this.createTestFolder.disabled) return // this.handleCreateFolder() - else { + if (this.createTestFolder.disabled) { this.inputPath.value = this.trimTestDirInput(this.inputPath.value) if (this.testTabLogic.pathExists(this.inputPath.value)) { this.inputPath.value = this.trimTestDirInput(this.inputPath.value) diff --git a/apps/remix-ide/src/app/tabs/testTab/testTab.js b/apps/remix-ide/src/app/tabs/testTab/testTab.js index 4d9a1a19d7..1cfdff91be 100644 --- a/apps/remix-ide/src/app/tabs/testTab/testTab.js +++ b/apps/remix-ide/src/app/tabs/testTab/testTab.js @@ -21,7 +21,7 @@ class TestTabLogic { fileProvider.exists(path, (e, res) => { if (!res) fileProvider.createDir(path) }) } - pathExists(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]) From a6481b0b0f91f20f4c33bc484c8fe4fcefafa541 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 3 May 2021 09:42:16 +0200 Subject: [PATCH 21/26] listen to event setWorkspace --- apps/remix-ide/src/app/tabs/test-tab.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index fdeb287c0b..1fa24d05a4 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -53,6 +53,8 @@ module.exports = class TestTab extends ViewPlugin { listenToEvents () { this.filePanel.event.register('newTestFileCreated', file => { + console.log('newTestFileCreated') + var testList = this._view.el.querySelector("[class^='testList']") var test = this.createSingleTest(file) testList.appendChild(test) @@ -60,6 +62,12 @@ module.exports = class TestTab extends ViewPlugin { this.data.selectedTests.push(file) }) + this.on('fileExplorers', 'setWorkspace', async () => { + this.testTabLogic.setCurrentPath(this.defaultPath) + this.inputPath.value = this.defaultPath + this.updateForNewCurrent() + }) + this.fileManager.events.on('noFileSelected', () => { }) @@ -67,7 +75,7 @@ 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) => { @@ -462,7 +470,7 @@ module.exports = class TestTab extends ViewPlugin { runBtn.setAttribute('disabled', 'disabled') } - updateGenerateFileAction (currentFile) { + updateGenerateFileAction () { const el = yo`