Skip to content

Add e2e test suite failed/failure hash choices #562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions test/e2e/accept-changes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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')
11 changes: 9 additions & 2 deletions test/e2e/modules/e2e-test/test-suite-result.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
) {
Expand All @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading