@piwitests/reporter 0.69.0 → 0.71.0

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.
@@ -1,6 +1,90 @@
1
- import { P as ProbeArg, a as ProbedAttrs } from '../../types-CGr9jJZ_.js';
2
1
  import { Page, TestInfo, TestType, Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, Locator } from '@playwright/test';
3
- import { L as LocatorPageUse, P as ProcessRole, R as RoleCost } from '../../wire-7zsqlBoY.js';
2
+
3
+ /** Arguments for `probeElementAttrs` — the role maps mirror the single source of truth in `@piwitests/core`. */
4
+ interface ProbeArg {
5
+ /** Attribute whitelist to read off the element (the shared `CAPTURED_ATTRIBUTES`). */
6
+ keep: string[];
7
+ /** Required when `includeStructural` is true — role resolution needs the tag/input-type role maps. */
8
+ tagRoles?: Record<string, string>;
9
+ inputRoles?: Record<string, string>;
10
+ /** CSS selector matching every element role resolution can reach (also structural-only). */
11
+ roleSources?: string;
12
+ /** Compute `rolePosition` and ancestor-anchor candidates. The live picker always wants these; the snapshot picker never does (no anchors step there). */
13
+ includeStructural: boolean;
14
+ /**
15
+ * Count how many elements each candidate matches: `selectorCounts`,
16
+ * `rolePosition` and every anchor's counts, each a walk of the document or
17
+ * of an ancestor's subtree. True unless set: a caller that counts with an
18
+ * index of its own turns it off, and the anchors then carry what identifies
19
+ * them and no count, whatever the size of the page.
20
+ */
21
+ countMatches?: boolean;
22
+ /**
23
+ * The attribute `getByTestId` reads in the project (Playwright's
24
+ * `testIdAttribute`); `data-testid` when null or absent. It is read with
25
+ * `keep`, counted for `selectorCounts.testId`, read off each ancestor for its
26
+ * `testId` and `testIdCount`, and never taken as an ancestor's `dataAttr`;
27
+ * any other `data-*`, `data-testid` included, is an ordinary one.
28
+ */
29
+ testIdAttribute?: string | null;
30
+ }
31
+ /** Element shape the in-page probe returns — structural view of what the picker overlays need. */
32
+ interface ProbedAttrs {
33
+ tagName: string;
34
+ attributes: Record<string, string | null>;
35
+ textContent: string;
36
+ center: {
37
+ x: number;
38
+ y: number;
39
+ };
40
+ hasLabel: boolean;
41
+ /** Text of the elements `aria-labelledby` points at, else of the first associated `<label>`. */
42
+ labelText: string | null;
43
+ selectorCounts: {
44
+ testId?: number;
45
+ id?: number;
46
+ name?: number;
47
+ classes?: Record<string, number>;
48
+ /** How many elements share this element's role *and* exact accessible name (`getByRole(role, { name })` without `exact` also matches names that contain it). */
49
+ roleName?: number;
50
+ /** Of the `roleName` matches, how many are laid out (a box, or an `offsetParent`) — what `getByRole(role, { name }).visible()` would match. */
51
+ visibleRoleName?: number;
52
+ /** How many elements `getByText` would match on this element's text, counted no further than 2 — every consumer only asks whether that is exactly one. Undefined when the element has no text, or the subtree was too large to scan. */
53
+ text?: number;
54
+ /** How many elements share this element's `placeholder` — what `getByPlaceholder` would really match. */
55
+ placeholder?: number;
56
+ /** How many elements share this element's `alt` — what `getByAltText` would really match. */
57
+ alt?: number;
58
+ /** How many elements share this element's `title` — what `getByTitle` would really match. */
59
+ title?: number;
60
+ };
61
+ rolePosition?: {
62
+ role: string;
63
+ count: number;
64
+ index: number;
65
+ levelCount?: number;
66
+ } | null;
67
+ ancestors?: Array<{
68
+ tag: string;
69
+ depth: number;
70
+ testId: string | null;
71
+ id: string | null;
72
+ role: string | null;
73
+ ariaLabel: string | null;
74
+ scopedRoleCount?: number;
75
+ scopedTextCount?: number;
76
+ testIdCount?: number;
77
+ idCount?: number;
78
+ roleCount?: number;
79
+ dataAttr?: {
80
+ name: string;
81
+ value: string;
82
+ };
83
+ dataAttrCount?: number;
84
+ filterText?: string;
85
+ filterRoleCount?: number;
86
+ }>;
87
+ }
4
88
 
