From 1623d2cfe625f31d187b1ceb9a43c8a311adcf2e Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Tue, 30 Jul 2024 14:10:27 +0200 Subject: [PATCH] Add e2e test suite hash choices --- test/e2e/accept-changes.cjs | 16 ++++++++++------ test/e2e/modules/e2e-test/test-suite-result.cjs | 11 +++++++++-- test/e2e/test.cjs | 7 ++++--- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/test/e2e/accept-changes.cjs b/test/e2e/accept-changes.cjs index b3d1a23f1..2391c6ac3 100644 --- a/test/e2e/accept-changes.cjs +++ b/test/e2e/accept-changes.cjs @@ -2,7 +2,12 @@ const fs = require('fs') const prettier = require('prettier') function copyHashes(failHashFile, refHashFile) { - const failHashData = JSON.parse(fs.readFileSync(failHashFile)) + let failHashData + try { + failHashData = JSON.parse(fs.readFileSync(failHashFile)) + } catch (error) { + return + } const refHashData = JSON.parse(fs.readFileSync(refHashFile)) for (const testFilename in failHashData.test) { @@ -25,8 +30,7 @@ function copyHashes(failHashFile, refHashFile) { } copyHashes('test_report/results/test_cases/test_cases.json', 'test_cases/test_cases.json') -/* -copyHashes( - "test_report/results/tests/style/style_tests.json", - "tests/style_tests.json" -) */ +copyHashes('test_report/results/tests/style_tests/style_tests.json', 'tests/style_tests.json') +copyHashes('test_report/results/tests/features/features.json', 'tests/features.json') +copyHashes('test_report/results/tests/fixes/fixes.json', 'tests/fixes.json') +copyHashes('test_report/results/tests/config_tests/config_tests.json', 'tests/config_tests.json') diff --git a/test/e2e/modules/e2e-test/test-suite-result.cjs b/test/e2e/modules/e2e-test/test-suite-result.cjs index eac4bf926..f581749c3 100644 --- a/test/e2e/modules/e2e-test/test-suite-result.cjs +++ b/test/e2e/modules/e2e-test/test-suite-result.cjs @@ -85,7 +85,8 @@ class TestSuiteResult { if (this.#createHashes !== 'DISABLED') { if ( this.#createHashes === 'ALL' || - (this.#createHashes === 'FAILED' && + (this.#createHashes === 'FAILED' && this.#testSuiteResults.FAILED.length !== 0) || + (this.#createHashes === 'FAILURES' && (this.#testSuiteResults.FAILED.length !== 0 || this.#testSuiteResults.WARNING.length !== 0)) ) { @@ -100,12 +101,18 @@ class TestSuiteResult { }) for (const [key] of Object.entries(this.#testSuiteResults.RESULTS)) { if ( - this.#createHashes === 'FAILED' && + this.#createHashes === 'FAILURES' && !this.#testSuiteResults.FAILED.includes(key) && !this.#testSuiteResults.WARNING.includes(key) ) { continue } + if ( + this.#createHashes === 'FAILED' && + !this.#testSuiteResults.FAILED.includes(key) + ) { + continue + } Object.keys(testCasesConfig).forEach((suite) => { if (key.startsWith(suite)) { if (this.#testSuiteResults.RESULTS[key].hash) { diff --git a/test/e2e/test.cjs b/test/e2e/test.cjs index daef815cc..264f5154b 100644 --- a/test/e2e/test.cjs +++ b/test/e2e/test.cjs @@ -93,15 +93,16 @@ Please note that the test require Chrome, ChromeDriver and Selenium Webdriver to ) .default('maxFailedImages', null) - .choices('hashes', ['ALL', 'FAILED', 'DISABLED']) + .choices('hashes', ['ALL', 'FAILED', 'FAILURES', 'DISABLED']) .describe( 'hashes', 'Change the saving behavior of hashes, which are unique identifiers calculated for each test case' + '\n- "ALL": Write hashes into the report file for every test' + - '\n- "FAILED": Write hashes into the report file for failed/warning tests only' + + '\n- "FAILED": Write hashes into the report file for failed tests only' + + '\n- "FAILURES": Write hashes into the report file for failed/warning tests only' + '\n- "DISABLED": Do not create report file' ) - .default('hashes', 'FAILED') + .default('hashes', 'FAILURES') .boolean('nologs') .describe('nologs', 'Disable the saving of browser and console logs into a log file')