diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 58de45c173..7a103c012b 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -72,7 +72,7 @@ module.exports = class TestTab extends ViewPlugin { this.data.allTests = tests this.data.selectedTests = [...this.data.allTests] this.updateTestFileList(tests) - if (!this.testsOutput || !this.testsSummary) return + if (!this.testsOutput) return }) } @@ -125,28 +125,17 @@ module.exports = class TestTab extends ViewPlugin { } testCallback (result) { - const hasFailingLabel = document.querySelector(`.failed_${this.runningTestFileName}`) - const hasPassingLabel = document.querySelector(`.passed_${this.runningTestFileName}`) - this.testsOutput.hidden = false if (result.type === 'contract') { - this.runningTestFileName = this.cleanFileName(result.filename) - this.outputHeader = yo`
${result.value}
${result.filename}
` + this.testSuite = result.value + this.rawFileName = result.filename + this.runningTestFileName = this.cleanFileName(this.rawFileName) + this.outputHeader = yo`
${this.testSuite}
${this.rawFileName}
` this.testsOutput.appendChild(this.outputHeader) } else if (result.type === 'testPass') { this.testsOutput.appendChild(yo`
✓ ${result.value}
`) - if(!hasFailingLabel && !hasPassingLabel) { - const label = yo`PASS` - - this.outputHeader && yo.update(this.outputHeader, yo`
${label} ${result.context}
${result.filename}
`) - } } else if (result.type === 'testFailure') { this.testsOutput.appendChild(yo`
✘ ${result.value}
`) - if(!hasFailingLabel) { - const label = yo`FAIL` - - this.outputHeader && yo.update(this.outputHeader, yo`
${label} ${result.context}
${result.filename}
`) - } } } @@ -155,7 +144,6 @@ module.exports = class TestTab extends ViewPlugin { // result.passingNum // result.failureNum // result.timePassed - this.testsSummary.hidden = false if (!_err) { this.testsOutput } @@ -166,32 +154,47 @@ module.exports = class TestTab extends ViewPlugin { return fileName ? fileName.replace(/\//g, '_').replace(/\./g, '_') : fileName } + updateHeader (status) { + if (status) { + const label = yo`PASS` + + this.outputHeader && yo.update(this.outputHeader, yo`
${label} ${this.testSuite}
${this.rawFileName}
`) + } else { + const label = yo`FAIL` + + this.outputHeader && yo.update(this.outputHeader, yo`
${label} ${this.testSuite}
${this.rawFileName}
`) + } + } + updateFinalResult (_errors, result, filename) { - this.testsSummary.hidden = false ++this.readyTestsNumber if (_errors && _errors.errors) { - _errors.errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsSummary, {type: err.severity})) + _errors.errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsOutput, {type: err.severity})) + this.updateHeader(false) } else if (_errors && Array.isArray(_errors) && (_errors[0].message || _errors[0].formattedMessage)) { - _errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsSummary, {type: err.severity})) + _errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsOutput, {type: err.severity})) + this.updateHeader(false) } else if (_errors && !_errors.errors && !Array.isArray(_errors)) { // To track error like this: https://github.com/ethereum/remix/pull/1438 - this.renderer.error(_errors.formattedMessage || _errors.message, this.testsSummary, {type: 'error'}) + this.renderer.error(_errors.formattedMessage || _errors.message, this.testsOutput, {type: 'error'}) + this.updateHeader(false) } - this.testsSummary.appendChild(yo`
${filename}
`) yo.update(this.resultStatistics, this.createResultLabel()) if (result) { - if (result.totalPassing > 0) { - this.testsSummary.appendChild(yo`
${result.totalPassing} passing (${result.totalTime}s)
`) - this.testsSummary.appendChild(yo`
`) - } - if (result.totalFailing > 0) { - this.testsSummary.appendChild(yo`
${result.totalFailing} failing
`) - this.testsSummary.appendChild(yo`
`) + if (result.totalPassing > 0 && result.totalFailing > 0) { + this.testsOutput.appendChild(yo`
${result.totalPassing} passing, ${result.totalFailing} failing (${result.totalTime}s)
`) + this.updateHeader(false) + } else if (result.totalPassing > 0 && result.totalFailing <= 0) { + this.testsOutput.appendChild(yo`
${result.totalPassing} passing (${result.totalTime}s)
`) + this.updateHeader(true) + } else if (result.totalPassing <= 0 && result.totalFailing > 0) { + this.testsOutput.appendChild(yo`
${result.totalFailing} failing
`) + this.updateHeader(false) } result.errors.forEach((error, index) => { - this.testsSummary.appendChild(yo`
${error.context} - ${error.value}
`) - this.testsSummary.appendChild(yo`
${error.message}
`) - this.testsSummary.appendChild(yo`
`) + this.testsOutput.appendChild(yo``) + this.testsOutput.appendChild(yo`
Error:
${error.message}
`) + this.testsOutput.appendChild(yo`
`) }) } if (this.hasBeenStopped && (this.readyTestsNumber !== this.runningTestsNumber)) { @@ -210,13 +213,6 @@ module.exports = class TestTab extends ViewPlugin { } this.areTestsRunning = false } - result.errors.forEach((error, index) => { - this.testsOutput.appendChild(yo`
${result.filename} (${result.value})
`) - this.testsOutput.appendChild(yo`
✘ ${result.value}
`) - this.testsSummary.appendChild(yo`
${error.context} - ${error.value}
`) - this.testsSummary.appendChild(yo`
${error.message}
`) - this.testsSummary.appendChild(yo`
`) - }) } async testFromPath (path) { @@ -295,8 +291,6 @@ module.exports = class TestTab extends ViewPlugin { this.call('editor', 'clearAnnotations') this.testsOutput.innerHTML = '' this.testsOutput.hidden = true - this.testsSummary.innerHTML = '' - this.testsSummary.hidden = true this.testsExecutionStopped.hidden = true const tests = this.data.selectedTests if (!tests) return @@ -416,9 +410,8 @@ module.exports = class TestTab extends ViewPlugin { render () { this.onActivationInternal() - this.testsOutput = yo` `