5
89
  /**
6
90
  * Runs inside the browser via `evaluate()` (live picker) or as part of a
@@ -61,6 +145,47 @@ interface PageInteraction {
61
145
  indeterminate?: ElementRef[];
62
146
  }
63
147
 
148
+ /**
149
+ * Wire leaf shapes — the small, identical building blocks of the JSON contract
150
+ * exchanged between the reporter and the server. The single source of truth
151
+ * shared by the app (`#shared/types`) and the reporter (`types/wire.ts`).
152
+ *
153
+ * The per-case *payloads* are intentionally NOT here: the reporter produces a
154
+ * loose `WireTestCase` superset while the server receives the stricter
155
+ * `TestCasePayload` / `StreamEventPayload`. Those live on each side and are kept
156
+ * field-compatible by `apps/application/tests/unit/wire-shared-drift.test.ts`.
157
+ */
158
+
159
+ /**
160
+ * One locator call and the page it ran on, as the capture fixtures record it
161
+ * in the `piwi-locator-pages` attachment: a test's calls, deduped by call
162
+ * site, chain and page. The dashboard joins it to the locator index, so a use
163
+ * of a chain knows the pages it was made on.
164
+ */
165
+ interface LocatorPageUse {
166
+ /** `file:line:col` of the call, as a step location reports it (absolute; the server makes it project-relative). */
167
+ location: string;
168
+ /** The chain as Playwright prints it (`Locator.toString()`). */
169
+ locator: string;
170
+ /** The page's origin (`https://shop.test`), to tell the application's pages from third-party ones. */
171
+ origin: string;
172
+ /** The page key: the path with ids and tokens collapsed, no query, no hash (`/orders/:id`). */
173
+ page: string;
174
+ /** No locator interaction happened on the page since it was navigated to: the element was there as it loaded. */
175
+ arrival: boolean;
176
+ }
177
+ /** What a process is for the run, from its command line. */
178
+ type ProcessRole = 'runner' | 'worker' | 'browser' | 'renderer' | 'gpu' | 'utility' | 'ffmpeg' | 'webServer' | 'other';
179
+ /** What the processes of one role used during a test. */
180
+ interface RoleCost {
181
+ cpuMs: number;
182
+ /** Time runnable but waiting for a CPU. */
183
+ runWaitMs: number | null;
184
+ /** The largest process of the role during the test (its peak RSS). */
185
+ peakRssMb: number | null;
186
+ processes: number;
187
+ }
188
+
64
189
  /** A main-frame navigation, full or same-document: the page starts over. */
65
190
  declare function noteNavigation(page: object): void;
66
191
  /**
@@ -138,7 +263,7 @@ interface LiveCall {
138
263
  * `PIWI_RECORD_CHANNEL` is (`formatRecordChannel`, `parseRecordChannel`). Its first line, `run-attach`, tells it from a
139
264
  * hand-off's `attach`. Over it the worker says which test it runs and where it stopped, and the editor service steers
140
265
  * it: pause, step, resume, finish, run to a line, end the test, the breakpoints, an image of the stopped page, and, at
141
- * a stop the pause bar shows, the bar's own **Pick a locator** and **Record here**, the check panel's **Check an
266
+ * a stop the pause bar shows, the bar's own **Pick a locator** and **Record**, the check panel's **Check an
142
267
  * element** and a region's ARIA snapshot, started from outside the page; at any stop, the responses the test kept (an
143
268
  * interactive run keeps the text bodies of its pages' fetch and XHR answers), one of them to mock, and a locator's
144
269
  * matches; and, for a viewer outside the page, the stopped page's live view (`@piwitests/core/run-view`: its frames,
@@ -159,7 +284,7 @@ interface LiveCall {
159
284
 
160
285
  /**
161
286
  * What a stop the pause bar shows starts from outside the page, in the test's window: the bar's **Pick a locator**
162
- * (`pick`) and **Record here** (`record`), their results going where the bar's go; the check panel's **Check an
287
+ * (`pick`) and **Record** (`record`), their results going where the bar's go; the check panel's **Check an
163
288
  * element** (`assert`), through the record channel's hand-off in its `check` mode, the editor service writing the
164
289
  * check; and a region picked with the bar's picker (`assert-region`), whose ARIA snapshot the worker reads and sends
165
290
  * (`region`).
@@ -177,7 +302,7 @@ interface IntentAnswer {
177
302
  }
178
303
 
179
304
  /**
180
- * The pause bar's Pick a locator and Record here, started from outside the page (the editor's hub, for Piwi Picker):
305
+ * The pause bar's Pick a locator and Record, started from outside the page (the editor's hub, for Piwi Picker):
181
306
  * the bar takes an intent while it waits for its answer, and one handed to it while it is about to (its highlight
182
307
  * still drawing) waits for it; while a pick or a recording runs, none is taken. Each action in the test's window that
183
308
  * takes Escape as its own (a pick, a check, a region's pick: `RunActing`), the bar's own or an intent, is said to `said`
@@ -930,8 +1055,8 @@ declare function buildPageState(raw: RawPageState, cookies: Array<Record<string,
930
1055
  * action. `tagRoles`/`inputRoles` are the shared role maps (single source of
931
1056
  * truth in `locator-healing.ts`), and `roleSources` is the CSS selector for
932
1057
  * every element the probe can resolve a role for — all derived from the map so
933
- * nothing is hand-maintained twice. Exported so the dogfood mirror
934
- * (`application/tests/fixtures.ts`) reuses the same assembled object.
1058
+ * nothing is hand-maintained twice. Exported so every caller of the probe
1059
+ * passes the same assembled object.
935
1060
  */
