@ -2,6 +2,7 @@ import React, { useState, useRef, useEffect, ReactElement } from 'react' // esli
import * as semver from 'semver'
import * as semver from 'semver'
import { eachOfSeries } from 'async' // eslint-disable-line
import { eachOfSeries } from 'async' // eslint-disable-line
import type Web3 from 'web3'
import type Web3 from 'web3'
import { OverlayTrigger , Tooltip } from 'react-bootstrap'
import { canUseWorker , urlFromVersion } from '@remix-project/remix-solidity'
import { canUseWorker , urlFromVersion } from '@remix-project/remix-solidity'
import { Renderer } from '@remix-ui/renderer' // eslint-disable-line
import { Renderer } from '@remix-ui/renderer' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
@ -296,20 +297,26 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
let label
let label
if ( index > - 1 ) {
if ( index > - 1 ) {
const className = "alert-danger d-inline-block mb-1 mr-1 p-1 failed_" + runningTestFileName
const className = "alert-danger d-inline-block mb-1 mr-1 p-1 failed_" + runningTestFileName
label = ( < div
label = ( < OverlayTrigger placement = { 'right' } overlay = {
< Tooltip className = "text-nowrap" id = "info-recorder" >
< span > At least one contract test failed < / span >
< / Tooltip >
} > < div
className = { className }
className = { className }
title = "At least one contract test failed"
>
>
FAIL
FAIL
< / div > )
< / div > < / OverlayTrigger > )
} else {
} else {
const className = "alert-success d-inline-block mb-1 mr-1 p-1 passed_" + runningTestFileName
const className = "alert-success d-inline-block mb-1 mr-1 p-1 passed_" + runningTestFileName
label = ( < div
label = ( < OverlayTrigger placement = { 'top-end' } overlay = {
< Tooltip className = "text-nowrap" id = "info-recorder" >
< span > All contract tests passed < / span >
< / Tooltip >
} > < div
className = { className }
className = { className }
title = "All contract tests passed"
>
>
PASS
PASS
< / div > )
< / div > < / OverlayTrigger > )
}
}
// show contract and file name with label
// show contract and file name with label
const ContractCard : ReactElement = (
const ContractCard : ReactElement = (
@ -335,8 +342,12 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
if ( test . debugTxHash ) {
if ( test . debugTxHash ) {
const { web3 , debugTxHash } = test
const { web3 , debugTxHash } = test
debugBtn = (
debugBtn = (
< div id = { test . value . replaceAll ( ' ' , '_' ) } className = "btn border btn btn-sm ml-1" style = { { cursor : 'pointer' } } title = "Start debugging" onClick = { ( ) = > startDebug ( debugTxHash , web3 ) } >
< div id = { test . value . replaceAll ( ' ' , '_' ) } className = "btn border btn btn-sm ml-1" style = { { cursor : 'pointer' } } onClick = { ( ) = > startDebug ( debugTxHash , web3 ) } >
< i className = "fas fa-bug" > < / i >
< OverlayTrigger placement = { 'top-start' } overlay = {
< Tooltip className = "text-nowrap" id = "info-recorder" >
< span > Start debugging < / span >
< / Tooltip >
} > < i className = "fas fa-bug" > < / i > < / OverlayTrigger >
< / div >
< / div >
)
)
}
}
@ -663,6 +674,14 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
} )
} )
}
}
< / datalist >
< / datalist >
< OverlayTrigger
placement = "top-end"
overlay = {
< Tooltip className = "text-nowrap" id = "uiPathInputtooltip" >
< span > { "Press 'Enter' to change the path for test files." } < / span >
< / Tooltip >
}
>
< input
< input
list = "utPathList"
list = "utPathList"
className = "inputFolder custom-select"
className = "inputFolder custom-select"
@ -670,30 +689,42 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
data - id = "uiPathInput"
data - id = "uiPathInput"
name = "utPath"
name = "utPath"
value = { inputPathValue }
value = { inputPathValue }
title = "Press 'Enter' to change the path for test files."
style = { { backgroundImage : "var(--primary)" } }
style = { { backgroundImage : "var(--primary)" } }
onKeyDown = { ( ) = > { if ( inputPathValue === '/' ) setInputPathValue ( '' ) } }
onKeyDown = { ( ) = > { if ( inputPathValue === '/' ) setInputPathValue ( '' ) } }
onChange = { handleTestDirInput }
onChange = { handleTestDirInput }
onClick = { ( ) = > { if ( inputPathValue === '/' ) setInputPathValue ( '' ) } }
onClick = { ( ) = > { if ( inputPathValue === '/' ) setInputPathValue ( '' ) } }
/ >
/ >
< / OverlayTrigger >
< OverlayTrigger
placement = "top-end"
overlay = {
< Tooltip className = "text-nowrap" id = "uiPathInputButtontooltip" >
< span > Create a test folder < / span >
< / Tooltip >
}
>
< button
< button
className = "btn border ml-2"
className = "btn border ml-2"
data - id = "testTabGenerateTestFolder"
data - id = "testTabGenerateTestFolder"
title = "Create a test folder"
disabled = { disableCreateButton }
disabled = { disableCreateButton }
onClick = { handleCreateFolder }
onClick = { handleCreateFolder }
>
>
Create
Create
< / button >
< / button >
< / OverlayTrigger >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< div >
< div >
< div className = "d-flex p-2" >
< div className = "d-flex p-2" >
< OverlayTrigger overlay = {
< Tooltip id = "generateTestsButtontooltip" className = "text-nowrap" >
< span > Generate a sample test file < / span >
< / Tooltip >
} placement = { 'bottom-start' } >
< button
< button
className = "btn border w-50"
className = "btn border w-50"
data - id = "testTabGenerateTestFile"
data - id = "testTabGenerateTestFile"
title = "Generate a sample test file"
disabled = { disableGenerateButton }
disabled = { disableGenerateButton }
onClick = { async ( ) = > {
onClick = { async ( ) = > {
await testTabLogic . generateTestFile ( ( err :any ) = > { if ( err ) setToasterMsg ( err ) } ) // eslint-disable-line @typescript-eslint/no-explicit-any
await testTabLogic . generateTestFile ( ( err :any ) = > { if ( err ) setToasterMsg ( err ) } ) // eslint-disable-line @typescript-eslint/no-explicit-any
@ -702,18 +733,43 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
>
>
Generate
Generate
< / button >
< / button >
< a className = "btn border text-decoration-none pr-0 d-flex w-50 ml-2" title = "Check out documentation." target = "__blank" href = "https://remix-ide.readthedocs.io/en/latest/unittesting.html#test-directory" >
< / OverlayTrigger >
< OverlayTrigger overlay = {
< Tooltip id = "generateTestsLinktooltip" className = "text-nowrap" >
< span > Check out documentation . < / span >
< / Tooltip >
} placement = { 'bottom-start' } >
< a className = "btn border text-decoration-none pr-0 d-flex w-50 ml-2" target = "__blank" href = "https://remix-ide.readthedocs.io/en/latest/unittesting.html#test-directory" >
< label className = "btn p-1 ml-2 m-0" > How to use . . . < / label >
< label className = "btn p-1 ml-2 m-0" > How to use . . . < / label >
< / a >
< / a >
< / OverlayTrigger >
< / div >
< / div >
< div className = "d-flex p-2" >
< div className = "d-flex p-2" >
< button id = "runTestsTabRunAction" title = { runButtonTitle } data - id = "testTabRunTestsTabRunAction" className = "w-50 btn btn-primary" disabled = { disableRunButton } onClick = { runTests } >
< OverlayTrigger placement = { 'top-start' } overlay = {
< Tooltip className = "text-nowrap" id = "info-recorder" >
< span >
{ runButtonTitle }
< / span >
< / Tooltip >
} >
< button id = "runTestsTabRunAction" data - id = "testTabRunTestsTabRunAction" className = "w-50 btn btn-primary" disabled = { disableRunButton } onClick = { runTests } >
< span className = "fas fa-play ml-2" > < / span >
< span className = "fas fa-play ml-2" > < / span >
< label className = "labelOnBtn btn btn-primary p-1 ml-2 m-0" > Run < / label >
< label className = "labelOnBtn btn btn-primary p-1 ml-2 m-0" > Run < / label >
< / button >
< / button >
< button id = "runTestsTabStopAction" data - id = "testTabRunTestsTabStopAction" className = "w-50 pl-2 ml-2 btn btn-secondary" disabled = { disableStopButton } title = "Stop running tests" onClick = { stopTests } >
< / OverlayTrigger >
< button id = "runTestsTabStopAction" data - id = "testTabRunTestsTabStopAction" className = "w-50 pl-2 ml-2 btn btn-secondary" disabled = { disableStopButton } onClick = { stopTests } >
< OverlayTrigger placement = { 'top-start' } overlay = {
< Tooltip className = "text-nowrap" id = "info-recorder" >
< span >
Stop running tests
< / span >
< / Tooltip >
} >
< span >
< span className = "fas fa-stop ml-2" > < / span >
< span className = "fas fa-stop ml-2" > < / span >
< label className = "labelOnBtn btn btn-secondary p-1 ml-2 m-0" id = "runTestsTabStopActionLabel" > { stopButtonLabel } < / label >
< label className = "labelOnBtn btn btn-secondary p-1 ml-2 m-0" id = "runTestsTabStopActionLabel" > { stopButtonLabel } < / label >
< / span >
< / OverlayTrigger >
< / button >
< / button >
< / div >
< / div >
< div className = "d-flex align-items-center mx-3 pb-2 mt-2 border-bottom" >
< div className = "d-flex align-items-center mx-3 pb-2 mt-2 border-bottom" >
@ -730,7 +786,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
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 } >
< input className = "singleTest" id = { elemId } onChange = { ( e ) = > toggleCheckbox ( e . target . checked , index ) } type = "checkbox" checked = { testFileObj . checked } / >
< input data - id = "singleTest" className = "singleTest" id = { elemId } onChange = { ( e ) = > toggleCheckbox ( e . target . checked , index ) } type = "checkbox" checked = { testFileObj . checked } / >
< label className = "singleTestLabel text-nowrap pl-2 mb-0" htmlFor = { elemId } > { testFileObj . fileName } < / label >
< label className = "singleTestLabel text-nowrap pl-2 mb-0" htmlFor = { elemId } > { testFileObj . fileName } < / label >
< / div >
< / div >
)
)