UNPKG

donobu

Version:

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

95 lines 4.22 kB
/** * @fileoverview Donobu Slack Reporter for Playwright. * * Writes a Slack Block Kit payload to disk and, when configured, POSTs it * directly to a Slack Incoming Webhook. During auto-heal the POST is deferred * to the orchestrator so the user sees exactly one message per run reflecting * the final (merged, possibly healed) outcome — not an initial failure * message followed by a healed one. * * @usage * The reporter takes no Slack-related options. All Slack configuration is * driven by environment variables (see below) — typically populated from CI * secrets and contextual run metadata. Wire it up in `playwright.config.ts` * with no arguments: * * ```ts * reporter: [ * ['donobu/reporter/slack'], * ], * ``` * * Optionally set `outputFile` to control the on-disk payload path: * * ```ts * reporter: [ * ['donobu/reporter/slack', { outputFile: 'test-results/slack-payload.json' }], * ], * ``` * * @env Configuration * * **`DONOBU_SLACK_WEBHOOK_URL`** *(required for posting; secret)* — the Slack * Incoming Webhook URL to POST the payload to. When unset, the reporter still * writes the payload file but performs no network call (the file is then * useful as a CI artifact or for piping to `curl` manually). This is treated * as a secret and is read only from the environment — never as a reporter * option — so it cannot accidentally end up checked into a config file. * * **`DONOBU_REPORT_URL`** *(optional; not secret)* — a URL to embed in the * Slack message that links back to the full report (e.g. the GitHub Actions * run URL, or a published HTML report). When unset, the message simply omits * the link section. Read from the environment for symmetry with the webhook * URL: both come from CI context, and a single configuration story keeps the * mental model simple. To override per-suite, set the env var differently * before invoking `donobu test`. * * **`DONOBU_AUTO_HEAL_ACTIVE`** / **`DONOBU_AUTO_HEAL_ORCHESTRATED`** * *(set internally; not user-facing)* — coordination flags the donobu CLI * sets so the reporter knows when to defer Slack posting to the orchestrator. * Users should never set these themselves. * * @CI A typical GitHub Actions wiring: * * ```yaml * env: * DONOBU_SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} * DONOBU_REPORT_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} * run: npx donobu test --auto-heal * ``` * * @auto-heal Per-run delivery semantics * * Every Donobu run produces exactly one Slack POST when a webhook is * configured, regardless of whether auto-heal triggers: * - **No auto-heal configured:** the reporter posts directly during `onEnd`. * - **Auto-heal configured, tests pass:** the reporter defers; the * orchestrator posts the initial payload after the early-return. * - **Auto-heal configured, no eligible plans:** same — orchestrator posts * the initial payload via the fallback path. * - **Auto-heal configured, heal runs and merges:** the reporter defers in * both the initial run and the heal rerun; the orchestrator posts the * merged payload after re-rendering. */ import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter'; import { type SlackBlockPayload } from './renderSlack'; export interface DonobuSlackReporterOptions { /** Path to write the Slack payload. Defaults to `test-results/slack-payload.json`. */ outputFile?: string; } /** * POST a Slack Block Kit payload to an Incoming Webhook URL. Logs failures but * never throws — Slack delivery is a nice-to-have, not a test-run blocker. */ export declare function postSlackPayload(webhookUrl: string, payload: SlackBlockPayload): Promise<void>; export default class DonobuSlackReporter implements Reporter { private readonly options; private readonly resultsByTest; private rootDir; constructor(options?: DonobuSlackReporterOptions); onBegin(config: FullConfig, _suite: Suite): void; onTestEnd(test: TestCase, result: TestResult): void; onEnd(_result: FullResult): Promise<void>; printsToStdio(): boolean; } //# sourceMappingURL=slack.d.ts.map