From 45c8d46681ab4f9ee9dd01180e5773fc95017b92 Mon Sep 17 00:00:00 2001 From: Jozef Izso Date: Sat, 25 Apr 2026 12:13:19 +0200 Subject: [PATCH] Resolve list-files conflicts on current main --- __tests__/report/get-report.test.ts | 12 +++++++----- dist/index.js | 22 ++++++++++++++++++---- src/main.ts | 12 +++++++++++- src/report/get-report.ts | 2 +- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/__tests__/report/get-report.test.ts b/__tests__/report/get-report.test.ts index 6543208..6908c6c 100644 --- a/__tests__/report/get-report.test.ts +++ b/__tests__/report/get-report.test.ts @@ -1,5 +1,5 @@ import {DEFAULT_OPTIONS, getBadge, getReport, ReportOptions} from '../../src/report/get-report.js' -import {TestCaseResult, TestGroupResult, TestRunResult, TestSuiteResult} from '../../src/test-results' +import {TestCaseResult, TestGroupResult, TestRunResult, TestSuiteResult} from '../../src/test-results.js' describe('getBadge', () => { describe('URI encoding with special characters', () => { @@ -141,10 +141,12 @@ describe('getReport', () => { tests.push(new TestCaseResult(`passed-test-${i}`, 'success', 100)) } for (let i = 0; i < failed; i++) { - tests.push(new TestCaseResult(`failed-test-${i}`, 'failed', 100, { - details: 'Test failed', - message: 'Assertion error' - })) + tests.push( + new TestCaseResult(`failed-test-${i}`, 'failed', 100, { + details: 'Test failed', + message: 'Assertion error' + }) + ) } for (let i = 0; i < skipped; i++) { tests.push(new TestCaseResult(`skipped-test-${i}`, 'skipped', 0)) diff --git a/dist/index.js b/dist/index.js index c8865b0..576e7ab 100644 --- a/dist/index.js +++ b/dist/index.js @@ -56954,6 +56954,7 @@ const DEFAULT_OPTIONS = { listSuites: 'all', listTests: 'all', slugPrefix: '', + listFiles: 'all', baseUrl: '', onlySummary: false, useActionsSummary: true, @@ -57074,8 +57075,14 @@ function getTestRunsReport(testRuns, options) { sections.push(`
Expand for details`); sections.push(` `); } - if (testRuns.length > 0 || options.onlySummary) { - const tableData = testRuns + // Filter test runs based on list-files option + const filteredTestRuns = options.listFiles === 'failed' + ? testRuns.filter(tr => tr.result === 'failed') + : options.listFiles === 'none' + ? [] + : testRuns; + if (filteredTestRuns.length > 0 || options.onlySummary) { + const tableData = filteredTestRuns .map((tr, originalIndex) => ({ tr, originalIndex })) .filter(({ tr }) => tr.passed > 0 || tr.failed > 0 || tr.skipped > 0) .map(({ tr, originalIndex }) => { @@ -57092,7 +57099,7 @@ function getTestRunsReport(testRuns, options) { sections.push(resultsTable); } if (options.onlySummary === false) { - const suitesReports = testRuns.map((tr, i) => getSuitesReport(tr, i, options)).flat(); + const suitesReports = filteredTestRuns.map((tr, i) => getSuitesReport(tr, i, options)).flat(); sections.push(...suitesReports); } if (shouldCollapse) { @@ -58949,6 +58956,7 @@ class TestReporter { reporter = getInput('reporter', { required: true }); listSuites = getInput('list-suites', { required: true }); listTests = getInput('list-tests', { required: true }); + listFiles = getInput('list-files', { required: true }); maxAnnotations = parseInt(getInput('max-annotations', { required: true })); failOnError = getInput('fail-on-error', { required: true }) === 'true'; failOnEmpty = getInput('fail-on-empty', { required: true }) === 'true'; @@ -58972,6 +58980,10 @@ class TestReporter { setFailed(`Input parameter 'list-tests' has invalid value`); return; } + if (this.listFiles !== 'all' && this.listFiles !== 'failed' && this.listFiles !== 'none') { + setFailed(`Input parameter 'list-files' has invalid value`); + return; + } if (this.collapsed !== 'auto' && this.collapsed !== 'always' && this.collapsed !== 'never') { setFailed(`Input parameter 'collapsed' has invalid value`); return; @@ -59056,7 +59068,7 @@ class TestReporter { throw error; } } - const { listSuites, listTests, slugPrefix, onlySummary, useActionsSummary, badgeTitle, reportTitle, collapsed } = this; + const { listSuites, listTests, slugPrefix, listFiles, onlySummary, useActionsSummary, badgeTitle, reportTitle, collapsed } = this; const passed = results.reduce((sum, tr) => sum + tr.passed, 0); const failed = results.reduce((sum, tr) => sum + tr.failed, 0); const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0); @@ -59067,6 +59079,7 @@ class TestReporter { listSuites, listTests, slugPrefix, + listFiles, baseUrl, onlySummary, useActionsSummary, @@ -59096,6 +59109,7 @@ class TestReporter { listSuites, listTests, slugPrefix, + listFiles, baseUrl, onlySummary, useActionsSummary, diff --git a/src/main.ts b/src/main.ts index 6705acb..eb1b3a5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -183,7 +183,17 @@ class TestReporter { } } - const {listSuites, listTests, slugPrefix, listFiles, onlySummary, useActionsSummary, badgeTitle, reportTitle, collapsed} = this + const { + listSuites, + listTests, + slugPrefix, + listFiles, + onlySummary, + useActionsSummary, + badgeTitle, + reportTitle, + collapsed + } = this const passed = results.reduce((sum, tr) => sum + tr.passed, 0) const failed = results.reduce((sum, tr) => sum + tr.failed, 0) diff --git a/src/report/get-report.ts b/src/report/get-report.ts index c6fc185..52f8645 100644 --- a/src/report/get-report.ts +++ b/src/report/get-report.ts @@ -11,7 +11,7 @@ const MAX_ACTIONS_SUMMARY_LENGTH = 1048576 export interface ReportOptions { listSuites: 'all' | 'failed' | 'none' listTests: 'all' | 'failed' | 'none' - slugPrefix: string; + slugPrefix: string listFiles: 'all' | 'failed' | 'none' baseUrl: string onlySummary: boolean