936
1061
  declare const CAPTURED_ATTRS_ARG: ProbeArg;
937
1062
  /**
@@ -1060,4 +1185,4 @@ declare const piwiFixtures: Fixtures<PiwiFixtures, PiwiWorkerFixtures, Playwrigh
1060
1185
  */
1061
1186
  declare function extendPiwiFixtures<TestArgs extends FixtureArgs, WorkerArgs extends FixtureArgs>(test: TestType<TestArgs, WorkerArgs>): TestType<TestArgs & PiwiFixtures, WorkerArgs & PiwiWorkerFixtures>;
1062
1187
 
1063
- export { CAPTURED_ATTRS_ARG, type IntentStop, LocatorPageLog, type PageState, type PiwiFixtures, type PiwiWorkerFixtures, ProbeArg, ProbedAttrs, type RawPageState, type RawVitalEntry, activeResourceLedger, ariaSnapshotBestEffort, ariaSnapshotJSONBestEffort, boxCaptureFrames, buildPageState, callMethod, codeReachRoots, computeCoreVitals, configuredCodeReachRoots, errorPlace, extendPiwiFixtures, failureError, intentAt, internalCall, noteLocatorCall, noteNavigation, noteResourceUse, pageMapFetcher, piwiFixtures, probeElementAttrs, readPageInteraction, recordResourceCensus, resolveCodeReach, runnerTraceSnapshots, runnerTraces, runningCall, startCodeReach, startResourceLedger, stopCodeReach, stopResourceLedger };
1188
+ export { CAPTURED_ATTRS_ARG, type IntentStop, LocatorPageLog, type PageState, type PiwiFixtures, type PiwiWorkerFixtures, type ProbeArg, type ProbedAttrs, type RawPageState, type RawVitalEntry, activeResourceLedger, ariaSnapshotBestEffort, ariaSnapshotJSONBestEffort, boxCaptureFrames, buildPageState, callMethod, codeReachRoots, computeCoreVitals, configuredCodeReachRoots, errorPlace, extendPiwiFixtures, failureError, intentAt, internalCall, noteLocatorCall, noteNavigation, noteResourceUse, pageMapFetcher, piwiFixtures, probeElementAttrs, readPageInteraction, recordResourceCensus, resolveCodeReach, runnerTraceSnapshots, runnerTraces, runningCall, startCodeReach, startResourceLedger, stopCodeReach, stopResourceLedger };
@@ -1250,26 +1250,70 @@ function showPauseBar(arg) {
1250
1250
  bar.remove();
1251
1251
  delete g.__piwiPauseCleanup;
1252
1252
  };
