@piwitests/reporter 0.52.0 → 0.53.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,3 +1,5 @@
1
+ export { FAILURE_SCREENSHOT_ATTACHMENT } from '@piwitests/core/wire';
2
+
1
3
  /**
2
4
  * Names of the `testInfo` attachments the dashboard fixtures produce and the
3
5
  * reporter parses. Single source of truth — imported by the producer
@@ -15,6 +17,7 @@ declare const ATTACHMENT_NAMES: {
15
17
  readonly pageInventory: "piwi-page-inventory";
16
18
  readonly locatorPages: "piwi-locator-pages";
17
19
  readonly codeReach: "piwi-code-reach";
20
+ readonly serverCoverageRequests: "piwi-server-coverage-requests";
18
21
  readonly webVitals: "piwi-web-vitals";
19
22
  readonly locatorSuggestion: "piwi-locator-suggestion";
20
23
  readonly pageState: "piwi-page-state";
@@ -25,6 +28,7 @@ declare const ATTACHMENT_NAMES: {
25
28
  };
26
29
  /** Set of every internal attachment name — used to skip them when collecting user attachments. */
27
30
  declare const INTERNAL_ATTACHMENT_NAMES: ReadonlySet<string>;
31
+
28
32
  /** Annotation type that surfaces a locator-healing suggestion in the report/trace. */
29
33
  declare const LOCATOR_SUGGESTION_ANNOTATION: "piwi-locator-suggestion";
30
34
  /** Annotation type that surfaces a human-confirmed replacement locator in the report/trace. */
@@ -21,11 +21,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var attachments_exports = {};
22
22
  __export(attachments_exports, {
23
23
  ATTACHMENT_NAMES: () => ATTACHMENT_NAMES,
24
+ FAILURE_SCREENSHOT_ATTACHMENT: () => FAILURE_SCREENSHOT_ATTACHMENT,
24
25
  INTERNAL_ATTACHMENT_NAMES: () => INTERNAL_ATTACHMENT_NAMES,
25
26
  LOCATOR_SUGGESTION_ANNOTATION: () => LOCATOR_SUGGESTION_ANNOTATION,
26
27
  USER_PICK_ANNOTATION: () => USER_PICK_ANNOTATION
27
28
  });
28
29
  module.exports = __toCommonJS(attachments_exports);
