From 25189ba00b320043990e4b3f5e84a27de0cc7967 Mon Sep 17 00:00:00 2001 From: Aart Jan Kaptijn Date: Mon, 22 Nov 2021 13:55:27 +0100 Subject: [PATCH] wip --- src/main.ts | 47 +++++++++++++++++++++++++++++++++------- src/report/get-report.ts | 7 ++++-- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/main.ts b/src/main.ts index 1a4d801..9d8df9a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -213,14 +213,14 @@ class TestReporter { const passed = results.reduce((sum, tr) => sum + tr.passed, 0) const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0) const failed = results.reduce((sum, tr) => sum + tr.failed, 0) - await webhook.send({ + + const req = { blocks: [ { type: 'header', text: { type: 'plain_text', - text: 'Test results', - emoji: true + text: 'Test results' } }, { @@ -250,15 +250,46 @@ class TestReporter { ] }, { - type: 'section', - text: { - type: 'mrkdwn', - text: `<${resp.data.html_url}|View report>` - } + type: 'divider' } ] + } + + results.map((tr, runIndex) => { + if (tr.failed === 0) return + const runName = tr.path.slice(0, tr.path.indexOf('/TestResults/')) + + req.blocks.push({ + type: 'section', + fields: [ + { + type: 'mrkdwn', + text: `<${resp.data.html_url}#r${runIndex}|*${runName}*>` + }, + { + type: 'mrkdwn', + text: `:red_circle: ${tr.failed}` + } + ] + }) }) + + req.blocks.push( + { + type: 'divider' + }, + { + type: 'section', + text: { + type: 'mrkdwn', + text: `<${resp.data.html_url}|View full report>` + } + } + ) + + await webhook.send(req) } + return results } diff --git a/src/report/get-report.ts b/src/report/get-report.ts index 2cc1f16..030cfe7 100644 --- a/src/report/get-report.ts +++ b/src/report/get-report.ts @@ -138,7 +138,8 @@ function getTestRunsReport(testRuns: TestRunResult[], options: ReportOptions): s if (testRuns.length > 1 || options.onlySummary) { const tableData = testRuns.map((tr, runIndex) => { const time = formatTime(tr.time) - const name = tr.path + const folder = tr.path.indexOf('/TestResults/') + const name = folder > 0 ? tr.path.slice(0, folder) : tr.path const addr = options.baseUrl + makeRunSlug(runIndex).link const nameLink = link(name, addr) const passed = tr.passed > 0 ? `${tr.passed}${Icon.success}` : '' @@ -166,7 +167,9 @@ function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOpt const sections: string[] = [] const trSlug = makeRunSlug(runIndex) - const nameLink = `${tr.path}` + const folder = tr.path.indexOf('/TestResults/') + const name = folder > 0 ? tr.path.slice(0, folder) : tr.path + const nameLink = `${name}` const icon = getResultIcon(tr.result) sections.push(`## ${icon}\xa0${nameLink}`)