donobu 5.60.0 → 5.60.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/cli/donobu-cli.js +151 -52
  2. package/dist/envVars.d.ts +4 -0
  3. package/dist/envVars.js +12 -0
  4. package/dist/esm/cli/donobu-cli.js +151 -52
  5. package/dist/esm/envVars.d.ts +4 -0
  6. package/dist/esm/envVars.js +12 -0
  7. package/dist/esm/lib/page/extendPage.d.ts +6 -0
  8. package/dist/esm/lib/page/extendPage.js +24 -1
  9. package/dist/esm/lib/test/healRerunGate.d.ts +85 -0
  10. package/dist/esm/lib/test/healRerunGate.js +186 -0
  11. package/dist/esm/lib/test/testExtension.d.ts +1 -0
  12. package/dist/esm/lib/test/testExtension.js +20 -10
  13. package/dist/esm/reporter/buildReport.js +32 -0
  14. package/dist/esm/reporter/merge.d.ts +1 -6
  15. package/dist/esm/reporter/merge.js +57 -35
  16. package/dist/esm/reporter/model.d.ts +9 -0
  17. package/dist/esm/reporter/model.js +10 -1
  18. package/dist/esm/reporter/render.js +34 -12
  19. package/dist/esm/reporter/renderMarkdown.js +148 -93
  20. package/dist/esm/reporter/renderSlack.js +39 -28
  21. package/dist/esm/reporter/reportWalk.d.ts +16 -6
  22. package/dist/esm/reporter/reportWalk.js +63 -13
  23. package/dist/esm/tools/RunInlineJavaScriptCodeTool.js +43 -2
  24. package/dist/esm/tools/RunSandboxedJavaScriptCodeTool.js +24 -2
  25. package/dist/esm/utils/PlaywrightUtils.d.ts +75 -0
  26. package/dist/esm/utils/PlaywrightUtils.js +122 -0
  27. package/dist/lib/page/extendPage.d.ts +6 -0
  28. package/dist/lib/page/extendPage.js +24 -1
  29. package/dist/lib/test/healRerunGate.d.ts +85 -0
  30. package/dist/lib/test/healRerunGate.js +186 -0
  31. package/dist/lib/test/testExtension.d.ts +1 -0
  32. package/dist/lib/test/testExtension.js +20 -10
  33. package/dist/reporter/buildReport.js +32 -0
  34. package/dist/reporter/merge.d.ts +1 -6
  35. package/dist/reporter/merge.js +57 -35
  36. package/dist/reporter/model.d.ts +9 -0
  37. package/dist/reporter/model.js +10 -1
  38. package/dist/reporter/render.js +34 -12
  39. package/dist/reporter/renderMarkdown.js +148 -93
  40. package/dist/reporter/renderSlack.js +39 -28
  41. package/dist/reporter/reportWalk.d.ts +16 -6
  42. package/dist/reporter/reportWalk.js +63 -13
  43. package/dist/tools/RunInlineJavaScriptCodeTool.js +43 -2
  44. package/dist/tools/RunSandboxedJavaScriptCodeTool.js +24 -2
  45. package/dist/utils/PlaywrightUtils.d.ts +75 -0
  46. package/dist/utils/PlaywrightUtils.js +122 -0
  47. package/package.json +1 -1
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Runtime gate for auto-heal reruns.
4
+ *
5
+ * The auto-heal rerun is launched with the same project-level arguments as the
6
+ * initial run so Playwright's scheduling (declared project `dependencies`,
7
+ * workers, ordering) behaves with full fidelity. Within the targeted projects,
8
+ * however, only the tests the heal actually needs should execute. This module
9
+ * enforces that from an auto fixture that runs before any browser fixture:
10
+ * when `DONOBU_AUTO_HEAL_PLAN_PATH` is set, every test not in the rerun plan
11
+ * skips immediately — before a context or page is created — annotated with
12
+ * `donobu-heal-skip-replay` so the merge step drops the entry and leaves the
13
+ * initial run's result untouched.
14
+ *
15
+ * What runs during a heal rerun (the "declared signals only" policy):
16
+ * - Heal targets (the failed tests with actionable treatment plans).
17
+ * - For a target inside a `test.describe.serial` scope (or a file marked
18
+ * serial via `test.describe.configure({ mode: 'serial' })`): the other
19
+ * serial-scoped tests in that file. Serial mode is Playwright's declared
20
+ * intra-file ordering contract — Playwright itself re-runs whole serial
21
+ * groups on retry, and we mirror that. The orchestrator expands the plan
22
+ * with these companions before the rerun (see
23
+ * `expandTargetsWithSerialCompanions`) using the `serialScoped` flags the
24
+ * Donobu reporter recorded during the initial run — the runner process
25
+ * sees the suite tree; the worker (where this gate runs) does not.
26
+ * - Declared dependency projects, which Playwright always runs in full.
27
+ *
28
+ * Implicit ordering (checkpoint files between plain tests, cross-file state
29
+ * with `workers: 1`) is deliberately NOT honored: tests relying on it will
30
+ * skip themselves during the rerun and surface as honest failures with
31
+ * guidance to declare the dependency.
32
+ *
33
+ * The gate runs at test runtime rather than collection time so Playwright's
34
+ * test-location attribution stays untouched (a collection-time wrapper would
35
+ * become every test's reported call site, breaking the merge's file-based
36
+ * matching) and so the plan can be matched against `testInfo.file`/`title`
37
+ * exactly instead of via stack inspection.
38
+ */
39
+ var __importDefault = (this && this.__importDefault) || function (mod) {
40
+ return (mod && mod.__esModule) ? mod : { "default": mod };
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.buildPlanIndex = buildPlanIndex;
44
+ exports.shouldRunDuringHealRerun = shouldRunDuringHealRerun;
45
+ exports.expandTargetsWithSerialCompanions = expandTargetsWithSerialCompanions;
46
+ exports.resetHealRerunPlanCacheForTesting = resetHealRerunPlanCacheForTesting;
47
+ exports.maybeSkipForHealRerun = maybeSkipForHealRerun;
48
+ const fs_1 = __importDefault(require("fs"));
49
+ const path_1 = __importDefault(require("path"));
50
+ const envVars_1 = require("../../envVars");
51
+ const model_1 = require("../../reporter/model");
52
+ const Logger_1 = require("../../utils/Logger");
53
+ function buildPlanIndex(plan) {
54
+ const index = new Map();
55
+ for (const target of plan.targets ?? []) {
56
+ if (!target?.file || !target?.title) {
57
+ continue;
58
+ }
59
+ const file = path_1.default.resolve(target.file);
60
+ if (!index.has(file)) {
61
+ index.set(file, new Set());
62
+ }
63
+ index.get(file).add(target.title);
64
+ }
65
+ return index;
66
+ }
67
+ /**
68
+ * Pure decision: should the test in `file` with `title` actually execute
69
+ * during the heal rerun? The plan is fully explicit — serial companions were
70
+ * already expanded into it by the orchestrator.
71
+ */
72
+ function shouldRunDuringHealRerun(params) {
73
+ const titles = params.index.get(path_1.default.resolve(params.file));
74
+ return titles?.has(params.title) ?? false;
75
+ }
76
+ /**
77
+ * Expand heal targets with their `describe.serial` siblings, using the
78
+ * `serialScoped` flags the Donobu reporter recorded in the initial run's
79
+ * report. Companions live in the same file as their target by construction
80
+ * (serial scopes are intra-file), so they inherit the target's absolute file
81
+ * path; report file paths are rootDir-relative, hence the suffix match.
82
+ *
83
+ * Degrades to the unexpanded targets when the report (or the flags) are
84
+ * unavailable — serial chains then surface as honest not-reattempted
85
+ * failures instead of healing.
86
+ */
87
+ function expandTargetsWithSerialCompanions(targets, initialReport) {
88
+ const suites = (initialReport?.suites ?? []);
89
+ const expanded = [...targets];
90
+ const seen = new Set(targets.map((t) => `${path_1.default.resolve(t.file)}::${t.projectName}::${t.title}`));
91
+ for (const target of targets) {
92
+ if (!target.file || !target.title) {
93
+ continue;
94
+ }
95
+ const targetFile = path_1.default.resolve(target.file);
96
+ for (const suite of suites) {
97
+ const suiteFile = String(suite.file ?? '');
98
+ if (!targetFile.endsWith(path_1.default.normalize(suiteFile)) ||
99
+ suiteFile.length === 0) {
100
+ continue;
101
+ }
102
+ const specs = suite.specs ?? [];
103
+ const targetEntry = specs
104
+ .find((spec) => spec.title === target.title)
105
+ ?.tests?.find((test) => !target.projectName || test.projectName === target.projectName);
106
+ if (!targetEntry?.serialScoped) {
107
+ continue;
108
+ }
109
+ // The target is serial-scoped: every serial-scoped test in this file
110
+ // (same project) joins the plan. Bounded by the file, mirroring how
111
+ // Playwright re-runs whole serial groups on retry.
112
+ for (const spec of specs) {
113
+ for (const test of spec.tests ?? []) {
114
+ if (!test.serialScoped) {
115
+ continue;
116
+ }
117
+ if (target.projectName && test.projectName !== target.projectName) {
118
+ continue;
119
+ }
120
+ const key = `${targetFile}::${test.projectName}::${spec.title}`;
121
+ if (seen.has(key)) {
122
+ continue;
123
+ }
124
+ seen.add(key);
125
+ expanded.push({
126
+ file: target.file,
127
+ title: spec.title,
128
+ projectName: test.projectName,
129
+ });
130
+ }
131
+ }
132
+ }
133
+ }
134
+ return expanded;
135
+ }
136
+ let cachedPlanIndex;
137
+ function getPlanIndex(planPathOverride) {
138
+ if (planPathOverride === undefined && cachedPlanIndex !== undefined) {
139
+ return cachedPlanIndex;
140
+ }
141
+ const planPath = planPathOverride ?? envVars_1.env.data.DONOBU_AUTO_HEAL_PLAN_PATH;
142
+ let index = null;
143
+ if (planPath) {
144
+ try {
145
+ const raw = fs_1.default.readFileSync(planPath, 'utf8');
146
+ index = buildPlanIndex(JSON.parse(raw));
147
+ }
148
+ catch (error) {
149
+ Logger_1.appLogger.warn(`Auto-heal rerun plan at ${planPath} could not be read; running all collected tests.`, error);
150
+ index = null;
151
+ }
152
+ }
153
+ if (planPathOverride === undefined) {
154
+ cachedPlanIndex = index;
155
+ }
156
+ return index;
157
+ }
158
+ /** Test-only: reset the memoized plan so each test can load its own. */
159
+ function resetHealRerunPlanCacheForTesting() {
160
+ cachedPlanIndex = undefined;
161
+ }
162
+ /**
163
+ * Called from the Donobu auto fixture before any browser fixture initializes.
164
+ * Outside heal reruns this is a no-op. During a rerun, tests outside the plan
165
+ * are annotated and skipped on the spot — no context, no page, no cost.
166
+ */
167
+ function maybeSkipForHealRerun(testInfo, options) {
168
+ const index = getPlanIndex(options?.planPath);
169
+ if (!index) {
170
+ return;
171
+ }
172
+ const shouldRun = shouldRunDuringHealRerun({
173
+ index,
174
+ file: testInfo.file,
175
+ title: testInfo.title,
176
+ });
177
+ if (shouldRun) {
178
+ return;
179
+ }
180
+ testInfo.annotations.push({
181
+ type: model_1.HEAL_SKIP_REPLAY_ANNOTATION_TYPE,
182
+ description: 'Not part of the auto-heal rerun plan; the initial run result stands.',
183
+ });
184
+ testInfo.skip(true, 'Not part of the auto-heal rerun plan; the initial run result stands.');
185
+ }
186
+ //# sourceMappingURL=healRerunGate.js.map
@@ -5,6 +5,7 @@ import { FlowLogBuffer } from '../../utils/FlowLogBuffer';
5
5
  import type { DonobuExtendedPage } from '../page/DonobuExtendedPage';
6
6
  export * from '@playwright/test';
7
7
  export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
8
+ healRerunGate: void;
8
9
  flowLoggingContext: {
9
10
  flowId: string;
10
11
  logBuffer: FlowLogBuffer;
@@ -41,6 +41,7 @@ const PageLogListeners_1 = require("../../utils/PageLogListeners");
41
41
  const cacheLocator_1 = require("../ai/cache/cacheLocator");
42
42
  const extendPage_1 = require("../page/extendPage");
43
43
  const tbd_1 = require("../page/tbd");
44
+ const healRerunGate_1 = require("./healRerunGate");
44
45
  const selfHealing_1 = require("./utils/selfHealing");
45
46
  const triageTestFailure_1 = require("./utils/triageTestFailure");
46
47
  __exportStar(require("@playwright/test"), exports);
@@ -220,6 +221,20 @@ function persistVideoIfApplicable(page, testInfo, videoOption) {
220
221
  */
221
222
  const UPLOAD_DRAIN_TIMEOUT_MS = 30_000;
222
223
  exports.test = test_1.test.extend({
224
+ /**
225
+ * Auto-heal rerun gate. First in registration order so it runs before every
226
+ * other test-scoped fixture: during a heal rerun, tests outside the rerun
227
+ * plan skip here — before a browser context or page is ever created — with
228
+ * the `donobu-heal-skip-replay` annotation the merge step uses to drop
229
+ * their entries. A no-op outside heal reruns.
230
+ */
231
+ healRerunGate: [
232
+ async ({}, use, testInfo) => {
233
+ (0, healRerunGate_1.maybeSkipForHealRerun)(testInfo);
234
+ await use();
235
+ },
236
+ { scope: 'test', auto: true },
237
+ ],
223
238
  /**
224
239
  * Establish a logging scope for the entire Playwright test *before* any other
225
240
  * fixtures run. Playwright builds the fixture dependency graph eagerly, so
@@ -400,6 +415,7 @@ exports.test = test_1.test.extend({
400
415
  flowId: flowId,
401
416
  visualCueDurationMs: visualCueDurationMs,
402
417
  cacheFilepath: (0, cacheLocator_1.buildPageAiCachePath)(testInfo.file),
418
+ specFilePath: testInfo.file,
403
419
  envVars: (0, DonobuFlowsManager_1.distillAllowedEnvVariableNames)(overallObjective, testInfo.annotations
404
420
  .filter((a) => a.type === 'ENV' && a.description)
405
421
  .map((a) => a.description)),
@@ -1051,16 +1067,10 @@ async function finalizeTest(page, testInfo, logBuffer, videoOption) {
1051
1067
  }
1052
1068
  }
1053
1069
  }
1054
- else if (testInfo.status === 'passed' &&
1055
- MiscUtils_1.MiscUtils.yn(envVars_1.env.data.DONOBU_AUTO_HEAL_ACTIVE)) {
1056
- const hasSelfHealedAnnotation = testInfo.annotations.some((annotation) => annotation.type === 'self-healed');
1057
- if (!hasSelfHealedAnnotation) {
1058
- testInfo.annotations.push({
1059
- type: 'self-healed',
1060
- description: 'Automatically healed by Donobu auto-heal rerun.',
1061
- });
1062
- }
1063
- }
1070
+ // Note: passing tests in an auto-heal rerun are NOT annotated here. Whether
1071
+ // a test was actually healed (failed initially, passed on the rerun) is
1072
+ // decided by the merge step, which sees both runs — annotating every rerun
1073
+ // pass would mislabel dependency tests that never failed.
1064
1074
  // Flush any page.tbd() sessions: replace the tbd() call sites in the
1065
1075
  // source files with the generated Playwright code for the recorded
1066
1076
  // user interactions.
@@ -58,6 +58,14 @@ function buildDonobuReport(resultsByTest, rootDir) {
58
58
  // Signal "skipped" tests to the renderers the same way the JSON
59
59
  // reporter does.
60
60
  status: test.expectedStatus === 'skipped' ? 'skipped' : undefined,
61
+ // Consumed by `reportWalk.statusOf` to classify `test.fail()`
62
+ // specs as expected failures rather than real ones; absent from
63
+ // the legacy state-file shape.
64
+ expectedStatus: test.expectedStatus,
65
+ // Whether the test sits inside a `describe.serial` scope — declared
66
+ // intra-file ordering. The auto-heal orchestrator uses this to
67
+ // include a heal target's serial siblings in the rerun plan.
68
+ serialScoped: isSerialScoped(test),
61
69
  results: results.map((r) => ({
62
70
  status: r.status,
63
71
  duration: r.duration,
@@ -110,6 +118,30 @@ function buildDonobuReport(resultsByTest, rootDir) {
110
118
  }
111
119
  return { suites, metadata: {} };
112
120
  }
121
+ /**
122
+ * Whether any enclosing suite is in serial mode (`test.describe.serial` or
123
+ * `test.describe.configure({ mode: 'serial' })`).
124
+ *
125
+ * Reads the runner-side suite internals (`_parallelMode`) — reporters receive
126
+ * the runner's own Suite instances, which carry it. Verified against
127
+ * @playwright/test 1.58; guarded so shape drift degrades to `false` (serial
128
+ * chains then lose heal eligibility, but reporting stays honest).
129
+ */
130
+ function isSerialScoped(test) {
131
+ try {
132
+ let suite = test.parent;
133
+ while (suite) {
134
+ if (suite._parallelMode === 'serial') {
135
+ return true;
136
+ }
137
+ suite = suite.parent;
138
+ }
139
+ }
140
+ catch {
141
+ // Internal shape drifted — treat as non-serial.
142
+ }
143
+ return false;
144
+ }
113
145
  /** Walk up the suite chain to find the enclosing project suite's title. */
114
146
  function getProjectName(test) {
115
147
  let suite = test.parent;
@@ -11,17 +11,12 @@
11
11
  * call `mergeReports`, then persist / relocate attachments / re-render as
12
12
  * needed. Keeping the merge pure makes it trivial to test and reason about.
13
13
  */
14
- import type { DonobuReport, HealedTestDescriptor } from './model';
14
+ import type { DonobuReport } from './model';
15
15
  export interface MergeReportsParams {
16
16
  /** Pre-loaded initial report, or null when the initial run produced none. */
17
17
  initialReport: DonobuReport | null;
18
18
  /** Pre-loaded heal-run report, or null when the heal run produced none. */
19
19
  healReport: DonobuReport | null;
20
- /** Tests the orchestrator declared healed — used when the heal report
21
- * doesn't expose them under a matching key (e.g. filter rewrites). */
22
- healedTests: HealedTestDescriptor[];
23
- /** Whether the heal rerun exited cleanly. */
24
- healSucceeded: boolean;
25
20
  /** Recorded in the merged report metadata for triage auto-discovery. */
26
21
  triageRunDir?: string;
27
22
  /** Recorded in the merged report metadata purely for provenance. */
@@ -15,6 +15,8 @@
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.mergeReports = mergeReports;
17
17
  exports.buildTestKey = buildTestKey;
18
+ const model_1 = require("./model");
19
+ const reportWalk_1 = require("./reportWalk");
18
20
  function mergeReports(params) {
19
21
  const { initialReport, healReport } = params;
20
22
  if (!initialReport && !healReport) {
@@ -29,7 +31,17 @@ function mergeReports(params) {
29
31
  if (healReport) {
30
32
  const processedHealEntries = new Set();
31
33
  const processHealEntry = (healEntry) => {
32
- const key = buildTestKey(healEntry.suite.file, healEntry.test.projectName, healEntry.test.title);
34
+ // Tests the rerun's collection gate statically skipped carry zero
35
+ // information — the initial run's result for them stands untouched, so
36
+ // their heal entries are dropped wholesale (no appended attempts, no
37
+ // status churn, no skip noise in the merged report).
38
+ if (healEntry.test.annotations?.some((annotation) => annotation.type === model_1.HEAL_SKIP_REPLAY_ANNOTATION_TYPE)) {
39
+ return;
40
+ }
41
+ // Titles live on the spec in both report shapes (the Donobu state file
42
+ // and Playwright's native JSON); `test.title` is never set. Without the
43
+ // spec fallback all tests in a file/project collapse to one key.
44
+ const key = buildTestKey(healEntry.suite.file, healEntry.test.projectName, healEntry.test.title ?? healEntry.spec.title);
33
45
  let combinedEntry = (healEntry.test.testId
34
46
  ? combinedIndex.byId.get(healEntry.test.testId)
35
47
  : undefined) ??
@@ -54,16 +66,47 @@ function mergeReports(params) {
54
66
  ...healEntry.test.results,
55
67
  ];
56
68
  }
57
- if (healEntry.test.status !== undefined) {
58
- combinedTest.status = healEntry.test.status;
59
- }
60
- if (healEntry.test.outcome !== undefined) {
61
- combinedTest.outcome = healEntry.test.outcome;
62
- }
63
69
  const originalStatus = originalEntry
64
70
  ? getFinalResultStatus(originalEntry.test)
65
71
  : undefined;
66
72
  const healStatus = getFinalResultStatus(healEntry.test);
73
+ const originalFailed = originalStatus !== undefined &&
74
+ originalStatus !== 'passed' &&
75
+ originalStatus !== 'skipped';
76
+ // The heal rerun may only improve a test's outcome:
77
+ // - It must not relabel a genuine failure as "skipped" (a rerun in
78
+ // which the test skipped itself — e.g. a precondition guard fired —
79
+ // used to turn red runs green).
80
+ // - It must not flip an initially-passing test red: rerun failures of
81
+ // tests that tagged along (serial siblings, dependency projects) are
82
+ // advisory, recorded in the attempt history and an annotation.
83
+ const adoptHealStatus = healStatus === 'passed' ||
84
+ (originalStatus !== 'passed' && healStatus !== 'skipped');
85
+ if (adoptHealStatus) {
86
+ if (healEntry.test.status !== undefined) {
87
+ combinedTest.status = healEntry.test.status;
88
+ }
89
+ if (healEntry.test.outcome !== undefined) {
90
+ combinedTest.outcome = healEntry.test.outcome;
91
+ }
92
+ }
93
+ else if (originalFailed && healStatus === 'skipped') {
94
+ combinedTest.annotations = combinedTest.annotations ?? [];
95
+ combinedTest.annotations.push({
96
+ type: 'auto-heal-not-reattempted',
97
+ description: 'The auto-heal rerun could not re-attempt this test: it skipped itself during the rerun because a precondition set up by another test was missing. The original failure stands. To make this test heal-eligible, declare the ordering explicitly — via Playwright project `dependencies` or `test.describe.serial` — so the rerun can execute the prerequisites.',
98
+ });
99
+ }
100
+ else if (originalStatus === 'passed' &&
101
+ healStatus !== undefined &&
102
+ healStatus !== 'passed' &&
103
+ healStatus !== 'skipped') {
104
+ combinedTest.annotations = combinedTest.annotations ?? [];
105
+ combinedTest.annotations.push({
106
+ type: 'auto-heal-rerun-failed',
107
+ description: 'This test passed in the initial run but failed when re-run during the auto-heal pass. The initial result stands; the failed rerun attempt is preserved in the attempt history.',
108
+ });
109
+ }
67
110
  if (healStatus === 'passed' &&
68
111
  originalStatus &&
69
112
  originalStatus !== 'passed') {
@@ -90,26 +133,6 @@ function mergeReports(params) {
90
133
  iterateEntries(healIndex.byId);
91
134
  iterateEntries(healIndex.byKey);
92
135
  }
93
- if (params.healSucceeded && healedKeys.size === 0) {
94
- params.healedTests.forEach((descriptor) => {
95
- // Descriptors must arrive with `testCase.file` already normalized to the
96
- // same form that suite.file has in the reports — the caller owns path
97
- // normalization because it has access to the CWD the run was launched in.
98
- const key = buildTestKey(descriptor.testCase.file, descriptor.testCase.projectName, descriptor.testCase.title);
99
- const entry = combinedIndex.byKey.get(key);
100
- if (entry) {
101
- entry.test.annotations = entry.test.annotations ?? [];
102
- if (!entry.test.annotations.some((annotation) => annotation.type === 'self-healed')) {
103
- entry.test.annotations.push({
104
- type: 'self-healed',
105
- description: 'Automatically healed by Donobu auto-heal rerun after applying treatment plan.',
106
- });
107
- }
108
- entry.test.donobuStatus = 'healed';
109
- healedKeys.add(key);
110
- }
111
- });
112
- }
113
136
  combined.stats = computeReportStats(combined);
114
137
  const mergedMetadata = {
115
138
  ...(combined.metadata ?? {}),
@@ -152,7 +175,7 @@ function indexReport(report) {
152
175
  if (test.testId) {
153
176
  byId.set(test.testId, entry);
154
177
  }
155
- const key = buildTestKey(suite.file, test.projectName, test.title);
178
+ const key = buildTestKey(suite.file, test.projectName, test.title ?? spec.title);
156
179
  byKey.set(key, entry);
157
180
  });
158
181
  });
@@ -195,9 +218,13 @@ function computeReportStats(report) {
195
218
  if (finalResult?.duration) {
196
219
  duration += finalResult.duration;
197
220
  }
198
- const status = finalResult?.status ?? test.status;
199
- switch (status) {
221
+ // Classify from the full attempt history so a heal-rerun skip can't
222
+ // hide an earlier genuine failure, retry recoveries count as flaky,
223
+ // and expected failures (`test.fail()`) count as expected.
224
+ switch ((0, reportWalk_1.statusOf)(test)) {
200
225
  case 'passed':
226
+ case 'expectedFailure':
227
+ case 'healed':
201
228
  expected += 1;
202
229
  break;
203
230
  case 'skipped':
@@ -206,11 +233,6 @@ function computeReportStats(report) {
206
233
  case 'flaky':
207
234
  flaky += 1;
208
235
  break;
209
- case 'failed':
210
- case 'timedOut':
211
- case 'interrupted':
212
- unexpected += 1;
213
- break;
214
236
  default:
215
237
  unexpected += 1;
216
238
  }
@@ -21,6 +21,15 @@
21
21
  * stable across Donobu versions.
22
22
  */
23
23
  export declare const DONOBU_REPORT_STATE_FILENAME = ".donobu-report-state.json";
24
+ /**
25
+ * Annotation type stamped on tests the auto-heal rerun statically skipped
26
+ * because they were not part of the rerun plan (they passed the initial run
27
+ * and were not prerequisites of any heal target). The merge step drops these
28
+ * heal-run entries entirely: they carry no information, and the initial run's
29
+ * result for those tests stands untouched. Defined here (rather than in the
30
+ * test-side gate) so the pure reporter modules don't import test runtime code.
31
+ */
32
+ export declare const HEAL_SKIP_REPLAY_ANNOTATION_TYPE = "donobu-heal-skip-replay";
24
33
  /**
25
34
  * Per-format output record written by each Donobu reporter into the shared
26
35
  * state file. The auto-heal orchestrator reads this map after merging two
@@ -14,7 +14,7 @@
14
14
  * retype the whole Playwright reporter surface.
15
15
  */
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.DONOBU_REPORT_STATE_FILENAME = void 0;
17
+ exports.HEAL_SKIP_REPLAY_ANNOTATION_TYPE = exports.DONOBU_REPORT_STATE_FILENAME = void 0;
18
18
  /**
19
19
  * Filename the reporter writes into each run's Playwright output directory.
20
20
  * The auto-heal orchestrator looks for this file (in both the initial run's
@@ -24,4 +24,13 @@ exports.DONOBU_REPORT_STATE_FILENAME = void 0;
24
24
  * stable across Donobu versions.
25
25
  */
26
26
  exports.DONOBU_REPORT_STATE_FILENAME = '.donobu-report-state.json';
27
+ /**
28
+ * Annotation type stamped on tests the auto-heal rerun statically skipped
29
+ * because they were not part of the rerun plan (they passed the initial run
30
+ * and were not prerequisites of any heal target). The merge step drops these
31
+ * heal-run entries entirely: they carry no information, and the initial run's
32
+ * result for those tests stands untouched. Defined here (rather than in the
33
+ * test-side gate) so the pure reporter modules don't import test runtime code.
34
+ */
35
+ exports.HEAL_SKIP_REPLAY_ANNOTATION_TYPE = 'donobu-heal-skip-replay';
27
36
  //# sourceMappingURL=model.js.map
@@ -253,18 +253,10 @@ function extractTests(jsonData) {
253
253
  for (const test of spec.tests ?? []) {
254
254
  const annotations = test.annotations ?? [];
255
255
  const isSelfHealed = (0, reportWalk_1.isSelfHealed)(test);
256
- let status;
257
- const lastResult = test.results?.at(-1);
258
- if (test.status === 'skipped' ||
259
- (!lastResult && test.status === undefined)) {
260
- status = 'skipped';
261
- }
262
- else if (isSelfHealed) {
263
- status = 'healed';
264
- }
265
- else {
266
- status = lastResult?.status ?? 'unknown';
267
- }
256
+ // Derived from the full attempt history (see reportWalk.statusOf):
257
+ // surviving failures stay failed even when a heal-rerun skip is the
258
+ // final attempt, and retry recoveries surface as 'flaky'.
259
+ const status = (0, reportWalk_1.statusOf)(test);
268
260
  const objectiveAnnotation = annotations.find((a) => a.type === 'objective');
269
261
  const results = (test.results ?? []).map((r, i) => {
270
262
  const attachments = r.attachments ?? [];
@@ -394,6 +386,18 @@ const STATUS_CFG = {
394
386
  bg: 'rgba(16,185,129,0.08)',
395
387
  icon: '&#10003;',
396
388
  },
389
+ flaky: {
390
+ label: 'Flaky',
391
+ color: '#eab308',
392
+ bg: 'rgba(234,179,8,0.08)',
393
+ icon: '&#8635;',
394
+ },
395
+ expectedFailure: {
396
+ label: 'Expected Failure',
397
+ color: '#14b8a6',
398
+ bg: 'rgba(20,184,166,0.08)',
399
+ icon: '&#9745;',
400
+ },
397
401
  failed: {
398
402
  label: 'Failed',
399
403
  color: '#ef4444',
@@ -1524,6 +1528,8 @@ function renderHtml(report, triage, outputDir) {
1524
1528
  // Counts
1525
1529
  const counts = {
1526
1530
  passed: 0,
1531
+ flaky: 0,
1532
+ expectedFailure: 0,
1527
1533
  failed: 0,
1528
1534
  healed: 0,
1529
1535
  timedOut: 0,
@@ -1566,6 +1572,8 @@ function renderHtml(report, triage, outputDir) {
1566
1572
  // Build test bar blocks (one square per test, ordered by status, clickable)
1567
1573
  const statusOrder = [
1568
1574
  'passed',
1575
+ 'flaky',
1576
+ 'expectedFailure',
1569
1577
  'healed',
1570
1578
  'failed',
1571
1579
  'timedOut',
@@ -1594,6 +1602,18 @@ function renderHtml(report, triage, outputDir) {
1594
1602
  icon: '&#10003;',
1595
1603
  iconClass: 'icon-pass',
1596
1604
  },
1605
+ {
1606
+ key: 'flaky',
1607
+ label: 'Flaky',
1608
+ icon: '&#8635;',
1609
+ iconClass: 'icon-flaky',
1610
+ },
1611
+ {
1612
+ key: 'expectedFailure',
1613
+ label: 'Expected Failures',
1614
+ icon: '&#9745;',
1615
+ iconClass: 'icon-expected-failure',
1616
+ },
1597
1617
  { key: 'healed', label: 'Healed', icon: '&#9829;', iconClass: 'icon-heal' },
1598
1618
  { key: 'failed', label: 'Failed', icon: '&#9888;', iconClass: 'icon-fail' },
1599
1619
  {
@@ -1793,6 +1813,8 @@ body::before{content:'';position:fixed;top:-750px;left:50%;transform:translateX(
1793
1813
  .test-bar-block[data-tooltip]:hover::after{content:attr(data-tooltip);position:absolute;top:calc(100% + 8px);left:50%;transform:translateX(-50%);background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:var(--radius);padding:6px 10px;font-size:11px;font-family:var(--font);white-space:nowrap;z-index:10;pointer-events:none;box-shadow:0 4px 12px rgba(0,0,0,.2)}
1794
1814
  .test-bar-block[data-tooltip]:hover::before{content:'';position:absolute;top:calc(100% + 2px);left:50%;transform:translateX(-50%);border:5px solid transparent;border-bottom-color:var(--border);z-index:10;pointer-events:none}
1795
1815
  .test-bar-block.bar-passed{background:var(--bar-pass)}
1816
+ .test-bar-block.bar-flaky{background:var(--bar-warn)}
1817
+ .test-bar-block.bar-expectedfailure{background:var(--bar-pass);opacity:.55}
1796
1818
  .test-bar-block.bar-healed{background:var(--bar-heal)}
1797
1819
  .test-bar-block.bar-failed{background:var(--bar-fail)}
1798
1820
  .test-bar-block.bar-timedout,.test-bar-block.bar-interrupted{background:var(--bar-warn)}