From 47e3567682c6fa0e8f5f5325a8790bc1c31c8ed0 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 21 Apr 2020 20:34:37 +0200 Subject: [PATCH] added progress for results --- src/app/tabs/test-tab.js | 51 ++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 0838d18f51..d7a905ef31 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -148,6 +148,8 @@ module.exports = class TestTab extends ViewPlugin { this.testsSummary.appendChild(yo`
${filename}
`) if (result) { + ++this.readyTestsNumber + yo.update(this.resultStatistics, this.createResultLabel()) if (result.totalPassing > 0) { this.testsSummary.appendChild(yo`
${result.totalPassing} passing (${result.totalTime}s)
`) this.testsSummary.appendChild(yo`
`) @@ -163,15 +165,17 @@ module.exports = class TestTab extends ViewPlugin { }) } if (this.hasBeenStopped) { - this.testsSummary.appendChild(yo``) + this.testsExecutionStopped.hidden = false + } + if (this.hasBeenStopped || this.readyTestsNumber === this.data.selectedTests.length) { + // All tests are ready or the operation has been canceled + const stopBtn = document.getElementById('runTestsTabStopAction') + stopBtn.setAttribute('disabled', 'disabled') + const stopBtnLabel = document.getElementById('runTestsTabStopActionLabel') + stopBtnLabel.innerText = 'Stop' + const runBtn = document.getElementById('runTestsTabRunAction') + runBtn.removeAttribute('disabled') } - - const stopBtn = document.getElementById('runTestsTabStopAction') - const stopBtnLabel = document.getElementById('runTestsTabStopActionLabel') - stopBtnLabel.innerText = 'Stop' - stopBtn.setAttribute('disabled', 'disabled') - const runBtn = document.getElementById('runTestsTabRunAction') - runBtn.removeAttribute('disabled') } async testFromPath (path) { @@ -208,7 +212,7 @@ module.exports = class TestTab extends ViewPlugin { this.updateFinalResult() return } - this.loading.hidden = false + this.resultStatistics.hidden = false this.fileManager.getFile(testFilePath).then((content) => { const runningTest = {} runningTest[testFilePath] = { content } @@ -227,7 +231,6 @@ module.exports = class TestTab extends ViewPlugin { (_err, result, cb) => this.resultsCallback(_err, result, cb), (error, result) => { this.updateFinalResult(error, result, testFilePath) - this.loading.hidden = true callback(error) }, (url, cb) => { return this.compileTab.compileTabLogic.importFileCb(url, cb) @@ -240,6 +243,8 @@ module.exports = class TestTab extends ViewPlugin { runTests () { this.hasBeenStopped = false + this.readyTestsNumber = 0 + yo.update(this.resultStatistics, this.createResultLabel()) const stopBtn = document.getElementById('runTestsTabStopAction') stopBtn.removeAttribute('disabled') const runBtn = document.getElementById('runTestsTabRunAction') @@ -247,10 +252,14 @@ module.exports = class TestTab extends ViewPlugin { this.call('editor', 'clearAnnotations') this.testsOutput.innerHTML = '' this.testsSummary.innerHTML = '' + this.testsExecutionStopped.hidden = true const tests = this.data.selectedTests if (!tests) return - this.loading.hidden = tests.length === 0 - async.eachOfSeries(tests, (value, key, callback) => { if (this.hasBeenStopped) return; this.runTest(value, callback) }) + this.resultStatistics.hidden = tests.length === 0 + async.eachOfSeries(tests, (value, key, callback) => { + if (this.hasBeenStopped) return + this.runTest(value, callback) + }) } stopTests () { @@ -353,12 +362,21 @@ module.exports = class TestTab extends ViewPlugin { ` } + + createResultLabel () { + if (!this.data.selectedTests) return yo`` + const ready = this.readyTestsNumber ? `${this.readyTestsNumber}` : '0' + return yo`Progress: ${ready} finished (out of ${this.data.selectedTests.length})` + } + render () { this.onActivationInternal() this.testsOutput = yo`