diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index ad4fbe935d..44c9454aee 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -39,13 +39,6 @@ module.exports = class TestTab extends ViewPlugin { this.offsetToLineColumnConverter = offsetToLineColumnConverter this.allFilesInvolved = ['.deps/remix-tests/remix_tests.sol', '.deps/remix-tests/remix_accounts.sol'] this.element = document.createElement('div') - - appManager.event.on('activate', (name) => { - if (name === 'solidity') this.updateRunAction() - }) - appManager.event.on('deactivate', (name) => { - if (name === 'solidity') this.updateRunAction() - }) } onActivationInternal () { @@ -86,7 +79,6 @@ module.exports = class TestTab extends ViewPlugin { } await this.testRunner.init() await this.createTestLibs() - // this.updateRunAction() } onDeactivation () { @@ -97,9 +89,6 @@ module.exports = class TestTab extends ViewPlugin { } listenToEvents() { - this.on('filePanel', 'setWorkspace', async () => { - this.setCurrentPath(this.defaultPath) - }) this.on('filePanel', 'workspaceCreated', async () => { this.createTestLibs() @@ -120,17 +109,6 @@ module.exports = class TestTab extends ViewPlugin { return this.testFromSource(fileContent, path) } - /** - * Changes the current path of Unit Testing Plugin - * @param path - the path from where UT plugin takes _test.sol files to run - */ - async setCurrentPath (path) { - this.testTabLogic.setCurrentPath(path) - this.inputPath.value = path - this.updateDirList(path) - await this.updateForNewCurrent() - } - /* Test is not associated with the UI */ diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts b/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts index 31e34cf50f..9d07ed32ed 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts +++ b/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts @@ -6,7 +6,6 @@ export class TestTabLogic { currentPath helper constructor (fileManager: any, helper: any) { - console.log('Inside TestTabLogic constructor--from SUT-fileManager--->', fileManager) this.fileManager = fileManager this.helper = helper this.currentPath = '/tests' @@ -48,7 +47,6 @@ export class TestTabLogic { this.helper.createNonClashingNameWithPrefix(fileNameToImport, fileProvider, '_test', (error: any, newFile: any) => { // if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error) const isFileCreated = fileProvider.set(newFile, this.generateTestContractSample(hasCurrent, fileName)) - console.log('isFileCreated---->', isFileCreated) // if (!isFileCreated) return modalDialogCustom.alert('Failed to create test file ' + newFile) this.fileManager.open(newFile) this.fileManager.syncEditor(newFile) diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index 7d65e2a53d..f32cf6672e 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -69,22 +69,22 @@ export const SolidityUnitTesting = (props: Record) => { setTestsExecutionStoppedErrorHidden(true) } - const updateForNewCurrent = async (file = null) => { - // Ensure that when someone clicks on compilation error and that opens a new file - // Test result, which is compilation error in this case, is not cleared - if (currentErrors) { - if (Array.isArray(currentErrors) && currentErrors.length > 0) { - const errFiles = currentErrors.map(err => { if (err.sourceLocation && err.sourceLocation.file) return err.sourceLocation.file }) // eslint-disable-line - if (errFiles.includes(file)) return - } else if (currentErrors.sourceLocation && currentErrors.sourceLocation.file && currentErrors.sourceLocation.file === file) return - } - // if current file is changed while debugging and one of the files imported in test file are opened - // do not clear the test results in SUT plugin - if (isDebugging && testTab.allFilesInvolved.includes(file)) return - allTests = [] - updateTestFileList() - clearResults() - try { + const updateForNewCurrent = async (file = null) => { + // Ensure that when someone clicks on compilation error and that opens a new file + // Test result, which is compilation error in this case, is not cleared + if (currentErrors) { + if (Array.isArray(currentErrors) && currentErrors.length > 0) { + const errFiles = currentErrors.map(err => { if (err.sourceLocation && err.sourceLocation.file) return err.sourceLocation.file }) // eslint-disable-line + if (errFiles.includes(file)) return + } else if (currentErrors.sourceLocation && currentErrors.sourceLocation.file && currentErrors.sourceLocation.file === file) return + } + // if current file is changed while debugging and one of the files imported in test file are opened + // do not clear the test results in SUT plugin + if (isDebugging && testTab.allFilesInvolved.includes(file)) return + allTests = [] + updateTestFileList() + clearResults() + try { testTabLogic.getTests(async (error: any, tests: any) => { // if (error) return tooltip(error) allTests = tests @@ -94,8 +94,19 @@ export const SolidityUnitTesting = (props: Record) => { if (!areTestsRunning) await updateRunAction(file) }) } catch (e) { - console.log(e) - } + console.log(e) + } + } + + /** + * Changes the current path of Unit Testing Plugin + * @param path - the path from where UT plugin takes _test.sol files to run + */ + const setCurrentPath = async (path: string) => { + testTabLogic.setCurrentPath(path) + setInputPathValue(path) + updateDirList(path) + await updateForNewCurrent() } useEffect(() => { @@ -119,9 +130,13 @@ export const SolidityUnitTesting = (props: Record) => { } }) + testTab.on('filePanel', 'setWorkspace', async () => { + setCurrentPath(defaultPath) + }) + testTab.fileManager.events.on('noFileSelected', () => {}) testTab.fileManager.events.on('currentFileChanged', (file: any, provider: any) => updateForNewCurrent(file)) - + }, []) // eslint-disable-line const updateDirList = (path: string) => {