1253
- const buttons = [
1253
+ const glyphs = {
1254
+ resume: ["fill:M5 3.2v9.6l7.5-4.8z"],
1255
+ step: ["M3 9.5a5 5 0 0 1 10 0", "M11 7.7l2 2 2-2", "fill:M6.9 13a1.1 1.1 0 1 0 2.2 0a1.1 1.1 0 1 0-2.2 0z"],
1256
+ finish: ["M8 11V3", "M5 6l3-3 3 3", "M4 13.5h8"],
1257
+ end: ["M2.5 8a5.5 5.5 0 1 0 11 0a5.5 5.5 0 1 0-11 0z", "M4.1 4.1l7.8 7.8"],
1258
+ pick: ["M2.5 8a5.5 5.5 0 1 0 11 0a5.5 5.5 0 1 0-11 0z", "fill:M6.5 8a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0z"],
1259
+ record: ["fill:M3.5 8a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0-9 0z"]
1260
+ };
1261
+ const SVG = "http://www.w3.org/2000/svg";
1262
+ const glyph = (choice) => {
1263
+ const svg = doc.createElementNS(SVG, "svg");
1264
+ svg.setAttribute("viewBox", "0 0 16 16");
1265
+ svg.setAttribute("aria-hidden", "true");
1266
+ svg.setAttribute("data-piwi-glyph", choice);
1267
+ svg.style.cssText = "flex:none;display:block;width:14px;height:14px;margin:0;padding:0;overflow:visible;";
1268
+ for (const part of glyphs[choice] ?? []) {
1269
+ const path23 = doc.createElementNS(SVG, "path");
1270
+ const filled = part.startsWith("fill:");
1271
+ path23.setAttribute("d", filled ? part.slice(5) : part);
1272
+ path23.style.cssText = filled ? "fill:currentColor;stroke:none;" : "fill:none;stroke:currentColor;stroke-width:1.5px;stroke-linecap:round;stroke-linejoin:round;";
1273
+ svg.appendChild(path23);
1274
+ }
1275
+ return svg;
1276
+ };
1277
+ const steering = [
1254
1278
  arg.failure ? ["Resume", "resume", "Let the test end as it failed (Esc)", true] : ["Resume", "resume", "Run on to the next breakpoint (Esc)", true],
1255
1279
  ...arg.failure ? [] : [["Step", "step", "Pause again before the next call", false]],
1256
- ["Pick a locator", "pick", "Pick an element on the page and confirm a locator for it", false],
1257
- ...arg.record ? [
1258
- ["Record here", "record", "Record steps in this page: the editor writes them before this line", false]
1259
- ] : [],
1260
1280
  ...arg.failure ? [] : [
1261
- ["Finish", "finish", "Run the test on without stopping at a breakpoint again in this attempt", false]
1281
+ [
1282
+ "Finish",
1283
+ "finish",
1284
+ "Run the test on without stopping at a breakpoint again in this attempt",
1285
+ false
1286
+ ]
1262
1287
  ],
1263
- ...arg.end && !arg.failure ? [
1264
- ["End the test", "end", "Skip the rest of this test: it is reported as skipped", false]
1288
+ ...arg.end && !arg.failure ? [["End the test", "end", "Skip the rest of this test: it is reported as skipped", false]] : []
1289
+ ];
1290
+ const code = [
1291
+ ["Pick a locator", "pick", "Pick an element on the page and confirm a locator for it", false],
1292
+ ...arg.record ? [
1293
+ [
1294
+ "Record",
1295
+ "record",
1296
+ "Record steps in this page: the editor writes them before this line",
1297
+ false
1298
+ ]
1265
1299
  ] : []
1266
1300
  ];
1267
- for (const [label, choice, hint, primary] of buttons) {
1301
+ const buttons = [...steering, "divider", ...code];
1302
+ for (const entry of buttons) {
1303
+ if (entry === "divider") {
1304
+ const divider = doc.createElement("span");
1305
+ divider.setAttribute("aria-hidden", "true");
1306
+ divider.style.cssText = "width:1px;align-self:stretch;margin:2px 4px;background:#374151;";
1307
+ bar.appendChild(divider);
1308
+ continue;
1309
+ }
1310
+ const [label, choice, hint, primary] = entry;
1268
1311
  const btn = doc.createElement("button");
1269
1312
  btn.type = "button";
1270
- btn.textContent = label;
1313
+ btn.appendChild(glyph(choice));
1314
+ btn.appendChild(doc.createTextNode(label));
1271
1315
  btn.title = hint;
1272
- btn.style.cssText = "border-radius:6px;padding:4px 12px;cursor:pointer;font:600 12px/1.5 system-ui,sans-serif;" + (primary ? "background:#7c3aed;color:#fff;border:1px solid #7c3aed;" : "background:#1f2937;color:#f3f4f6;border:1px solid #374151;");
1316
+ btn.style.cssText = "display:inline-flex;align-items:center;gap:6px;border-radius:6px;padding:4px 12px 4px 10px;cursor:pointer;font:600 12px/1.5 system-ui,sans-serif;" + (primary ? "background:#7c3aed;color:#fff;border:1px solid #7c3aed;" : "background:#1f2937;color:#f3f4f6;border:1px solid #374151;");
1273
1317
  btn.addEventListener("click", (e) => {
1274
1318
  e.preventDefault();
1275
1319
  e.stopImmediatePropagation();
@@ -4238,6 +4282,23 @@ function isSecretValue(value) {
4238
4282
  return /^[A-Za-z0-9+/_-]{40,}={0,2}$/.test(text) && looksRandom(text);
4239
4283
  }
4240
4284
  var URL_IN_TEXT = /\b[a-z][a-z0-9+.-]{0,31}:\/\/[^\s"'<>`]+/gi;
4285
+ function urlEndInText(url) {
4286
+ const counts = { "(": 0, ")": 0, "[": 0, "]": 0 };
4287
+ for (const c of url) if (c in counts) counts[c]++;
4288
+ let end = url.length;
4289
+ while (end > 0) {
4290
+ const last = url[end - 1];
4291
+ if (".,;:!?".includes(last)) {
4292
+ end--;
4293
+ continue;
4294
+ }
4295
+ const open4 = last === ")" ? "(" : last === "]" ? "[" : "";
4296
+ if (!open4 || counts[open4] >= counts[last]) break;
4297
+ counts[last]--;
4298
+ end--;
4299
+ }
4300
+ return end;
4301
+ }
4241
4302
  var URL_PARTS = /^(?:([a-z][a-z0-9+.-]*:)?\/\/([^/?#]*))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?$/i;
4242
4303
  function decodeSafe(text) {
4243
4304
  try {
@@ -4354,8 +4415,9 @@ function hideSecretsInText(text, count = { n: 0 }) {
4354
4415
  let out = "";
4355
4416
  let last = 0;
4356
4417
  for (const url of text.matchAll(URL_IN_TEXT)) {
4357
- out += hideInText(text.slice(last, url.index), count) + hideSecretsInUrl(url[0], count);
4358
- last = url.index + url[0].length;
4418
+ const end = urlEndInText(url[0]);
4419
+ out += hideInText(text.slice(last, url.index), count) + hideSecretsInUrl(url[0].slice(0, end), count);
4420
+ last = url.index + end;
4359
4421
  }
4360
4422
  return out + hideInText(text.slice(last), count);
4361
4423
  }
@@ -5519,20 +5581,26 @@ async function pickLocator(page, probe, failing, ended) {
5519
5581
  const wait = page.waitForFunction(
5520
5582
  ([key, endedKey]) => {
5521
5583
  const g = globalThis;
5522
- if (g[endedKey] !== true) return g[key] !== void 0;
5523
- delete g[endedKey];
5524
- return true;
5584
+ if (g[endedKey] === true) {
5585
+ delete g[endedKey];
5586
+ return true;
5587
+ }
5588
+ if (g[key] !== void 0) return true;
5589
+ const shown2 = ["__piwiPickCleanup", "__piwiAnchorCleanup", "__piwiChoiceCleanup"].some(
5590
+ (cleanup) => typeof g[cleanup] === "function"
5591
+ );
5592
+ return shown2 ? false : "gone";
5525
5593
  },
5526
5594
  [name, PICK_ENDED],
5527
5595
  { timeout: 0, polling: 250 }
5528
5596
  );
5529
5597
  polling = true;
5530
- const done = await unlessEnded(
5531
- wait.then(() => true),
5598
+ const outcome = await unlessEnded(
5599
+ wait.then((handle) => handle.jsonValue()),
5532
5600
  ended
5533
5601
  );
5534
- if (done) polling = false;
5535
- return !ended?.aborted;
5602
+ if (outcome !== void 0) polling = false;
5603
+ return !ended?.aborted && outcome !== "gone";
5536
5604
  };
5537
5605
  try {
5538
5606
  const overlayArg = { transport: "global", failing };
@@ -7361,7 +7429,7 @@ async function pauseHere(page, point, probe, onPick, onRecord, ended, intents, o
7361
7429
  ...point.end ? { end: true } : {}
7362
7430
  };
7363
7431
  console.log(
7364
- point.failure ? `[piwi] The test failed at ${callSiteLine(point.location)}: Resume, Pick a locator${onRecord ? " or Record here" : ""} in the browser (Esc resumes, and the test ends as it failed).` : `[piwi] Paused at ${callSiteLine(point.location)} before ${call}: Resume, Step, Pick a locator${onRecord ? ", Record here" : ""}, Finish${point.end ? " or End the test" : ""} in the browser (Esc resumes).`
7432
+ point.failure ? `[piwi] The test failed at ${callSiteLine(point.location)}: Resume, Pick a locator${onRecord ? " or Record" : ""} in the browser (Esc resumes, and the test ends as it failed).` : `[piwi] Paused at ${callSiteLine(point.location)} before ${call}: Resume, Step, Finish${point.end ? ", End the test" : ""}, then Pick a locator${onRecord ? " or Record" : ""} in the browser (Esc resumes).`
7365
7433
  );
7366
7434
  let navigated = 0;
7367
7435
  for (; ; ) {
@@ -8431,7 +8499,7 @@ var RUN_TAKES = [
8431
8499
  ];
8432
8500
  var RUN_INTENT_NAMES = {
8433
8501
  pick: "Pick a locator",
8434
- record: "Record here",
8502
+ record: "Record",
8435
8503
  assert: "Assert",
8436
8504
  "assert-region": "Assert a region"
8437
8505
  };
@@ -17224,12 +17292,16 @@ function instrumentContext(context) {
17224
17292
  }
17225
17293
  context.on("page", (page) => instrumentPage(page));
17226
17294
  }
17295
+ function runsNoScript(options) {
17296
+ return options?.javaScriptEnabled === false;
17297
+ }
17227
17298
  function patchBrowser(browser) {
17228
17299
  if (!browser || PATCHED_BROWSERS.has(browser)) return;
17229
17300
  PATCHED_BROWSERS.add(browser);
17230
17301
  const originalNewPage = browser.newPage.bind(browser);
17231
17302
  browser.newPage = async (...args) => {
17232
17303
  const page = await originalNewPage(...args);
17304
+ if (runsNoScript(args[0])) return page;
17233
17305
  instrumentPage(page);
17234
17306
  await armStops([pageContext(page)]);
17235
17307
  await awaitFlakeConditions();
@@ -17242,6 +17314,7 @@ function patchBrowser(browser) {
17242
17314
  const emulation = flake?.role === "target" ? flakeContextOptions(flake.plan) : null;
17243
17315
  const context = await originalNewContext(...emulation ? [{ ...args[0], ...emulation }] : args);
17244
17316
  if (emulation) markFlakeContext(context);
17317
+ if (runsNoScript(args[0])) return context;
17245
17318
  instrumentContext(context);
17246
17319
  await armStops([context]);
17247
17320
  return context;
@@ -17619,7 +17692,8 @@ function testEnd(sink, testInfo) {
17619
17692
  type: "test-end",
17620
17693
  testId: testInfo.testId,
17621
17694
  status: testInfo.status ?? "passed",
17622
- pausedMs: sink.stops.reduce((sum, stop2) => sum + stop2.duration, 0)
17695
+ pausedMs: sink.stops.reduce((sum, stop2) => sum + stop2.duration, 0),
17696
+ expectedStatus: testInfo.expectedStatus
17623
17697
  };
17624
17698
  }
17625
17699
  var piwiFixtures = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piwitests/reporter",
3
- "version": "0.69.0",
3
+ "version": "0.71.0",
4
4
  "description": "Playwright reporter that streams results, traces and HTML reports to a Piwi Dashboard instance",
5
5
  "url": "https://github.com/PiwiTests/piwi",
6
6
  "homepage": "https://piwitests.dev",
@@ -1,67 +0,0 @@
1
- export { F as FAILURE_SCREENSHOT_ATTACHMENT } from '../../wire-7zsqlBoY.js';
2
-
3
- /**
4
- * Names of the `testInfo` attachments the dashboard fixtures produce and the
5
- * reporter parses. Single source of truth — imported by the producer
6
- * (`capture-fixtures.ts`), the consumers (`reporter.ts` / `file-handler.ts`), and
7
- * the dogfooding `application/tests/fixtures.ts`, so producer and consumer can
8
- * never drift on a name.
9
- */
10
- declare const ATTACHMENT_NAMES: {
11
- readonly locators: "piwi-locators";
12
- readonly ariaSnapshot: "piwi-aria-snapshot";
13
- readonly ariaSnapshotJson: "piwi-aria-snapshot-json";
14
- readonly console: "piwi-console";
15
- readonly dialogs: "piwi-dialogs";
16
- readonly network: "piwi-network";
17
- readonly pageInventory: "piwi-page-inventory";
18
- readonly locatorPages: "piwi-locator-pages";
19
- readonly codeReach: "piwi-code-reach";
20
- readonly browserCoverage: "piwi-browser-coverage";
21
- readonly browserFunctions: "piwi-browser-functions";
22
- readonly browserLines: "piwi-browser-lines";
23
- readonly cssCoverage: "piwi-css-coverage";
24
- readonly cssRules: "piwi-css-rules";
25
- readonly serverCoverageRequests: "piwi-server-coverage-requests";
26
- readonly webVitals: "piwi-web-vitals";
27
- readonly locatorSuggestion: "piwi-locator-suggestion";
28
- readonly pageState: "piwi-page-state";
29
- readonly userPick: "piwi-user-pick";
30
- readonly aiUsage: "piwi-ai-usage";
31
- readonly aiMeta: "piwi-ai-meta";
32
- readonly resources: "piwi-resources";
33
- readonly pauses: "piwi-pauses";
34
- readonly environment: "piwi-environment";
35
- };
36
- /** Set of every internal attachment name — used to skip them when collecting user attachments. */
37
- declare const INTERNAL_ATTACHMENT_NAMES: ReadonlySet<string>;
38
- /** A name of `ATTACHMENT_NAMES`. */
39
- type AttachmentName = (typeof ATTACHMENT_NAMES)[keyof typeof ATTACHMENT_NAMES];
40
- /**
41
- * The content type the capture fixtures write `piwi-aria-snapshot` with, and
42
- * the only one the reporter reads it with. An attachment made from a browser
43
- * server's `x-playwright-attachment` header has the content type `text/plain`.
44
- */
45
- declare const ARIA_SNAPSHOT_CONTENT_TYPE = "text/plain; charset=utf-8";
46
- /** Whether `attachment` has the name `name` and the content type the capture fixtures write it with. */
47
- declare function isPiwiAttachment(attachment: {
48
- name: string;
49
- contentType?: string;
50
- }, name: AttachmentName): boolean;
51
- /**
52
- * The last of `attachments` that `isPiwiAttachment` accepts for `name`. A
53
- * reader of an attachment the fixtures write more than once
54
- * (`piwi-browser-functions`, `piwi-browser-lines`, `piwi-css-rules`) goes through every match with
55
- * `isPiwiAttachment` instead.
56
- */
57
- declare function findPiwiAttachment<T extends {
58
- name: string;
59
- contentType?: string;
60
- }>(attachments: readonly T[] | undefined, name: AttachmentName): T | undefined;
61
-
62
- /** Annotation type that surfaces a locator-healing suggestion in the report/trace. */
63
- declare const LOCATOR_SUGGESTION_ANNOTATION: "piwi-locator-suggestion";
64
- /** Annotation type that surfaces a human-confirmed replacement locator in the report/trace. */
65
- declare const USER_PICK_ANNOTATION: "piwi-user-pick";
66
-
67
- export { ARIA_SNAPSHOT_CONTENT_TYPE, ATTACHMENT_NAMES, type AttachmentName, INTERNAL_ATTACHMENT_NAMES, LOCATOR_SUGGESTION_ANNOTATION, USER_PICK_ANNOTATION, findPiwiAttachment, isPiwiAttachment };
@@ -1,90 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/internal/capture/attachments.ts
21
- var attachments_exports = {};
22
- __export(attachments_exports, {
23
- ARIA_SNAPSHOT_CONTENT_TYPE: () => ARIA_SNAPSHOT_CONTENT_TYPE,
24
- ATTACHMENT_NAMES: () => ATTACHMENT_NAMES,
25
- FAILURE_SCREENSHOT_ATTACHMENT: () => FAILURE_SCREENSHOT_ATTACHMENT,
26
- INTERNAL_ATTACHMENT_NAMES: () => INTERNAL_ATTACHMENT_NAMES,
27
- LOCATOR_SUGGESTION_ANNOTATION: () => LOCATOR_SUGGESTION_ANNOTATION,
28
- USER_PICK_ANNOTATION: () => USER_PICK_ANNOTATION,
29
- findPiwiAttachment: () => findPiwiAttachment,
30
- isPiwiAttachment: () => isPiwiAttachment
31
- });
32
- module.exports = __toCommonJS(attachments_exports);
33
-
34
- // ../core/src/wire.ts
35
- var FAILURE_SCREENSHOT_ATTACHMENT = "piwi-failure-screenshot";
36
-
37
- // src/internal/capture/attachments.ts
38
- var ATTACHMENT_NAMES = {
39
- locators: "piwi-locators",
40
- ariaSnapshot: "piwi-aria-snapshot",
41
- ariaSnapshotJson: "piwi-aria-snapshot-json",
42
- console: "piwi-console",
43
- dialogs: "piwi-dialogs",
44
- network: "piwi-network",
45
- pageInventory: "piwi-page-inventory",
46
- locatorPages: "piwi-locator-pages",
47
- codeReach: "piwi-code-reach",
48
- browserCoverage: "piwi-browser-coverage",
49
- browserFunctions: "piwi-browser-functions",
50
- browserLines: "piwi-browser-lines",
51
- cssCoverage: "piwi-css-coverage",
52
- cssRules: "piwi-css-rules",
53
- serverCoverageRequests: "piwi-server-coverage-requests",
54
- webVitals: "piwi-web-vitals",
55
- locatorSuggestion: "piwi-locator-suggestion",
56
- pageState: "piwi-page-state",
57
- userPick: "piwi-user-pick",
58
- aiUsage: "piwi-ai-usage",
59
- aiMeta: "piwi-ai-meta",
60
- resources: "piwi-resources",
61
- pauses: "piwi-pauses",
62
- environment: "piwi-environment"
63
- };
64
- var INTERNAL_ATTACHMENT_NAMES = new Set(Object.values(ATTACHMENT_NAMES));
65
- var ARIA_SNAPSHOT_CONTENT_TYPE = "text/plain; charset=utf-8";
66
- function contentTypeOf(name) {
67
- return name === ATTACHMENT_NAMES.ariaSnapshot ? ARIA_SNAPSHOT_CONTENT_TYPE : "application/json";
68
- }
69
- function isPiwiAttachment(attachment, name) {
70
- return attachment.name === name && attachment.contentType === contentTypeOf(name);
71
- }
72
- function findPiwiAttachment(attachments, name) {
73
- for (let i = (attachments?.length ?? 0) - 1; i >= 0; i--) {
74
- if (isPiwiAttachment(attachments[i], name)) return attachments[i];
75
- }
76
- return void 0;
77
- }
78
- var LOCATOR_SUGGESTION_ANNOTATION = ATTACHMENT_NAMES.locatorSuggestion;
79
- var USER_PICK_ANNOTATION = ATTACHMENT_NAMES.userPick;
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- ARIA_SNAPSHOT_CONTENT_TYPE,
83
- ATTACHMENT_NAMES,
84
- FAILURE_SCREENSHOT_ATTACHMENT,
85
- INTERNAL_ATTACHMENT_NAMES,
86
- LOCATOR_SUGGESTION_ANNOTATION,
87
- USER_PICK_ANNOTATION,
88
- findPiwiAttachment,
89
- isPiwiAttachment
90
- });
@@ -1,50 +0,0 @@
1
- import { TestInfo } from '@playwright/test';
2
-
3
- /**
4
- * Shared gate for Piwi's failure-time overlay. Both `inspectOnFailure`
5
- * (`PIWI_INSPECT_ON_FAIL`) and `pickLocatorOnFailure` (`PIWI_PICK_LOCATOR_ON_FAIL`)
6
- * open Piwi's own in-page overlay (see `pick-on-failure.ts`) — never
7
- * Playwright's native inspector — so the experience is fully ours and a
8
- * confirmed pick flows back into the dashboard.
9
- *
10
- * Local-only by design: the overlay needs a human and a visible browser, so the
11
- * gate requires a headed browser and refuses to run under CI regardless of the
12
- * flag. It also waits for the final attempt when retries are configured — an
13
- * attempt that is about to be retried closes without opening the overlay.
14
- */
15
- /** Everything the gate reads, as plain values so it stays unit-testable. */
16
- interface InspectionGate {
17
- /** Raw `PIWI_INSPECT_ON_FAIL` env value — only the string `'true'` enables. */
18
- enabled: string | undefined;
19
- /** Whether the run is a CI job, as `detectCi` reads the environment. */
20
- ci: boolean;
21
- /** `testInfo.status` at teardown. */
22
- status: string | undefined;
23
- /** `testInfo.expectedStatus` — an expected failure (test.fail()) never pauses. */
24
- expectedStatus: string | undefined;
25
- /** `testInfo.project.use.headless` — must be explicitly `false` (headed). */
26
- headless: unknown;
27
- /** Zero-based attempt index (`testInfo.retry`). */
28
- retry: number;
29
- /** Configured retry count for the project (`testInfo.project.retries`). */
30
- retries: number;
31
- }
32
- /** Decide whether the failing page should be handed to the Inspector. */
33
- declare function shouldInspectOnFailure(gate: InspectionGate): boolean;
34
- /**
35
- * When a failure-time feature is *enabled* on a *real* failure but the gate
36
- * still refused for an environmental reason (headless / CI), return a
37
- * one-line human explanation so "nothing happened" is never a silent mystery.
38
- * Returns null when the feature is off, the test didn't really fail, or the
39
- * gate would actually pass (the feature ran, so there is nothing to explain).
40
- */
41
- declare function environmentalSkipReason(gate: InspectionGate): string | null;
42
- /**
43
- * Project the live TestInfo + process env into the plain gate shape. The gate
44
- * conditions are shared by every failure-time affordance that needs a live
45
- * headed page; `enabled` selects which opt-in flag arms this one (defaults to
46
- * the Inspector's `PIWI_INSPECT_ON_FAIL`).
47
- */
48
- declare function inspectionGateFromTestInfo(testInfo: TestInfo, enabled?: string | undefined): InspectionGate;
49
-
50
- export { type InspectionGate, environmentalSkipReason, inspectionGateFromTestInfo, shouldInspectOnFailure };