Skip to content

Commit

Permalink
chore(tests): collapsing ct test report comment (#7378)
Browse files Browse the repository at this point in the history
* chore(tests): collapsing ct test report comment

* fix(ci): fixing md formatting with linebreak in detail
  • Loading branch information
jordanl17 authored Aug 19, 2024
1 parent e6185ef commit cd341d8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/sanity/playwright-ct/scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,25 @@ function generateMarkdownTable(rows: SummaryRow[]) {
].join('\n')
}

function generateTestingSummary(rows: SummaryRow[]) {
const failedTestCount = sumBy(rows, 'totalFailed')

return `${failedTestCount > 0 ? `❌ Failed Tests (${failedTestCount})` : '✅ All Tests Passed'} -- expand for details`
}

function formatAsCollapsable(summary: string, detail: string) {
return `<details>\n<summary>${summary}</summary>\n\n${detail}\n</details>`
}

/**
* Generate PR comment output
*/
export function generateComment(rows: SummaryRow[]) {
const updatedAtUtc = getCurrentUTCDate()
const table = generateMarkdownTable(rows)
const testingSummary = generateTestingSummary(rows)

return `**Component Testing Report** Updated ${updatedAtUtc} (UTC)\n\n${table}\n\n`
return `**Component Testing Report** Updated ${updatedAtUtc} (UTC)\n\n${formatAsCollapsable(testingSummary, table)}\n\n`
}

/**
Expand Down

0 comments on commit cd341d8

Please sign in to comment.