|
|
@ -21,7 +21,6 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
const { helper, testTab, initialPath } = props |
|
|
|
const { helper, testTab, initialPath } = props |
|
|
|
const { testTabLogic } = testTab |
|
|
|
const { testTabLogic } = testTab |
|
|
|
|
|
|
|
|
|
|
|
const [defaultPath, setDefaultPath] = useState('tests') |
|
|
|
|
|
|
|
const [toasterMsg, setToasterMsg] = useState('') |
|
|
|
const [toasterMsg, setToasterMsg] = useState('') |
|
|
|
|
|
|
|
|
|
|
|
const [disableCreateButton, setDisableCreateButton] = useState(true) |
|
|
|
const [disableCreateButton, setDisableCreateButton] = useState(true) |
|
|
@ -52,7 +51,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
const selectedTests: any = useRef([]) |
|
|
|
const selectedTests: any = useRef([]) |
|
|
|
const currentErrors: any = useRef([]) |
|
|
|
const currentErrors: any = useRef([]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const defaultPath = 'tests' |
|
|
|
let areTestsRunning = false |
|
|
|
let areTestsRunning = false |
|
|
|
|
|
|
|
|
|
|
|
let runningTestFileName: any |
|
|
|
let runningTestFileName: any |
|
|
@ -88,15 +87,14 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
updateTestFileList() |
|
|
|
updateTestFileList() |
|
|
|
clearResults() |
|
|
|
clearResults() |
|
|
|
try { |
|
|
|
try { |
|
|
|
testTabLogic.getTests(async (error: any, tests: any) => { |
|
|
|
const tests = await testTabLogic.getTests() |
|
|
|
if (error) return setToasterMsg(error)
|
|
|
|
allTests.current = tests |
|
|
|
allTests.current = tests |
|
|
|
selectedTests.current = [...allTests.current] |
|
|
|
selectedTests.current = [...allTests.current] |
|
|
|
updateTestFileList() |
|
|
|
updateTestFileList() |
|
|
|
if (!areTestsRunning) await updateRunAction(file) |
|
|
|
if (!areTestsRunning) await updateRunAction(file) |
|
|
|
} catch (e: any) { |
|
|
|
}) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
|
|
|
|
setToasterMsg(e) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -116,17 +114,12 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
}, [initialPath]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
}, [initialPath]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
updateDirList('/') |
|
|
|
|
|
|
|
updateForNewCurrent() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testTab.on('filePanel', 'newTestFileCreated', async (file: string) => { |
|
|
|
testTab.on('filePanel', 'newTestFileCreated', async (file: string) => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
testTabLogic.getTests((error: any, tests: any) => { |
|
|
|
const tests = await testTabLogic.getTests() |
|
|
|
if (error) return setToasterMsg(error)
|
|
|
|
allTests.current = tests |
|
|
|
allTests.current = tests |
|
|
|
selectedTests.current = [...allTests.current] |
|
|
|
selectedTests.current = [...allTests.current] |
|
|
|
updateTestFileList() |
|
|
|
updateTestFileList() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
allTests.current.push(file) |
|
|
|
allTests.current.push(file) |
|
|
@ -135,11 +128,11 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
testTab.on('filePanel', 'setWorkspace', async () => { |
|
|
|
testTab.on('filePanel', 'setWorkspace', async () => { |
|
|
|
setCurrentPath(defaultPath) |
|
|
|
await setCurrentPath(defaultPath) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
testTab.fileManager.events.on('noFileSelected', () => { }) // eslint-disable-line
|
|
|
|
testTab.fileManager.events.on('noFileSelected', () => { }) // eslint-disable-line
|
|
|
|
testTab.fileManager.events.on('currentFileChanged', (file: any, provider: any) => updateForNewCurrent(file)) |
|
|
|
testTab.fileManager.events.on('currentFileChanged', async (file: any, provider: any) => await updateForNewCurrent(file)) |
|
|
|
|
|
|
|
|
|
|
|
}, []) // eslint-disable-line
|
|
|
|
}, []) // eslint-disable-line
|
|
|
|
|
|
|
|
|
|
|
@ -157,7 +150,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
if (e.key === 'Enter') { |
|
|
|
if (e.key === 'Enter') { |
|
|
|
if (await testTabLogic.pathExists(testDirInput)) { |
|
|
|
if (await testTabLogic.pathExists(testDirInput)) { |
|
|
|
testTabLogic.setCurrentPath(testDirInput) |
|
|
|
testTabLogic.setCurrentPath(testDirInput) |
|
|
|
updateForNewCurrent() |
|
|
|
await updateForNewCurrent() |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -174,17 +167,19 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
if (await testTabLogic.pathExists(testDirInput)) { |
|
|
|
if (await testTabLogic.pathExists(testDirInput)) { |
|
|
|
setDisableCreateButton(true) |
|
|
|
setDisableCreateButton(true) |
|
|
|
setDisableGenerateButton(false) |
|
|
|
setDisableGenerateButton(false) |
|
|
|
testTabLogic.setCurrentPath(testDirInput) |
|
|
|
|
|
|
|
updateForNewCurrent() |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Enable Create button
|
|
|
|
// Enable Create button
|
|
|
|
setDisableCreateButton(false) |
|
|
|
setDisableCreateButton(false) |
|
|
|
// Disable Generate button because dir does not exist
|
|
|
|
// Disable Generate button because dir does not exist
|
|
|
|
setDisableGenerateButton(true) |
|
|
|
setDisableGenerateButton(true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
await setCurrentPath(testDirInput) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
updateDirList('/') |
|
|
|
await setCurrentPath('/') |
|
|
|
|
|
|
|
setDisableCreateButton(true) |
|
|
|
|
|
|
|
setDisableGenerateButton(false) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -194,8 +189,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
setInputPathValue(inputPath) |
|
|
|
setInputPathValue(inputPath) |
|
|
|
if (disableCreateButton) { |
|
|
|
if (disableCreateButton) { |
|
|
|
if (await testTabLogic.pathExists(inputPath)) { |
|
|
|
if (await testTabLogic.pathExists(inputPath)) { |
|
|
|
testTabLogic.setCurrentPath(inputPath) |
|
|
|
await setCurrentPath(inputPath) |
|
|
|
updateForNewCurrent() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -211,7 +205,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
setDisableGenerateButton(false) |
|
|
|
setDisableGenerateButton(false) |
|
|
|
testTabLogic.setCurrentPath(inputPath) |
|
|
|
testTabLogic.setCurrentPath(inputPath) |
|
|
|
await updateRunAction() |
|
|
|
await updateRunAction() |
|
|
|
updateForNewCurrent() |
|
|
|
await updateForNewCurrent() |
|
|
|
pathOptions.push(inputPath) |
|
|
|
pathOptions.push(inputPath) |
|
|
|
setPathOptions(pathOptions) |
|
|
|
setPathOptions(pathOptions) |
|
|
|
} |
|
|
|
} |
|
|
@ -648,7 +642,6 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
} |
|
|
|
} |
|
|
|
</datalist> |
|
|
|
</datalist> |
|
|
|
<input |
|
|
|
<input |
|
|
|
placeholder={defaultPath} |
|
|
|
|
|
|
|
list="utPathList" |
|
|
|
list="utPathList" |
|
|
|
className="inputFolder custom-select" |
|
|
|
className="inputFolder custom-select" |
|
|
|
id="utPath" |
|
|
|
id="utPath" |
|
|
@ -659,6 +652,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
style={{ backgroundImage: "var(--primary)" }} |
|
|
|
style={{ backgroundImage: "var(--primary)" }} |
|
|
|
onKeyUp={handleTestDirInput} |
|
|
|
onKeyUp={handleTestDirInput} |
|
|
|
onChange={handleEnter} |
|
|
|
onChange={handleEnter} |
|
|
|
|
|
|
|
onClick = {() => { if (inputPathValue === '/') setInputPathValue('')} } |
|
|
|
/> |
|
|
|
/> |
|
|
|
<button |
|
|
|
<button |
|
|
|
className="btn border ml-2" |
|
|
|
className="btn border ml-2" |
|
|
@ -679,9 +673,9 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { |
|
|
|
data-id="testTabGenerateTestFile" |
|
|
|
data-id="testTabGenerateTestFile" |
|
|
|
title="Generate sample test file." |
|
|
|
title="Generate sample test file." |
|
|
|
disabled={disableGenerateButton} |
|
|
|
disabled={disableGenerateButton} |
|
|
|
onClick={() => { |
|
|
|
onClick={async () => { |
|
|
|
testTabLogic.generateTestFile((err:any) => { if (err) setToasterMsg(err)}) |
|
|
|
testTabLogic.generateTestFile((err:any) => { if (err) setToasterMsg(err)}) |
|
|
|
updateForNewCurrent() |
|
|
|
await updateForNewCurrent() |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
Generate |
|
|
|
Generate |
|
|
|