UNPKG

donobu

Version:

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

61 lines 2.12 kB
"use strict"; /** * @fileoverview Shared helpers for walking a `DonobuReport` and classifying * the tests inside it. Used by every renderer (HTML, Markdown, Slack) so they * all agree on "what counts as self-healed" and how suites nest. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.collectSpecs = collectSpecs; exports.isSelfHealed = isSelfHealed; exports.statusOf = statusOf; /** * Recursively collect all specs from a suite and its nested sub-suites. The * Playwright JSON report nests suites (e.g. describe blocks), so a flat view * is what every renderer actually wants. */ function collectSpecs(suite) { const specs = [...(suite.specs ?? [])]; for (const child of suite.suites ?? []) { specs.push(...collectSpecs(child)); } return specs; } /** * A test is "self-healed" when either: * - it carries a `self-healed` annotation (set by the merge step when a * failing test flipped to passing on the heal rerun), or * - its `donobuStatus` field has been set to `'healed'` (same signal, via * the merged report's per-test metadata). */ function isSelfHealed(test) { const annotations = test?.annotations ?? []; const hasAnnotation = annotations.some((a) => a?.type === 'self-healed'); return hasAnnotation || test?.donobuStatus === 'healed'; } /** * Derive the display status for a test. Prefers the final attempt's result * status; bumps to `'healed'` when the self-heal signal is present; falls * back to `'skipped'` when Playwright didn't emit a result. */ function statusOf(test) { const lastResult = test?.results?.at?.(-1); if (test?.status === 'skipped' || (!lastResult && test?.status === undefined)) { return 'skipped'; } if (isSelfHealed(test)) { return 'healed'; } const status = lastResult?.status ?? 'unknown'; switch (status) { case 'passed': case 'failed': case 'timedOut': case 'skipped': case 'interrupted': return status; default: return 'unknown'; } } //# sourceMappingURL=reportWalk.js.map