From f5ee5b59457de87dc8d3fc40d7481e4923f3930e Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 28 Apr 2020 03:35:57 +0000 Subject: [PATCH] Fixed display of label for multiple test suites and removed output box for passing tests --- src/app/tabs/test-tab.js | 52 +++++++++++++++++++++++++----------- test-browser/helpers/init.js | 2 +- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index a8daddc495..9cca1a4938 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -128,9 +128,14 @@ module.exports = class TestTab extends ViewPlugin { this.testsOutput.hidden = false if (result.type === 'contract') { this.testSuite = result.value + if (this.testSuites) { + this.testSuites.push(this.testSuite) + } else { + this.testSuites = [this.testSuite] + } this.rawFileName = result.filename - this.runningTestFileName = this.cleanFileName(this.rawFileName) - this.outputHeader = yo`
${this.testSuite}
${this.rawFileName}
` + this.runningTestFileName = this.cleanFileName(this.rawFileName, this.testSuite) + this.outputHeader = yo`
${this.testSuite}
${this.rawFileName}
` this.testsOutput.appendChild(this.outputHeader) } else if (result.type === 'testPass') { this.testsOutput.appendChild(yo`
✓ ${result.value}
`) @@ -150,19 +155,19 @@ module.exports = class TestTab extends ViewPlugin { cb() } - cleanFileName (fileName) { - return fileName ? fileName.replace(/\//g, '_').replace(/\./g, '_') : fileName + cleanFileName (fileName, testSuite) { + return fileName ? fileName.replace(/\//g, '_').replace(/\./g, '_') + testSuite : fileName } setHeader (status) { if (status) { const label = yo`
PASS
` - this.outputHeader && yo.update(this.outputHeader, yo`
${label} ${this.testSuite}
${this.rawFileName}
`) + 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}
`) + this.outputHeader && yo.update(this.outputHeader, yo`
${label} ${this.testSuite}
${this.rawFileName}
`) } } @@ -185,23 +190,40 @@ module.exports = class TestTab extends ViewPlugin { if (result) { if (result.totalPassing > 0 && result.totalFailing > 0) { this.testsOutput.appendChild(yo`
${result.totalPassing} passing, ${result.totalFailing} failing (${result.totalTime}s)
`) - if (this.rawFileName === filename) this.setHeader(false) } else if (result.totalPassing > 0 && result.totalFailing <= 0) { this.testsOutput.appendChild(yo`
${result.totalPassing} passing (${result.totalTime}s)
`) - if (this.rawFileName === filename) this.setHeader(true) } else if (result.totalPassing <= 0 && result.totalFailing > 0) { this.testsOutput.appendChild(yo`
${result.totalFailing} failing
`) - if (this.rawFileName === filename) this.setHeader(false) } + //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) + }) const displayError = yo`
` result.errors.forEach((error, index) => { - displayError.appendChild(yo`
- - ${error.message} -
`) + 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) + displayError.appendChild(yo` +
+ + ${error.message} +
+ `) }) - this.testsOutput.appendChild(displayError) + if (result.errors && result.errors.length > 0) { + this.testsOutput.appendChild(displayError) + } + this.testsOutput.appendChild(yo`

`) } if (this.hasBeenStopped && (this.readyTestsNumber !== this.runningTestsNumber)) { // if all tests has been through before stopping no need to print this. @@ -416,7 +438,7 @@ module.exports = class TestTab extends ViewPlugin { render () { this.onActivationInternal() - this.testsOutput = yo`