From 1141577cf1b1423c5030cdf56d3b5c65657d3489 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 4 Jan 2022 18:20:33 +0530 Subject: [PATCH] types in SUT component --- .../solidity-unit-testing/.eslintrc.json | 3 - .../src/lib/solidity-unit-testing.tsx | 58 ++++++++++--------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/libs/remix-ui/solidity-unit-testing/.eslintrc.json b/libs/remix-ui/solidity-unit-testing/.eslintrc.json index 5e100bf955..50e59482cf 100644 --- a/libs/remix-ui/solidity-unit-testing/.eslintrc.json +++ b/libs/remix-ui/solidity-unit-testing/.eslintrc.json @@ -1,9 +1,6 @@ { "extends": ["plugin:@nrwl/nx/react", "../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], - "rules": { - "@typescript-eslint/no-explicit-any": "off" - }, "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index 0e791fd0ec..1c71951f42 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -21,42 +21,42 @@ export const SolidityUnitTesting = (props: Record) => { const { helper, testTab, initialPath } = props const { testTabLogic } = testTab - const [toasterMsg, setToasterMsg] = useState('') + const [toasterMsg, setToasterMsg] = useState('') - const [disableCreateButton, setDisableCreateButton] = useState(true) - const [disableGenerateButton, setDisableGenerateButton] = useState(false) - const [disableStopButton, setDisableStopButton] = useState(true) - const [disableRunButton, setDisableRunButton] = useState(false) - const [runButtonTitle, setRunButtonTitle] = useState('Run tests') - const [stopButtonLabel, setStopButtonLabel] = useState('Stop') + const [disableCreateButton, setDisableCreateButton] = useState(true) + const [disableGenerateButton, setDisableGenerateButton] = useState(false) + const [disableStopButton, setDisableStopButton] = useState(true) + const [disableRunButton, setDisableRunButton] = useState(false) + const [runButtonTitle, setRunButtonTitle] = useState('Run tests') + const [stopButtonLabel, setStopButtonLabel] = useState('Stop') - const [checkSelectAll, setCheckSelectAll] = useState(true) + const [checkSelectAll, setCheckSelectAll] = useState(true) const [testsOutput, setTestsOutput] = useState([]) - const [testsExecutionStoppedHidden, setTestsExecutionStoppedHidden] = useState(true) - const [progressBarHidden, setProgressBarHidden] = useState(true) - const [testsExecutionStoppedErrorHidden, setTestsExecutionStoppedErrorHidden] = useState(true) + const [testsExecutionStoppedHidden, setTestsExecutionStoppedHidden] = useState(true) + const [progressBarHidden, setProgressBarHidden] = useState(true) + const [testsExecutionStoppedErrorHidden, setTestsExecutionStoppedErrorHidden] = useState(true) let [testFiles, setTestFiles] = useState([]) // eslint-disable-line - const [pathOptions, setPathOptions] = useState(['']) + const [pathOptions, setPathOptions] = useState(['']) - const [inputPathValue, setInputPathValue] = useState('tests') + const [inputPathValue, setInputPathValue] = useState('tests') - let [readyTestsNumber, setReadyTestsNumber] = useState(0) // eslint-disable-line - let [runningTestsNumber, setRunningTestsNumber] = useState(0) // eslint-disable-line + let [readyTestsNumber, setReadyTestsNumber] = useState(0) // eslint-disable-line + let [runningTestsNumber, setRunningTestsNumber] = useState(0) // eslint-disable-line - const hasBeenStopped = useRef(false) - const isDebugging = useRef(false) - const allTests: any = useRef([]) - const selectedTests: any = useRef([]) - const currentErrors: any = useRef([]) + const hasBeenStopped = useRef(false) + const isDebugging = useRef(false) + const allTests = useRef([]) + const selectedTests = useRef([]) + const currentErrors:any = useRef([]) const defaultPath = 'tests' let areTestsRunning = false - let runningTestFileName: any - const filesContent: any = {} - const testsResultByFilename: Record = {} + let runningTestFileName: string + const filesContent: Record> = {} + const testsResultByFilename: Record>> = {} const trimTestDirInput = (input: string) => { if (input.includes('/')) return input.split('/').map(e => e.trim()).join('/') @@ -71,7 +71,7 @@ export const SolidityUnitTesting = (props: Record) => { setTestsExecutionStoppedErrorHidden(true) } - const updateForNewCurrent = async (file = null) => { + const updateForNewCurrent = async (file: string | null = null) => { // Ensure that when someone clicks on compilation error and that opens a new file // Test result, which is compilation error in this case, is not cleared if (currentErrors.current) { @@ -90,6 +90,8 @@ export const SolidityUnitTesting = (props: Record) => { const tests = await testTabLogic.getTests() allTests.current = tests selectedTests.current = [...allTests.current] + console.log('allTests----->', allTests.current) + console.log('selectedTests----->', selectedTests.current) updateTestFileList() if (!areTestsRunning) await updateRunAction(file) } catch (e: any) { @@ -132,12 +134,13 @@ export const SolidityUnitTesting = (props: Record) => { }) testTab.fileManager.events.on('noFileSelected', () => { }) // eslint-disable-line - testTab.fileManager.events.on('currentFileChanged', async (file: any, provider: any) => await updateForNewCurrent(file)) + testTab.fileManager.events.on('currentFileChanged', async (file: string, provider: any) => await updateForNewCurrent(file)) }, []) // eslint-disable-line const updateDirList = (path: string) => { testTabLogic.dirList(path).then((options: any) => { + console.log('options in testDir List--->', options) setPathOptions(options) }) } @@ -214,7 +217,7 @@ export const SolidityUnitTesting = (props: Record) => { return fileName ? fileName.replace(/\//g, '_').replace(/\./g, '_') + testSuite : fileName } - const startDebug = async (txHash: any, web3: any) => { + const startDebug = async (txHash: string, web3: any) => { isDebugging.current = true if (!await testTab.appManager.isActive('debugger')) await testTab.appManager.activatePlugin('debugger') testTab.call('menuicons', 'select', 'debugger') @@ -223,6 +226,7 @@ export const SolidityUnitTesting = (props: Record) => { const printHHLogs = (logsArr: any, testName: any) => { let finalLogs = `${testName}:\n` + console.log('logsArr======>', logsArr) for (const log of logsArr) { let formattedLog // Hardhat implements the same formatting options that can be found in Node.js' console.log, @@ -262,7 +266,7 @@ export const SolidityUnitTesting = (props: Record) => { } } - const renderContract = (filename: any, contract: any, index: number, withoutLabel = false) => { + const renderContract = (filename: string, contract: string|null, index: number, withoutLabel = false) => { if (withoutLabel) { const contractCard: any = (