From 3f03a10469bf3cba0530c7ea772d2b45e12b9daf Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 6 Dec 2021 14:01:10 +0530 Subject: [PATCH] tests Summary --- .../src/lib/solidity-unit-testing.tsx | 119 ++++++++++-------- 1 file changed, 68 insertions(+), 51 deletions(-) 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 2c57d3fcfe..977bd6d17e 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 @@ -14,6 +14,13 @@ interface TestObject { checked: boolean } +interface TestSummary { + filename: string + passed: number + failed: number + timeTaken: any +} + export const SolidityUnitTesting = (props: any) => { const {helper, testTab} = props @@ -30,6 +37,8 @@ export const SolidityUnitTesting = (props: any) => { const [checkSelectAll, setCheckSelectAll] = useState(true) const [testsOutput, setTestsOutput] = useState([]) + let [testsSummary, setTestsSummary] = useState() + const [testsSummaryHidden, setTestsSummaryHidden] = useState(true) const [testsExecutionStoppedHidden, setTestsExecutionStoppedHidden] = useState(true) const [testsExecutionStoppedErrorHidden, setTestsExecutionStoppedErrorHidden] = useState(true) @@ -335,8 +344,8 @@ export const SolidityUnitTesting = (props: any) => { const updateFinalResult = (_errors: any, result: any, filename: any) => { console.log('result---in updateFinalResult->', result, filename) - // ++this.readyTestsNumber - // this.testsOutput.hidden = false + ++readyTestsNumber + setTestsSummaryHidden(false) // if (!result && (_errors && (_errors.errors || (Array.isArray(_errors) && (_errors[0].message || _errors[0].formattedMessage))))) { // this.testCallback({ type: 'contract', filename }) // this.currentErrors = _errors.errors @@ -351,55 +360,57 @@ export const SolidityUnitTesting = (props: any) => { // this.renderer.error(_errors.formattedMessage || _errors.message, this.testsOutput, { type: 'error' }) // } // yo.update(this.resultStatistics, this.createResultLabel()) - // if (result) { - // const totalTime = parseFloat(result.totalTime).toFixed(2) - - // if (result.totalPassing > 0 && result.totalFailing > 0) { - // this.testsOutput.appendChild(yo` - //
- // Result for ${filename} - // Passing: ${result.totalPassing} - // Failing: ${result.totalFailing} - // Total time: ${totalTime}s - //
- // `) - // } else if (result.totalPassing > 0 && result.totalFailing <= 0) { - // this.testsOutput.appendChild(yo` - //
- // Result for ${filename} - // Passing: ${result.totalPassing} - // Total time: ${totalTime}s - //
- // `) - // } else if (result.totalPassing <= 0 && result.totalFailing > 0) { - // this.testsOutput.appendChild(yo` - //
- // Result for ${filename} - // Failing: ${result.totalFailing} - // Total time: ${totalTime}s - //
- // `) - // } - // // fix for displaying right label for multiple tests (testsuites) in a single file - // this.testSuites.forEach(testSuite => { - // this.testSuite = testSuite - // this.runningTestFileName = this.cleanFileName(filename, this.testSuite) - // this.outputHeader = document.querySelector(`#${this.runningTestFileName}`) - // this.setHeader(true) - // }) - - // result.errors.forEach((error, index) => { - // this.testSuite = error.context - // this.runningTestFileName = this.cleanFileName(filename, error.context) - // this.outputHeader = document.querySelector(`#${this.runningTestFileName}`) - // const isFailingLabel = document.querySelector(`.failed_${this.runningTestFileName}`) - // if (!isFailingLabel) this.setHeader(false) - // }) - // this.testsOutput.appendChild(yo` - //
- //

- //
- // `) + if (result) { + const totalTime = parseFloat(result.totalTime).toFixed(2) + testsSummary = { filename, passed: result.totalPassing, failed: result.totalFailing, timeTaken: totalTime } + setTestsSummary(testsSummary) + + // if (result.totalPassing > 0 && result.totalFailing > 0) { + // this.testsOutput.appendChild(yo` + //
+ // Result for ${filename} + // Passing: ${result.totalPassing} + // Failing: ${result.totalFailing} + // Total time: ${totalTime}s + //
+ // `) + // } else if (result.totalPassing > 0 && result.totalFailing <= 0) { + // this.testsOutput.appendChild(yo` + //
+ // Result for ${filename} + // Passing: ${result.totalPassing} + // Total time: ${totalTime}s + //
+ // `) + // } else if (result.totalPassing <= 0 && result.totalFailing > 0) { + // this.testsOutput.appendChild(yo` + //
+ // Result for ${filename} + // Failing: ${result.totalFailing} + // Total time: ${totalTime}s + //
+ // `) + } + // fix for displaying right label for multiple tests (testsuites) in a single file + // this.testSuites.forEach(testSuite => { + // this.testSuite = testSuite + // this.runningTestFileName = this.cleanFileName(filename, this.testSuite) + // this.outputHeader = document.querySelector(`#${this.runningTestFileName}`) + // this.setHeader(true) + // }) + + // result.errors.forEach((error, index) => { + // this.testSuite = error.context + // this.runningTestFileName = this.cleanFileName(filename, error.context) + // this.outputHeader = document.querySelector(`#${this.runningTestFileName}`) + // const isFailingLabel = document.querySelector(`.failed_${this.runningTestFileName}`) + // if (!isFailingLabel) this.setHeader(false) + // }) + // this.testsOutput.appendChild(yo` + //
+ //

+ //
+ // `) // } // if (this.hasBeenStopped && (this.readyTestsNumber !== this.runningTestsNumber)) { // // if all tests has been through before stopping no need to print this. @@ -656,6 +667,12 @@ export const SolidityUnitTesting = (props: any) => {
{testsOutput}
+ )