diff --git a/packages/sanity/playwright-ct/scripts/utils.ts b/packages/sanity/playwright-ct/scripts/utils.ts index 9e9452b7f06..094ae489bc1 100644 --- a/packages/sanity/playwright-ct/scripts/utils.ts +++ b/packages/sanity/playwright-ct/scripts/utils.ts @@ -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 `
\n${summary}\n\n${detail}\n
` +} + /** * 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` } /**