@@ -67,14 +67,14 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
6767 let [ readyTestsNumber , setReadyTestsNumber ] = useState < number > ( 0 ) // eslint-disable-line
6868 let [ runningTestsNumber , setRunningTestsNumber ] = useState < number > ( 0 ) // eslint-disable-line
6969
70+ const areTestsRunning = useRef < boolean > ( false )
7071 const hasBeenStopped = useRef < boolean > ( false )
7172 const isDebugging = useRef < boolean > ( false )
7273 const allTests = useRef < string [ ] > ( [ ] )
7374 const selectedTests = useRef < string [ ] > ( [ ] )
7475 const currentErrors :any = useRef ( [ ] ) // eslint-disable-line @typescript-eslint/no-explicit-any
7576
7677 const defaultPath = 'tests'
77- let areTestsRunning = false
7878
7979 let runningTestFileName : string
8080 const filesContent : Record < string , Record < string , string > > = { }
@@ -113,7 +113,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
113113 allTests . current = tests
114114 selectedTests . current = [ ...allTests . current ]
115115 updateTestFileList ( )
116- if ( ! areTestsRunning ) await updateRunAction ( file )
116+ if ( ! areTestsRunning . current ) await updateRunAction ( file )
117117 } catch ( e : any ) { // eslint-disable-line @typescript-eslint/no-explicit-any
118118 console . log ( e )
119119 setToasterMsg ( e )
@@ -153,7 +153,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
153153 await setCurrentPath ( defaultPath )
154154 } )
155155
156- testTab . fileManager . events . on ( 'noFileSelected' , ( ) => { } ) // eslint-disable-line
156+ testTab . fileManager . events . on ( 'noFileSelected' , async ( ) => { await updateForNewCurrent ( ) } )
157157 testTab . fileManager . events . on ( 'currentFileChanged' , async ( file : string ) => await updateForNewCurrent ( file ) )
158158
159159 } , [ ] ) // eslint-disable-line
@@ -167,15 +167,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
167167 const handleTestDirInput = async ( e : any ) => { // eslint-disable-line @typescript-eslint/no-explicit-any
168168 let testDirInput = trimTestDirInput ( e . target . value )
169169 testDirInput = helper . removeMultipleSlashes ( testDirInput )
170- if ( testDirInput !== '/' ) testDirInput = helper . removeTrailingSlashes ( testDirInput )
171170 setInputPathValue ( testDirInput )
172- if ( e . key === 'Enter' ) {
173- if ( await testTabLogic . pathExists ( testDirInput ) ) {
174- testTabLogic . setCurrentPath ( testDirInput )
175- await updateForNewCurrent ( )
176- return
177- }
178- }
179171 if ( testDirInput ) {
180172 if ( testDirInput . endsWith ( '/' ) && testDirInput !== '/' ) {
181173 testDirInput = helper . removeTrailingSlashes ( testDirInput )
@@ -205,17 +197,6 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
205197 }
206198 }
207199
208- const handleEnter = async ( e : any ) => { // eslint-disable-line @typescript-eslint/no-explicit-any
209- let inputPath = e . target . value
210- inputPath = helper . removeMultipleSlashes ( trimTestDirInput ( inputPath ) )
211- setInputPathValue ( inputPath )
212- if ( disableCreateButton ) {
213- if ( await testTabLogic . pathExists ( inputPath ) ) {
214- await setCurrentPath ( inputPath )
215- }
216- }
217- }
218-
219200 const handleCreateFolder = async ( ) => {
220201 let inputPath = trimTestDirInput ( inputPathValue )
221202 let path = helper . removeMultipleSlashes ( inputPath )
@@ -519,7 +500,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
519500 if ( selectedTests . current ?. length !== 0 ) {
520501 setDisableRunButton ( false )
521502 }
522- areTestsRunning = false
503+ areTestsRunning . current = false
523504 }
524505 }
525506
@@ -566,7 +547,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
566547 }
567548
568549 const runTests = ( ) => {
569- areTestsRunning = true
550+ areTestsRunning . current = true
570551 hasBeenStopped . current = false
571552 readyTestsNumber = 0
572553 setReadyTestsNumber ( readyTestsNumber )
@@ -587,14 +568,14 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
587568
588569 const updateRunAction = async ( currentFile : any = null ) => { // eslint-disable-line @typescript-eslint/no-explicit-any
589570 const isSolidityActive = await testTab . appManager . isActive ( 'solidity' )
590- if ( ! isSolidityActive || ! selectedTests . current ? .length ) {
591- // setDisableRunButton(true)
571+ if ( ! isSolidityActive || ! selectedTests . current . length ) {
572+ setDisableRunButton ( true )
592573 if ( ! currentFile || ( currentFile && currentFile . split ( '.' ) . pop ( ) . toLowerCase ( ) !== 'sol' ) ) {
593574 setRunButtonTitle ( 'No solidity file selected' )
594575 } else {
595576 setRunButtonTitle ( 'The "Solidity Plugin" should be activated' )
596577 }
597- }
578+ } else setDisableRunButton ( false )
598579 }
599580
600581 const stopTests = ( ) => {
@@ -611,7 +592,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
611592
612593 const toggleCheckbox = ( eChecked : boolean , index : number ) => {
613594 testFiles [ index ] . checked = eChecked
614- setTestFiles ( testFiles )
595+ setTestFiles ( [ ... testFiles ] )
615596 selectedTests . current = getCurrentSelectedTests ( )
616597 if ( eChecked ) {
617598 setCheckSelectAll ( true )
@@ -628,7 +609,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
628609
629610 const checkAll = ( event : any ) => { // eslint-disable-line @typescript-eslint/no-explicit-any
630611 testFiles . forEach ( ( testFileObj ) => testFileObj . checked = event . target . checked )
631- setTestFiles ( testFiles )
612+ setTestFiles ( [ ... testFiles ] )
632613 setCheckSelectAll ( event . target . checked )
633614 if ( event . target . checked ) {
634615 selectedTests . current = getCurrentSelectedTests ( )
@@ -646,7 +627,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
646627 }
647628 else
648629 testFiles = [ ]
649- setTestFiles ( testFiles )
630+ setTestFiles ( [ ... testFiles ] )
650631 }
651632
652633 return (
@@ -674,8 +655,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
674655 title = "Press 'Enter' to change the path for test files."
675656 style = { { backgroundImage : "var(--primary)" } }
676657 onKeyDown = { ( ) => { if ( inputPathValue === '/' ) setInputPathValue ( '' ) } }
677- onKeyUp = { handleTestDirInput }
678- onChange = { handleEnter }
658+ onChange = { handleTestDirInput }
679659 onClick = { ( ) => { if ( inputPathValue === '/' ) setInputPathValue ( '' ) } }
680660 />
681661 < button
@@ -728,7 +708,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
728708 />
729709 < label className = "text-nowrap pl-2 mb-0" htmlFor = "checkAllTests" > Select all </ label >
730710 </ div >
731- < div className = "testList py-2 mt-0 border-bottom" > { testFiles ? .length ? testFiles . map ( ( testFileObj : TestObject , index ) => {
711+ < div className = "testList py-2 mt-0 border-bottom" > { testFiles . length ? testFiles . map ( ( testFileObj : TestObject , index ) => {
732712 const elemId = `singleTest${ testFileObj . fileName } `
733713 return (
734714 < div className = "d-flex align-items-center py-1" key = { index } >
0 commit comments