UNPKG

donobu

Version:

Create browser automations with an LLM agent and replay them as Playwright scripts.

100 lines 3.54 kB
"use strict"; /** * @fileoverview Donobu Slack payload renderer. * * Pure library that turns a `DonobuReport` into a Slack Block Kit payload * suitable for POSTing to an Incoming Webhook. No filesystem writes, no * network calls, no env-var reads — callers own I/O. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.renderSlack = renderSlack; const reportWalk_1 = require("./reportWalk"); function renderSlack(report, options = {}) { const suites = (report.suites ?? []); const blocks = []; blocks.push({ type: 'header', text: { type: 'plain_text', text: '🐵 Donobu Test Summary' }, }); let totalPassed = 0; let totalFailed = 0; let totalTimedOut = 0; let totalSkipped = 0; let totalInterrupted = 0; let totalSelfHealed = 0; suites.forEach((suite) => { (0, reportWalk_1.collectSpecs)(suite).forEach((spec) => { (spec.tests ?? []).forEach((test) => { const result = test.results?.at(-1); const healed = (0, reportWalk_1.isSelfHealed)(test); if (test.status === 'skipped' || (!result && test.status === undefined)) { totalSkipped++; } else if (result) { if (healed) { totalSelfHealed++; } else { switch (result.status) { case 'passed': totalPassed++; break; case 'failed': totalFailed++; break; case 'timedOut': totalTimedOut++; break; case 'skipped': totalSkipped++; break; case 'interrupted': totalInterrupted++; break; } } } }); }); }); const statusRows = [ { name: 'Passed', emoji: '✅', count: totalPassed }, { name: 'Self-Healed', emoji: '❤️‍🩹', count: totalSelfHealed }, { name: 'Failed', emoji: '❌', count: totalFailed }, { name: 'Timed Out', emoji: '⏰', count: totalTimedOut }, { name: 'Skipped', emoji: '⏭️', count: totalSkipped }, { name: 'Interrupted', emoji: '⚡', count: totalInterrupted }, ]; statusRows.forEach((row) => { blocks.push({ type: 'section', fields: [ { type: 'mrkdwn', text: `${row.emoji} ${row.name}` }, { type: 'mrkdwn', text: `${row.count}` }, ], }); }); if (options.reportUrl) { blocks.push({ type: 'divider' }); blocks.push({ type: 'section', text: { type: 'mrkdwn', text: `📊 <${options.reportUrl}|View Full Report>`, }, }); } blocks.push({ type: 'divider' }); blocks.push({ type: 'context', elements: [ { type: 'mrkdwn', text: `Report generated on ${new Date().toLocaleString()} by Donobu`, }, ], }); return { blocks }; } //# sourceMappingURL=renderSlack.js.map