pull/1862/head
aniket-engg 3 years ago committed by Aniket
parent 8449bf8f15
commit 02e5db8bfd
  1. 2
      apps/remix-ide/src/app/tabs/test-tab.js
  2. 1
      libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts
  3. 22
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx

@ -88,7 +88,7 @@ module.exports = class TestTab extends ViewPlugin {
this.fileManager.events.removeAllListeners('currentFileChanged') this.fileManager.events.removeAllListeners('currentFileChanged')
} }
listenToEvents() { listenToEvents () {
this.on('filePanel', 'workspaceCreated', async () => { this.on('filePanel', 'workspaceCreated', async () => {
this.createTestLibs() this.createTestLibs()

@ -47,6 +47,7 @@ export class TestTabLogic {
this.helper.createNonClashingNameWithPrefix(fileNameToImport, fileProvider, '_test', (error: any, newFile: any) => { this.helper.createNonClashingNameWithPrefix(fileNameToImport, fileProvider, '_test', (error: any, newFile: any) => {
// if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error) // if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error)
const isFileCreated = fileProvider.set(newFile, this.generateTestContractSample(hasCurrent, fileName)) const isFileCreated = fileProvider.set(newFile, this.generateTestContractSample(hasCurrent, fileName))
console.log('isFileCreated--->', isFileCreated)
// if (!isFileCreated) return modalDialogCustom.alert('Failed to create test file ' + newFile) // if (!isFileCreated) return modalDialogCustom.alert('Failed to create test file ' + newFile)
this.fileManager.open(newFile) this.fileManager.open(newFile)
this.fileManager.syncEditor(newFile) this.fileManager.syncEditor(newFile)

@ -48,7 +48,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => {
let areTestsRunning = false let areTestsRunning = false
let isDebugging = false let isDebugging = false
let allTests: any = [] const allTests: any = useRef([])
let currentErrors: any = [] let currentErrors: any = []
let runningTestFileName: any let runningTestFileName: any
@ -81,14 +81,14 @@ export const SolidityUnitTesting = (props: Record<string, any>) => {
// if current file is changed while debugging and one of the files imported in test file are opened // 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 // do not clear the test results in SUT plugin
if (isDebugging && testTab.allFilesInvolved.includes(file)) return if (isDebugging && testTab.allFilesInvolved.includes(file)) return
allTests = [] allTests.current = []
updateTestFileList() updateTestFileList()
clearResults() clearResults()
try { try {
testTabLogic.getTests(async (error: any, tests: any) => { testTabLogic.getTests(async (error: any, tests: any) => {
// if (error) return tooltip(error) // if (error) return tooltip(error)
allTests = tests allTests.current = tests
selectedTests = [...allTests] selectedTests = [...allTests.current]
setSelectedTests(tests) setSelectedTests(tests)
updateTestFileList() updateTestFileList()
if (!areTestsRunning) await updateRunAction(file) if (!areTestsRunning) await updateRunAction(file)
@ -113,18 +113,18 @@ export const SolidityUnitTesting = (props: Record<string, any>) => {
updateDirList('/') updateDirList('/')
updateForNewCurrent() updateForNewCurrent()
testTab.on('filePanel', 'newTestFileCreated', async (file: any) => { testTab.on('filePanel', 'newTestFileCreated', async (file: string) => {
try { try {
testTabLogic.getTests((error: any, tests: any) => { testTabLogic.getTests((error: any, tests: any) => {
// if (error) return tooltip(error) // if (error) return tooltip(error)
allTests = tests allTests.current = tests
selectedTests = [...allTests] selectedTests = [...allTests.current]
setSelectedTests(tests) setSelectedTests(tests)
updateTestFileList() updateTestFileList()
}) })
} catch (e) { } catch (e) {
console.log(e) console.log(e)
allTests.push(file) allTests.current.push(file)
selectedTests.push(file) selectedTests.push(file)
setSelectedTests(selectedTests) setSelectedTests(selectedTests)
} }
@ -134,7 +134,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => {
setCurrentPath(defaultPath) 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)) testTab.fileManager.events.on('currentFileChanged', (file: any, provider: any) => updateForNewCurrent(file))
}, []) // eslint-disable-line }, []) // eslint-disable-line
@ -616,8 +616,8 @@ export const SolidityUnitTesting = (props: Record<string, any>) => {
} }
const updateTestFileList = () => { const updateTestFileList = () => {
if(allTests?.length) { if(allTests.current?.length) {
testFiles = allTests.map((testFile: any) => { return {'fileName': testFile, 'checked': true }}) testFiles = allTests.current.map((testFile: any) => { return {'fileName': testFile, 'checked': true }})
setCheckSelectAll(true) setCheckSelectAll(true)
} }
else else

Loading…
Cancel
Save