From 59e5b80837303c0651c910453aaee2d7de7f80ba Mon Sep 17 00:00:00 2001 From: pissang Date: Thu, 29 Apr 2021 22:12:51 +0800 Subject: [PATCH] chore(visual): optimize running status --- test/runTest/client/client.js | 14 +++++++++++++- test/runTest/client/index.html | 2 +- test/runTest/server.js | 30 ++++++++++++++++++------------ test/runTest/store.js | 4 ++++ 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/test/runTest/client/client.js b/test/runTest/client/client.js index 016d84781..46a9505b4 100644 --- a/test/runTest/client/client.js +++ b/test/runTest/client/client.js @@ -423,7 +423,19 @@ function updateUrl(notRefresh) { history.pushState({}, '', location.pathname + '?' + searchUrl); } else { - window.location.search = '?' + searchUrl; + if (app.running) { + app.$confirm('Change versions will stop the running tests.
Do you still want to continue?', 'Warn', { + confirmButtonText: 'Yes', + cancelButtonText: 'No', + dangerouslyUseHTMLString: true, + center: true + }).then(value => { + window.location.search = '?' + searchUrl; + }).catch(() => {}); + } + else { + window.location.search = '?' + searchUrl; + } } } diff --git a/test/runTest/client/index.html b/test/runTest/client/index.html index f86c65be6..72e653608 100644 --- a/test/runTest/client/index.html +++ b/test/runTest/client/index.html @@ -84,7 +84,7 @@ under the License. { function abortTests() { - if (aborted) { + if (!running) { return; } stopRunningTests(); io.of('/client').emit('abort'); - aborted = true; + running = false; } socket.on('setTestVersions', async (params) => { - abortTests(); + if (_currentTestHash !== getTestHash(params)) { + abortTests(); + } await updateTestsList( - getTestHash(params), - true + _currentTestHash = getTestHash(params), + !running // Set to unsettled if not running ); socket.emit('update', { @@ -245,12 +250,12 @@ async function start() { socket.on('run', async data => { let startTime = Date.now(); - aborted = false; + running = true; await prepareEChartsLib(data.expectedVersion); // Expected version. await prepareEChartsLib(data.actualVersion); // Version to test - if (aborted) { // If it is aborted when downloading echarts lib. + if (!running) { // If it is aborted when downloading echarts lib. return; } @@ -274,13 +279,14 @@ async function start() { console.error(e); } - if (!aborted) { + if (running) { console.log('Finished'); io.of('/client').emit('finish', { time: Date.now() - startTime, count: data.tests.length, threads: data.threads }); + running = false; } else { console.log('Aborted!'); diff --git a/test/runTest/store.js b/test/runTest/store.js index 62db9a306..8da58527d 100644 --- a/test/runTest/store.js +++ b/test/runTest/store.js @@ -137,6 +137,10 @@ module.exports.updateTestsList = async function ( _tests.forEach(testOpt => { testOpt.actions = actionsMetaData[testOpt.name] || 0; }); + + // Save once. + module.exports.saveTestsList(); + return _tests; }; -- GitLab