diff --git a/README.md b/README.md index cfc8b75..916c6f6 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,16 @@ Options are specified on the [`with` map](https://docs.github.com/en/actions/usi show: "fail, skip" ``` +* **`folded`: display test details in a folded details block** (optional) + When enabled the details for each test result will be nested in a details blocks which can be expanded by clicking on the test name. This option can be `true` or `false` (The default). + + ```yaml + - uses: test-summary/action@v2 + with: + paths: "test/results/**/TEST-*.xml" + folded: true + ``` + FAQ --- * **How is the summary graphic generated? Does any of my data ever leave GitHub?** diff --git a/action.yml b/action.yml index 5613916..f66a8ed 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,8 @@ inputs: description: File to write with rendered output show: description: Types of tests to show in the results table + folded: + description: Show each result in a folded details block runs: using: 'node20' main: 'index.js' diff --git a/src/dashboard.ts b/src/dashboard.ts index 24fcb0b..c949a40 100644 --- a/src/dashboard.ts +++ b/src/dashboard.ts @@ -28,7 +28,7 @@ export function dashboardSummary(result: TestResult): string { return `${summary}` } -export function dashboardResults(result: TestResult, show: number): string { +export function dashboardResults(result: TestResult, show: number, folded: boolean): string { let table = "" let count = 0 @@ -41,6 +41,9 @@ export function dashboardResults(result: TestResult, show: number): string { } table += "\n" count++ diff --git a/src/index.ts b/src/index.ts index 644afa3..face627 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,6 +11,7 @@ async function run(): Promise { const pathGlobs = core.getInput("paths", { required: true }) const outputFile = core.getInput("output") || process.env.GITHUB_STEP_SUMMARY || "-" const showList = core.getInput("show") + const folded = JSON.parse(core.getInput("folded") || "false") /* * Given paths may either be an individual path (eg "foo.xml"), @@ -99,7 +100,7 @@ async function run(): Promise { let output = dashboardSummary(total) if (show) { - output += dashboardResults(total, show) + output += dashboardResults(total, show, folded) } if (outputFile === "-") { diff --git a/test/dashboard.ts b/test/dashboard.ts index 5d93a15..802bf71 100644 --- a/test/dashboard.ts +++ b/test/dashboard.ts @@ -29,7 +29,7 @@ describe("dashboard", async () => { } ] } - const actual = dashboardResults(result, TestStatus.Fail) + const actual = dashboardResults(result, TestStatus.Fail, false) expect(actual).contains("name escaped <properly>") expect(actual).contains("description escaped "properly"") expect(actual).contains("another name escaped 'properly'") @@ -51,7 +51,7 @@ describe("dashboard", async () => { } ] } - const actual = dashboardResults(result, TestStatus.Fail) + const actual = dashboardResults(result, TestStatus.Fail, false) expect(actual).contains("<no name>") }) @@ -72,7 +72,7 @@ describe("dashboard", async () => { ] } - const actual = dashboardResults(result, TestStatus.Fail) + const actual = dashboardResults(result, TestStatus.Fail, false) expect(actual).contains("message escaped <properly>") expect(actual).contains("details escaped <properly>")
" + if (folded) { + table += "
" + } const icon = statusIcon(testcase.status) if (icon) { @@ -55,6 +58,10 @@ export function dashboardResults(result: TestResult, show: number): string { table += escapeHTML(testcase.description) } + if (folded) { + table += "" + } + if (testcase.message || testcase.details) { table += "
\n" @@ -71,6 +78,10 @@ export function dashboardResults(result: TestResult, show: number): string { } } + if (folded) { + table += "
" + } + table += "