@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piwitests/reporter",
3
- "version": "0.68.0",
3
+ "version": "0.70.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",
@@ -36,7 +36,9 @@ Without it, the CLI does the same: `npx @piwitests/reporter bug <id>`, with the
36
36
  4. **Fix the bug** in the application code. Keep the change to what the evidence and the expected result point at.
37
37
 
38
38
  5. **Prove the fix.** Remove the `test.fail()` line from the bug's spec and run it: it must pass. Run the tests that
39
- visit the page too (`npx playwright test <their files>`), so the fix breaks nothing around it.
39
+ visit the page too (`npx playwright test <their files>`), so the fix breaks nothing around it. With Piwi's run tools
40
+ connected (`npx @piwitests/reporter mcp`), start each with `run_start` instead: a test that fails waits at its line
41
+ for you to read its page (`run_follow`, `page_snapshot`).
40
42
 
41
43
  6. **Report.** The cause, the fix, the spec file, and the two runs. Once the spec passes without `test.fail()` in a
42
44
  run on the project's default branch (not a `piwi bug` run), Piwi closes the report on its own; before that, such a
@@ -25,7 +25,7 @@ Prefer the **Piwi MCP server** if it is connected to this agent (tools named `li
25
25
 
26
26
  6. **Propose the fix.** Make the smallest change that addresses the root cause, in the actual source or spec files. Prefer Piwi's own suggestions where they exist — for a broken selector, the ranked replacement from `get_locator_healing` (the `apply-locator-healing` skill does exactly this). Show the diff.
27
27
 
28
- 7. **Verify.** Re-run the affected spec(s): `npx playwright test <file>`. Confirm they pass and the new run is green in the dashboard (`get_run_insights` compares the run with its baseline, usually the last passing run: regressions cleared, nothing new broken).
28
+ 7. **Verify.** Re-run the affected spec(s). With Piwi's run tools connected (`npx @piwitests/reporter mcp`: `run_start`, `run_follow`, `page_snapshot`, …), start it with `run_start` (`file`, and `line` for one test): it runs where the developer sees it, and a test that still fails waits at its line for you to read its page (`run_follow`, then `page_snapshot`). Otherwise run `npx playwright test <file>`. Confirm they pass and the new run is green in the dashboard (`get_run_insights` compares the run with its baseline, usually the last passing run: regressions cleared, nothing new broken).
29
29
 
30
30
  8. **Report back.** Piwi learns from what you tell it, so end every investigation with these calls (each is logged with your API key; `record_diagnosis` and `report_fix_attempt` need the Maintainer role or above on the project, rating a diagnosis needs read access only):
31
31
  - **Your diagnosis.** If the cluster had no diagnosis, or yours differs, record it with `record_diagnosis` (`clusterId`, or `executionId` for a failure in no cluster or with a cause of its own): the model you run on and the diagnosis in the schema the tool describes (summary, confidenceScore, severity, ranked hypotheses with their evidence, suggestedFix with the unified-diff `patch`). Piwi validates the patch against the source that failed and shows the diagnosis as written by an agent.
@@ -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 };
@@ -1,72 +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/inspect-on-failure.ts
21
- var inspect_on_failure_exports = {};
22
- __export(inspect_on_failure_exports, {
23
- environmentalSkipReason: () => environmentalSkipReason,
24
- inspectionGateFromTestInfo: () => inspectionGateFromTestInfo,
25
- shouldInspectOnFailure: () => shouldInspectOnFailure
26
- });
27
- module.exports = __toCommonJS(inspect_on_failure_exports);
28
-
29
- // src/internal/support/ci.ts
30
- function detectCi(env) {
31
- return Boolean(
32
- env.JENKINS_URL || env.GITHUB_ACTIONS || env.GITLAB_CI || env.CIRCLECI || env.TRAVIS || env.TF_BUILD || env.BITBUCKET_BUILD_NUMBER || env.TEAMCITY_VERSION || env.CODEBUILD_BUILD_ID || env.bamboo_buildKey || env.CI && env.CI.toLowerCase() !== "false" && env.CI !== "0"
33
- );
34
- }
35
-
36
- // src/internal/capture/inspect-on-failure.ts
37
- function shouldInspectOnFailure(gate) {
38
- if (gate.enabled !== "true") return false;
39
- if (gate.ci) return false;
40
- if (gate.headless !== false) return false;
41
- if (gate.status !== "failed" && gate.status !== "timedOut") return false;
42
- if (gate.status === gate.expectedStatus) return false;
43
- return gate.retry >= gate.retries;
44
- }
45
- function environmentalSkipReason(gate) {
46
- if (gate.enabled !== "true") return null;
47
- if (gate.status !== "failed" && gate.status !== "timedOut") return null;
48
- if (gate.status === gate.expectedStatus) return null;
49
- if (gate.ci) return "running under CI \u2014 this is a headed, local-only feature";
50
- if (gate.headless !== false) {
51
- return "the browser is headless \u2014 re-run with --headed (or set use: { headless: false })";
52
- }
53
- return null;
54
- }
55
- function inspectionGateFromTestInfo(testInfo, enabled = process.env.PIWI_INSPECT_ON_FAIL) {
56
- const use = testInfo.project?.use ?? {};
57
- return {
58
- enabled,
59
- ci: detectCi(process.env),
60
- status: testInfo.status,
61
- expectedStatus: testInfo.expectedStatus,
62
- headless: use.headless,
63
- retry: testInfo.retry,
64
- retries: testInfo.project?.retries ?? 0
65
- };
66
- }
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- environmentalSkipReason,
70
- inspectionGateFromTestInfo,
71
- shouldInspectOnFailure
72
- });