30
+
31
+ // ../core/src/wire.ts
32
+ var FAILURE_SCREENSHOT_ATTACHMENT = "piwi-failure-screenshot";
33
+
34
+ // src/internal/capture/attachments.ts
29
35
  var ATTACHMENT_NAMES = {
30
36
  locators: "piwi-locators",
31
37
  ariaSnapshot: "piwi-aria-snapshot",
@@ -36,6 +42,7 @@ var ATTACHMENT_NAMES = {
36
42
  pageInventory: "piwi-page-inventory",
37
43
  locatorPages: "piwi-locator-pages",
38
44
  codeReach: "piwi-code-reach",
45
+ serverCoverageRequests: "piwi-server-coverage-requests",
39
46
  webVitals: "piwi-web-vitals",
40
47
  locatorSuggestion: "piwi-locator-suggestion",
41
48
  pageState: "piwi-page-state",
@@ -50,6 +57,7 @@ var USER_PICK_ANNOTATION = ATTACHMENT_NAMES.userPick;
50
57
  // Annotate the CommonJS export names for ESM import in node:
51
58
  0 && (module.exports = {
52
59
  ATTACHMENT_NAMES,
60
+ FAILURE_SCREENSHOT_ATTACHMENT,
53
61
  INTERNAL_ATTACHMENT_NAMES,
54
62
  LOCATOR_SUGGESTION_ANNOTATION,
55
63
  USER_PICK_ANNOTATION
@@ -1,5 +1,6 @@
1
1
  import { ProbeArg } from '@piwitests/picker-dom';
2
2
  export { ProbeArg, ProbedAttrs, probeElementAttrs } from '@piwitests/picker-dom';
3
+ import { PageInteraction } from '@piwitests/core/page-interaction';
3
4
  import { Page, TestInfo, TestType, Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, Locator } from '@playwright/test';
4
5
  import { LocatorPageUse, ProcessRole, RoleCost } from '@piwitests/core/wire';
5
6
  import { JsCoverageEntry } from '@piwitests/core/code-reach';
@@ -51,6 +52,15 @@ interface CodeReachRoots {
51
52
  }
52
53
  /** Fetches a source map's text; null when it cannot. */
53
54
  type MapFetcher = (url: string) => Promise<string | null>;
55
+ /**
56
+ * One covered script: its function coverage (one range per function), V8's
57
+ * content hash, and its source, which is left out when the worker has already
58
+ * resolved that version of the script.
59
+ */
60
+ interface CoveredScript extends JsCoverageEntry {
61
+ /** V8's content hash of the script; without it, the version is a hash of `source`. */
62
+ hash?: string;
63
+ }
54
64
  /**
55
65
  * The roots for a test: `codeReachRoots` when set, else the Playwright config's
56
66
  * directory; the repository root always comes last, since bundlers name
@@ -58,13 +68,19 @@ type MapFetcher = (url: string) => Promise<string | null>;
58
68
  */
59
69
  declare function codeReachRoots(configDir: string, configured: string[] | null | undefined): CodeReachRoots;
60
70
  /** The repository-relative files the covered scripts reached, sorted and capped. */
61
- declare function resolveCodeReach(entries: JsCoverageEntry[], roots: CodeReachRoots, fetchMap: MapFetcher): Promise<string[]>;
71
+ declare function resolveCodeReach(entries: CoveredScript[], roots: CodeReachRoots, fetchMap: MapFetcher): Promise<string[]>;
62
72
  /** A map fetcher through the page's request context, bounded in size and time. */
63
73
  declare function pageMapFetcher(page: Page): MapFetcher;
64
- /** Start JavaScript coverage on a page; false when the browser has none or it fails. */
74
+ /**
75
+ * Start function coverage on a page, with the debugger on to learn each
76
+ * script's version; false when the browser has none or it fails.
77
+ */
65
78
  declare function startCodeReach(page: Page): Promise<boolean>;
66
- /** Stop JavaScript coverage and return its entries; null when it cannot be read. */
67
- declare function stopCodeReach(page: Page): Promise<JsCoverageEntry[] | null>;
79
+ /**
80
+ * Stop the page's coverage and return the scripts parsed since it started,
81
+ * each with its functions and version; null when it cannot be read.
82
+ */
83
+ declare function stopCodeReach(page: Page): Promise<CoveredScript[] | null>;
68
84
 
69
85
  interface ProcStat {
70
86
  pid: number;
@@ -424,6 +440,18 @@ declare function noteResourceUse(page: object): void;
424
440
  */
425
441
  declare function recordResourceCensus(testInfo: TestInfo): Promise<void>;
426
442
 
443
+ /**
444
+ * Reads, in the page, what it is doing beyond its DOM: the element holding keyboard focus (and the caret or
445
+ * selected range of a text field), the element under the mouse, a text selection outside fields, and the
446
+ * checkboxes in the indeterminate state. Elements are named by element path and text by offset, the format
447
+ * `@piwitests/core/page-interaction` describes and the dashboard resolves in the failure-time DOM. Never reads
448
+ * a field's value or the selected text.
449
+ *
450
+ * Runs in the browser through `page.evaluate`, so it is self-contained: no reference to this module's scope,
451
+ * and `any` for the DOM this package has no types for.
452
+ */
453
+ declare function readPageInteraction(): PageInteraction;
454
+
427
455
  type FixtureArgs = {
428
456
  [key: string]: any;
429
457
  };
@@ -449,7 +477,7 @@ declare function computeCoreVitals(lcpEntries: RawVitalEntry[] | null, shiftEntr
449
477
  /** The code reach roots from `PIWI_CODE_REACH_ROOTS` (a JSON array or a path list). */
450
478
  declare function configuredCodeReachRoots(): string[] | null;
451
479
  /** Page state captured at test end. Storage values and cookie values are NEVER included. */
452
- interface PageState {
480
+ interface PageState extends PageInteraction {
453
481
  url: string;
454
482
  hash: string | null;
455
483
  /** `history.state` as JSON, capped and token-masked. */
@@ -489,11 +517,12 @@ interface RawPageState {
489
517
  }>;
490
518
  }
491
519
  /**
492
- * Assemble the wire page-state from the in-page reads and the context cookies.
493
- * Pure and Node-side so the sanitization (token masking, caps, value-free
494
- * cookies) is unit-testable.
520
+ * Assemble the wire page-state from the in-page reads, the context cookies and
521
+ * what the page was doing (`readPageInteraction`). Pure and Node-side so the
522
+ * sanitization (token masking, caps, value-free cookies, well-formed element
523
+ * paths) is unit-testable.
495
524
  */
496
- declare function buildPageState(raw: RawPageState, cookies: Array<Record<string, unknown>> | null): PageState;
525
+ declare function buildPageState(raw: RawPageState, cookies: Array<Record<string, unknown>> | null, interaction?: unknown): PageState;
497
526
  /**
498
527
  * Everything the in-page probe needs, serialized into the browser on every
499
528
  * action. `tagRoles`/`inputRoles` are the shared role maps (single source of
@@ -581,4 +610,4 @@ declare const piwiFixtures: Fixtures<PiwiFixtures, PiwiWorkerFixtures, Playwrigh
581
610
  */
582
611
  declare function extendPiwiFixtures<TestArgs extends FixtureArgs, WorkerArgs extends FixtureArgs>(test: TestType<TestArgs, WorkerArgs>): TestType<TestArgs & PiwiFixtures, WorkerArgs & PiwiWorkerFixtures>;
583
612
 
584
- export { CAPTURED_ATTRS_ARG, LocatorPageLog, type PageState, type PiwiFixtures, type PiwiWorkerFixtures, type RawPageState, type RawVitalEntry, activeResourceLedger, ariaSnapshotBestEffort, ariaSnapshotJSONBestEffort, boxCaptureFrames, buildPageState, callMethod, codeReachRoots, computeCoreVitals, configuredCodeReachRoots, extendPiwiFixtures, internalCall, noteLocatorCall, noteNavigation, noteResourceUse, pageMapFetcher, piwiFixtures, recordResourceCensus, resolveCodeReach, startCodeReach, startResourceLedger, stopCodeReach, stopResourceLedger };
613
+ export { CAPTURED_ATTRS_ARG, LocatorPageLog, type PageState, type PiwiFixtures, type PiwiWorkerFixtures, type RawPageState, type RawVitalEntry, activeResourceLedger, ariaSnapshotBestEffort, ariaSnapshotJSONBestEffort, boxCaptureFrames, buildPageState, callMethod, codeReachRoots, computeCoreVitals, configuredCodeReachRoots, extendPiwiFixtures, internalCall, noteLocatorCall, noteNavigation, noteResourceUse, pageMapFetcher, piwiFixtures, readPageInteraction, recordResourceCensus, resolveCodeReach, startCodeReach, startResourceLedger, stopCodeReach, stopResourceLedger };