diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 44c9454aee..9351b37c05 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -88,7 +88,7 @@ module.exports = class TestTab extends ViewPlugin { this.fileManager.events.removeAllListeners('currentFileChanged') } - listenToEvents() { + listenToEvents () { this.on('filePanel', 'workspaceCreated', async () => { this.createTestLibs() 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 9d07ed32ed..6e955c1074 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 @@ -47,6 +47,7 @@ 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 f32cf6672e..4b2d3c0388 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 @@ -48,7 +48,7 @@ export const SolidityUnitTesting = (props: Record) => { let areTestsRunning = false let isDebugging = false - let allTests: any = [] + const allTests: any = useRef([]) let currentErrors: any = [] let runningTestFileName: any @@ -81,14 +81,14 @@ export const SolidityUnitTesting = (props: Record) => { // 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 = [] + allTests.current = [] updateTestFileList() clearResults() try { testTabLogic.getTests(async (error: any, tests: any) => { // if (error) return tooltip(error) - allTests = tests - selectedTests = [...allTests] + allTests.current = tests + selectedTests = [...allTests.current] setSelectedTests(tests) updateTestFileList() if (!areTestsRunning) await updateRunAction(file) @@ -113,18 +113,18 @@ export const SolidityUnitTesting = (props: Record) => { updateDirList('/') updateForNewCurrent() - testTab.on('filePanel', 'newTestFileCreated', async (file: any) => { + testTab.on('filePanel', 'newTestFileCreated', async (file: string) => { try { testTabLogic.getTests((error: any, tests: any) => { // if (error) return tooltip(error) - allTests = tests - selectedTests = [...allTests] + allTests.current = tests + selectedTests = [...allTests.current] setSelectedTests(tests) updateTestFileList() }) } catch (e) { console.log(e) - allTests.push(file) + allTests.current.push(file) selectedTests.push(file) setSelectedTests(selectedTests) } @@ -134,7 +134,7 @@ export const SolidityUnitTesting = (props: Record) => { setCurrentPath(defaultPath) }) - testTab.fileManager.events.on('noFileSelected', () => {}) + testTab.fileManager.events.on('noFileSelected', () => {}) // eslint-disable-line testTab.fileManager.events.on('currentFileChanged', (file: any, provider: any) => updateForNewCurrent(file)) }, []) // eslint-disable-line @@ -616,8 +616,8 @@ export const SolidityUnitTesting = (props: Record) => { } const updateTestFileList = () => { - if(allTests?.length) { - testFiles = allTests.map((testFile: any) => { return {'fileName': testFile, 'checked': true }}) + if(allTests.current?.length) { + testFiles = allTests.current.map((testFile: any) => { return {'fileName': testFile, 'checked': true }}) setCheckSelectAll(true) } else