diff --git a/.github/workflows/all-tests.yml b/.github/workflows/all-tests.yml index 1c8ba1e04..7d26aa227 100644 --- a/.github/workflows/all-tests.yml +++ b/.github/workflows/all-tests.yml @@ -582,7 +582,13 @@ jobs: npx playwright merge-reports --reporter html ./all-reports/all-blob-reports mv playwright-report ./all-reports/html-report - - name: Upload HTML report + - name: Generate summary report + working-directory: tests/pw + run: | + node ./mergeTestSummary.js + + + - name: Upload final test artifact uses: actions/upload-artifact@v4 with: name: final-test-artifact diff --git a/tests/pw/e2e.config.ts b/tests/pw/e2e.config.ts index a03af397c..a0ec14951 100644 --- a/tests/pw/e2e.config.ts +++ b/tests/pw/e2e.config.ts @@ -145,7 +145,7 @@ export default defineConfig({ { name: 'e2e_tests', testMatch: /.*\.spec\.ts/, - grep: [/@lite/], + grep: [/@admin/], /* whether not to run setup tests before running actual tests */ dependencies: NO_SETUP ? [] : ['e2e_setup'], /* whether not to run teardown tests after running actual tests */ diff --git a/tests/pw/utils/mergeSummaryReport.js b/tests/pw/utils/mergeSummaryReport.js new file mode 100644 index 000000000..e84b71801 --- /dev/null +++ b/tests/pw/utils/mergeSummaryReport.js @@ -0,0 +1,90 @@ +const fs = require('fs'); +const path = require('path'); + +// Helper function to format duration +const getFormattedDuration = milliseconds => { + const hours = Math.floor(milliseconds / (1000 * 60 * 60)); + const min = Math.floor((milliseconds / (1000 * 60)) % 60); + const sec = Math.floor((milliseconds / 1000) % 60); + return `${hours < 1 ? '' : hours + 'h '}${min < 1 ? '' : min + 'm '}${sec < 1 ? '' : sec + 's'}`; +}; + +const mergeReports = reportPaths => { + const mergedReport = { + suite_name: '', + total_tests: 0, + passed: 0, + failed: 0, + flaky: 0, + skipped: 0, + suite_duration: 0, + suite_duration_formatted: '', + tests: [], + passed_tests: [], + failed_tests: [], + flaky_tests: [], + skipped_tests: [], + }; + + reportPaths.forEach(reportPath => { + const report = JSON.parse(fs.readFileSync(reportPath, 'utf8')); + mergedReport.total_tests += report.total_tests; + mergedReport.passed += report.passed; + mergedReport.failed += report.failed; + mergedReport.flaky += report.flaky; + mergedReport.skipped += report.skipped; + mergedReport.suite_duration += report.suite_duration; + + // Append and de-duplicate test arrays + mergedReport.tests.push(...report.tests); + mergedReport.passed_tests.push(...report.passed_tests); + mergedReport.failed_tests.push(...report.failed_tests); + mergedReport.flaky_tests.push(...report.flaky_tests); + mergedReport.skipped_tests.push(...report.skipped_tests); + }); + + // Remove duplicates and sort arrays + mergedReport.tests = [...new Set(mergedReport.tests)].sort(); + mergedReport.passed_tests = [...new Set(mergedReport.passed_tests)].sort(); + mergedReport.failed_tests = [...new Set(mergedReport.failed_tests)].sort(); + mergedReport.flaky_tests = [...new Set(mergedReport.flaky_tests)].sort(); + mergedReport.skipped_tests = [...new Set(mergedReport.skipped_tests)].sort(); + + // Format the suite duration + mergedReport.suite_duration_formatted = getFormattedDuration(mergedReport.suite_duration); + + return mergedReport; +}; + +// Main script execution +const reportsFolder = './all-reports'; // Change to your artifacts location +const reportPaths = []; + +// Collect all result.json files +const findReports = dir => { + const files = fs.readdirSync(dir); + files.forEach(file => { + const fullPath = path.join(dir, file); + if (fs.statSync(fullPath).isDirectory()) { + findReports(fullPath); // Recurse into subdirectories + } else if (file === 'results.json') { + reportPaths.push(fullPath); + } + }); +}; + +findReports(reportsFolder); + +if (reportPaths.length === 0) { + console.error('No results.json files found in artifacts.'); + process.exit(1); +} + +// Merge reports +const mergedReport = mergeReports(reportPaths); + +// Save the merged report +const outputPath = './all-reports/merged-summary.json'; +fs.writeFileSync(outputPath, JSON.stringify(mergedReport, null, 2), 'utf8'); + +console.log(`Merged summary report saved to ${outputPath}`);