@piwitests/reporter 0.68.0 → 0.70.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
  /**
@@ -82,6 +207,55 @@ declare class LocatorPageLog {
82
207
  list(): LocatorPageUse[];
83
208
  }
84
209
 
210
+ /**
211
+ * The run page's live view on the team instance. While a run of a project that turned it on executes, each worker
212
+ * keeps one event stream open to the instance, with a key for that run alone that the reporter sets in the workers'
213
+ * environment (`PIWI_LIVE_VIEW`, `<url>#<key>`, `formatLiveViewEnv`). On that stream the instance says how many people
214
+ * watch the worker (`viewers`), and which elements its project masks (`masks`). While anyone does, the worker posts small JPEG frames of its test's page, each with the
215
+ * call it was taken at and the title of its test, a few a second at most, and the instance relays them to those viewers
216
+ * alone and keeps none.
217
+ * The worker also posts when its test stops and goes on (`stop`), which the run page shows, when the test watched
218
+ * ended (`ended`), and when the run stops being shared (`unshared`). In a CI run, while anyone watches it in full, it
219
+ * posts too the call its test is in as Playwright logs it (`call-log`): the log's last lines, the point an input action acts on,
220
+ * and the elements the call's locator matches while it waits. Nothing goes from the instance to the page: the
221
+ * view never steers the run. Each message is JSON, checked field by field (`parseInstanceToWorker`,
222
+ * `readWorkerToInstance`).
223
+ *
224
+ * An instance that says on the stream what its viewers ask of the images (`view`: the largest size they show one at,
225
+ * in device pixels, the pace, and whether one of them shows the worker in full) takes each frame as its JPEG's bytes
226
+ * behind a short JSON header, one live message (`LIVE_FRAME_TYPE`); an older instance takes the frame in base64 inside
227
+ * JSON. The call log and the test's end go only to a full view: a worker that only tiles show posts neither, and
228
+ * follows no call log. A viewer reads one stream of live
229
+ * messages (`LIVE_STREAM_TYPE`): the frames of the workers it watches, their images as bytes, and the JSON messages
230
+ * of the view (`LiveViewerMessage`). A live message is a length-prefixed JSON header, then length-prefixed bytes
231
+ * (`encodeLiveMessage`, `createLiveMessageReader`): the dashboard and any other viewer read it with this one reader.
232
+ *
233
+ * Beside the images, a viewer of the worker in full may ask for the layers of `@piwitests/core/live-layers`
234
+ * (`LiveWatchAsk`'s `layers` on the instance): the instance says which on the worker's stream (`view`'s `layers`, the
235
+ * union of what its full views ask), and the worker posts them while asked alone, each naming its test: what the page
236
+ * and the test's requests said (`page-event`), the page's text (`text`, as the instance asks for it, `text` on the
237
+ * stream), and the images of its test's filmstrip (`thumb`, a live message whose data is the JPEG: the view's own masked
238
+ * images, kept in the worker's memory for a viewer who comes later, sent again on `resend`). The instance relays each to
239
+ * the watches that asked for that layer, and keeps none.
240
+ *
241
+ * A full view may also ask for **Inspect** (`view`'s `inspect`): the worker then posts the DOM snapshots its page's
242
+ * trace takes at each call (`snapshot`) and the resources they name (`resource`), as `@piwitests/core/live-inspect`
243
+ * says, and the instance tells each watch with Inspect open of each snapshot (`snapshot`, its data left out), which it
244
+ * serves rendered on its own.
245
+ *
246
+ * A CI run's workers open their streams at once. A run outside CI holds its key too, and its workers open no stream
247
+ * until a person shares the run (**Share live**, the run channel's `share`), and close it as the sharing stops. Such a
248
+ * run without a key names why instead (`none:<why>`, `formatLiveViewMissing`), for the surfaces to say.
249
+ */
250
+
251
+ /** A call of the test, as the run page names it: its title and its place in the user's code, when known. */
252
+ interface LiveCall {
253
+ title: string;
254
+ /** The file, relative to the run's working directory, with forward slashes. */
255
+ file: string | null;
256
+ line: number | null;
257
+ }
258
+
85
259
  /**
86
260
  * The run channel: each worker of a test run the editor started keeps one connection, from before its first test to its
87
261
  * end, to the local socket the editor service listens on for the record channel's hand-offs
@@ -89,13 +263,15 @@ declare class LocatorPageLog {
89
263
  * `PIWI_RECORD_CHANNEL` is (`formatRecordChannel`, `parseRecordChannel`). Its first line, `run-attach`, tells it from a
90
264
  * hand-off's `attach`. Over it the worker says which test it runs and where it stopped, and the editor service steers
91
265
  * it: pause, step, resume, finish, run to a line, end the test, the breakpoints, an image of the stopped page, and, at
92
- * 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
93
267
  * element** and a region's ARIA snapshot, started from outside the page; at any stop, the responses the test kept (an
94
268
  * interactive run keeps the text bodies of its pages' fetch and XHR answers), one of them to mock, and a locator's
95
269
  * matches; and, for a viewer outside the page, the stopped page's live view (`@piwitests/core/run-view`: its frames,
96
270
  * the input played on it) and the locator of the element under a point of an image of it; for a viewer of the
97
- * worker's lane, its running test's page live, through its tests and stops (`view-lane`, a feature beyond `takes`);
98
- * and, for an agent (the
271
+ * worker's lane, its running test's page live, through its tests and stops (`view-lane`, a feature beyond `takes`),
272
+ * and the layers of that view its viewers ask beside the images (`layers`, `lane-layer`: `@piwitests/core/live-layers`);
273
+ * for the hub alone, where its running attempt's trace grows (`trace`), which the hub opens in Playwright's trace
274
+ * viewer and names to no one; and, for an agent (the
99
275
  * editor's MCP server), the stopped page's ARIA snapshot in AI mode, an action on one of its elements by its ref, that
100
276
  * element's ranked locators, what the run does as it goes (`events`), and its browser bound for Playwright's own tools
101
277
  * on request (`bind`). A worker holds a failure for the editor only once the service said it shows and answers one
@@ -108,12 +284,17 @@ declare class LocatorPageLog {
108
284
 
109
285
  /**
110
286
  * What a stop the pause bar shows starts from outside the page, in the test's window: the bar's **Pick a locator**
111
- * (`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
112
288
  * element** (`assert`), through the record channel's hand-off in its `check` mode, the editor service writing the
113
289
  * check; and a region picked with the bar's picker (`assert-region`), whose ARIA snapshot the worker reads and sends
114
290
  * (`region`).
115
291
  */
