|
|
@ -67,6 +67,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d |
|
|
|
let [readyTestsNumber, setReadyTestsNumber] = useState<number>(0) // eslint-disable-line
|
|
|
|
let [readyTestsNumber, setReadyTestsNumber] = useState<number>(0) // eslint-disable-line
|
|
|
|
let [runningTestsNumber, setRunningTestsNumber] = useState<number>(0) // eslint-disable-line
|
|
|
|
let [runningTestsNumber, setRunningTestsNumber] = useState<number>(0) // eslint-disable-line
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const areTestsRunning = useRef<boolean>(false) |
|
|
|
const hasBeenStopped = useRef<boolean>(false) |
|
|
|
const hasBeenStopped = useRef<boolean>(false) |
|
|
|
const isDebugging = useRef<boolean>(false) |
|
|
|
const isDebugging = useRef<boolean>(false) |
|
|
|
const allTests = useRef<string[]>([]) |
|
|
|
const allTests = useRef<string[]>([]) |
|
|
@ -74,7 +75,6 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d |
|
|
|
const currentErrors:any = useRef([]) // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
const currentErrors:any = useRef([]) // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
|
|
|
|
|
|
|
|
const defaultPath = 'tests' |
|
|
|
const defaultPath = 'tests' |
|
|
|
let areTestsRunning = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let runningTestFileName: string |
|
|
|
let runningTestFileName: string |
|
|
|
const filesContent: Record<string, Record<string, string>> = {} |
|
|
|
const filesContent: Record<string, Record<string, string>> = {} |
|
|
@ -113,7 +113,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d |
|
|
|
allTests.current = tests |
|
|
|
allTests.current = tests |
|
|
|
selectedTests.current = [...allTests.current] |
|
|
|
selectedTests.current = [...allTests.current] |
|
|
|
updateTestFileList() |
|
|
|
updateTestFileList() |
|
|
|
if (!areTestsRunning) await updateRunAction(file) |
|
|
|
if (!areTestsRunning.current) await updateRunAction(file) |
|
|
|
} catch (e: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
} catch (e: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
setToasterMsg(e) |
|
|
|
setToasterMsg(e) |
|
|
@ -500,7 +500,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d |
|
|
|
if (selectedTests.current?.length !== 0) { |
|
|
|
if (selectedTests.current?.length !== 0) { |
|
|
|
setDisableRunButton(false) |
|
|
|
setDisableRunButton(false) |
|
|
|
} |
|
|
|
} |
|
|
|
areTestsRunning = false |
|
|
|
areTestsRunning.current = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -547,7 +547,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const runTests = () => { |
|
|
|
const runTests = () => { |
|
|
|
areTestsRunning = true |
|
|
|
areTestsRunning.current = true |
|
|
|
hasBeenStopped.current = false |
|
|
|
hasBeenStopped.current = false |
|
|
|
readyTestsNumber = 0 |
|
|
|
readyTestsNumber = 0 |
|
|
|
setReadyTestsNumber(readyTestsNumber) |
|
|
|
setReadyTestsNumber(readyTestsNumber) |
|
|
@ -568,8 +568,8 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d |
|
|
|
|
|
|
|
|
|
|
|
const updateRunAction = async (currentFile: any = null) => { // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
const updateRunAction = async (currentFile: any = null) => { // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
const isSolidityActive = await testTab.appManager.isActive('solidity') |
|
|
|
const isSolidityActive = await testTab.appManager.isActive('solidity') |
|
|
|
if (!isSolidityActive || !selectedTests.current?.length) { |
|
|
|
if (!isSolidityActive || !selectedTests.current.length) { |
|
|
|
// setDisableRunButton(true)
|
|
|
|
setDisableRunButton(true) |
|
|
|
if (!currentFile || (currentFile && currentFile.split('.').pop().toLowerCase() !== 'sol')) { |
|
|
|
if (!currentFile || (currentFile && currentFile.split('.').pop().toLowerCase() !== 'sol')) { |
|
|
|
setRunButtonTitle('No solidity file selected') |
|
|
|
setRunButtonTitle('No solidity file selected') |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -592,7 +592,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d |
|
|
|
|
|
|
|
|
|
|
|
const toggleCheckbox = (eChecked: boolean, index: number) => { |
|
|
|
const toggleCheckbox = (eChecked: boolean, index: number) => { |
|
|
|
testFiles[index].checked = eChecked |
|
|
|
testFiles[index].checked = eChecked |
|
|
|
setTestFiles(testFiles) |
|
|
|
setTestFiles([...testFiles]) |
|
|
|
selectedTests.current = getCurrentSelectedTests() |
|
|
|
selectedTests.current = getCurrentSelectedTests() |
|
|
|
if (eChecked) { |
|
|
|
if (eChecked) { |
|
|
|
setCheckSelectAll(true) |
|
|
|
setCheckSelectAll(true) |
|
|
@ -609,7 +609,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d |
|
|
|
|
|
|
|
|
|
|
|
const checkAll = (event: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
const checkAll = (event: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
testFiles.forEach((testFileObj) => testFileObj.checked = event.target.checked) |
|
|
|
testFiles.forEach((testFileObj) => testFileObj.checked = event.target.checked) |
|
|
|
setTestFiles(testFiles) |
|
|
|
setTestFiles([...testFiles]) |
|
|
|
setCheckSelectAll(event.target.checked) |
|
|
|
setCheckSelectAll(event.target.checked) |
|
|
|
if (event.target.checked) { |
|
|
|
if (event.target.checked) { |
|
|
|
selectedTests.current = getCurrentSelectedTests() |
|
|
|
selectedTests.current = getCurrentSelectedTests() |
|
|
@ -627,7 +627,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
testFiles = [] |
|
|
|
testFiles = [] |
|
|
|
setTestFiles(testFiles) |
|
|
|
setTestFiles([...testFiles]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
@ -708,7 +708,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d |
|
|
|
/> |
|
|
|
/> |
|
|
|
<label className="text-nowrap pl-2 mb-0" htmlFor="checkAllTests"> Select all </label> |
|
|
|
<label className="text-nowrap pl-2 mb-0" htmlFor="checkAllTests"> Select all </label> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="testList py-2 mt-0 border-bottom">{testFiles?.length ? testFiles.map((testFileObj: TestObject, index) => { |
|
|
|
<div className="testList py-2 mt-0 border-bottom">{testFiles.length ? testFiles.map((testFileObj: TestObject, index) => { |
|
|
|
const elemId = `singleTest${testFileObj.fileName}` |
|
|
|
const elemId = `singleTest${testFileObj.fileName}` |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="d-flex align-items-center py-1" key={index}> |
|
|
|
<div className="d-flex align-items-center py-1" key={index}> |
|
|
|