116
292
  type RunIntent = 'pick' | 'record' | 'assert' | 'assert-region';
293
+ /**
294
+ * The actions in the test's window that take Escape as their own, which a worker says run (`acting`): a pick, a check
295
+ * and a region's pick end on it. A recording does not: it records Escape as a step of the test.
296
+ */
297
+ type RunActing = Exclude<RunIntent, 'record'>;
117
298
  /** Whether an intent started, or why not, in one sentence. */
118
299
  interface IntentAnswer {
119
300
  ok: boolean;
@@ -121,14 +302,20 @@ interface IntentAnswer {
121
302
  }
122
303
 
123
304
  /**
124
- * 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):
125
306
  * the bar takes an intent while it waits for its answer, and one handed to it while it is about to (its highlight
126
- * still drawing) waits for it; while a pick or a recording runs, none is taken.
307
+ * still drawing) waits for it; while a pick or a recording runs, none is taken. Each action in the test's window that
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`
309
+ * as it starts, and null once it ended (`acting`); a recording, which records Escape as a step, is not.
127
310
  */
128
311
  declare class BarIntents {
129
312
  private take;
130
313
  private queued;
131
314
  private busy;
315
+ private readonly said;
316
+ constructor(said?: (what: RunActing | null) => void);
317
+ /** Runs an action in the test's window (`what`), saying it runs until it ended. */
318
+ acting<T>(what: RunActing, run: () => Promise<T>): Promise<T>;
132
319
  /** Hand the bar an intent; false while it runs one, or holds one already. */
133
320
  offer(intent: RunIntent): boolean;
134
321
  /** The bar waits for its answer: settles with the next intent handed to it. */
@@ -137,14 +324,6 @@ declare class BarIntents {
137
324
  answered(): void;
138
325
  }
139
326
 
140
- /** A call of the test, as the run page names it: its title and its place in the user's code, when known. */
141
- interface LiveCall {
142
- title: string;
143
- /** The file, relative to the run's working directory, with forward slashes. */
144
- file: string | null;
145
- line: number | null;
146
- }
147
-
148
327
  /**
149
328
  * Register this package's `dist/` directory as a boxed stack prefix — the list
150
329
  * Playwright filters its own frames with — so a wrapped action's step location
@@ -876,8 +1055,8 @@ declare function buildPageState(raw: RawPageState, cookies: Array<Record<string,
876
1055
  * action. `tagRoles`/`inputRoles` are the shared role maps (single source of
877
1056
  * truth in `locator-healing.ts`), and `roleSources` is the CSS selector for
878
1057
  * every element the probe can resolve a role for — all derived from the map so
879
- * nothing is hand-maintained twice. Exported so the dogfood mirror
880
- * (`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.
881
1060
  */
882
1061
  declare const CAPTURED_ATTRS_ARG: ProbeArg;
883
1062
  /**
@@ -933,6 +1112,18 @@ type CodePlace = {
933
1112
  * as Windows writes them. Null for an error with no such frame (a test timeout).
934
1113
  */
935
1114
  declare function errorPlace(error: unknown, windows?: boolean): CodePlace | null;
1115
+ /**
1116
+ * Whether the runner traces the attempt, as its tracing's options say once the attempt began (`_tracing.traceOptions()`,
1117
+ * Playwright internal: the options, with their `mode`, for a traced attempt, none for another); null on a runner of
1118
+ * another shape.
1119
+ */
1120
+ declare function runnerTraces(testInfo: TestInfo): boolean | null;
1121
+ /**
1122
+ * Whether the runner's trace of the attempt takes DOM snapshots, as its tracing's options say (Playwright internal,
1123
+ * feature-checked): `snapshots`, or its `dom` where it names each kind (1.64, `{ aria: true }` taking none); null where
1124
+ * it does not trace the attempt or its shape is not known.
1125
+ */
1126
+ declare function runnerTraceSnapshots(testInfo: TestInfo): boolean | null;
936
1127
  /**
937
1128
  * The call the test is on, as the run page's live view names it beside each frame, its file relative to the working
938
1129
  * directory. Null for none.
@@ -994,4 +1185,4 @@ declare const piwiFixtures: Fixtures<PiwiFixtures, PiwiWorkerFixtures, Playwrigh
994
1185
  */
995
1186
  declare function extendPiwiFixtures<TestArgs extends FixtureArgs, WorkerArgs extends FixtureArgs>(test: TestType<TestArgs, WorkerArgs>): TestType<TestArgs & PiwiFixtures, WorkerArgs & PiwiWorkerFixtures>;
996
1187
 
997
- 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, 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 };