@andrii_kremlovskyi/playwright-traces-reader 2.5.4 → 2.6.1

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.
@@ -84,34 +84,6 @@ export interface TraceIssue {
84
84
  } | null;
85
85
  relatedAction: RelatedActionRef | null;
86
86
  }
87
- export interface RepeatedFailingRequestPattern {
88
- signature: string;
89
- method: string;
90
- url: string;
91
- count: number;
92
- traceSha1s: string[];
93
- statuses: number[];
94
- relatedActions: Array<{
95
- callId: string;
96
- title: string;
97
- }>;
98
- }
99
- export interface RepeatedIssuePattern {
100
- signature: string;
101
- source: TraceIssue['source'];
102
- name: string | null;
103
- message: string;
104
- count: number;
105
- traceSha1s: string[];
106
- relatedActions: Array<{
107
- callId: string;
108
- title: string;
109
- }>;
110
- }
111
- export interface ReportFailurePatterns {
112
- repeatedFailingRequests: RepeatedFailingRequestPattern[];
113
- repeatedIssues: RepeatedIssuePattern[];
114
- }
115
87
  export interface NetworkFilterOptions {
116
88
  source?: 'all' | 'browser' | 'api';
117
89
  grep?: string;
@@ -186,6 +158,38 @@ export declare function extractAttachment(traceContext: TraceContext, attachment
186
158
  * numbered files, and returns metadata including the saved file path.
187
159
  */
188
160
  export declare function extractScreenshots(traceContext: TraceContext, outDir: string): Promise<Screenshot[]>;
161
+ /** A point of interest in a failing test (a failing step / assertion). */
162
+ export interface FailureAnchor {
163
+ /** The failing action/step callId, when known. */
164
+ callId: string | null;
165
+ /** Human-readable step/issue title, when known. */
166
+ title: string | null;
167
+ /** Wall-clock timestamp (ms) of the failure point. */
168
+ timestamp: number;
169
+ }
170
+ /** Screencast frames captured around a single failure anchor. */
171
+ export interface FailureScreenshotSet {
172
+ anchorCallId: string | null;
173
+ anchorTitle: string | null;
174
+ anchorTimestamp: number;
175
+ /** Relative file name of the frame just before the failure, or null. */
176
+ before: string | null;
177
+ /** Relative file name of the frame closest to the failure, or null. */
178
+ action: string | null;
179
+ /** Relative file name of the frame just after the failure, or null. */
180
+ after: string | null;
181
+ }
182
+ /**
183
+ * For each failure anchor, locates the nearest screencast frame `before`
184
+ * (timestamp ≤ anchor), `action` (closest in time), and `after`
185
+ * (timestamp ≥ anchor), writes the referenced image blobs into `outDir`, and
186
+ * returns the saved file names per anchor.
187
+ *
188
+ * Frames are de-duplicated by SHA1 — the same underlying image is written once
189
+ * and referenced by multiple roles/anchors. Returns an empty array when the
190
+ * trace has no screencast frames (e.g. API-only tests or capture disabled).
191
+ */
192
+ export declare function extractFailureScreenshots(traceContext: TraceContext, anchors: FailureAnchor[], outDir: string): Promise<FailureScreenshotSet[]>;
189
193
  /**
190
194
  * A single serialized DOM snapshot for one phase of one action.
191
195
  *
@@ -416,8 +420,6 @@ export interface FailedTraceSelection {
416
420
  traceSha1: string;
417
421
  summary: TraceSummary;
418
422
  }
419
- export declare function getReportFailurePatterns(reportDataDir: string, options?: GetFailedTestSummariesOptions): Promise<ReportFailurePatterns>;
420
- export declare function summarizeReportFailurePatterns(selections: FailedTraceSelection[]): ReportFailurePatterns;
421
423
  export declare function getFailedTraceSelections(reportDataDir: string, options?: GetFailedTestSummariesOptions): Promise<FailedTraceSelection[]>;
422
424
  /**
423
425
  * High-level report-level helper: finds all **unique** failing tests across
@@ -1 +1 @@
1
- {"version":3,"file":"extractors.d.ts","sourceRoot":"","sources":["../src/extractors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsF,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAIhL,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAA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C5C;;;;;;;;;;;;;;;;;OAiBG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,wBAAsB,wBAAwB,CAC5C,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,6BAA6B,GACtC,OAAO,CAAC,oBAAoB,EAAE,CAAC,CA0DjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,sBAAsB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,6BAA6B,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAGpI"}
@@ -42,12 +42,11 @@ exports.getTraceIssues = getTraceIssues;
42
42
  exports.getAttachments = getAttachments;
43
43
  exports.extractAttachment = extractAttachment;
44
44
  exports.extractScreenshots = extractScreenshots;
45
+ exports.extractFailureScreenshots = extractFailureScreenshots;
45
46
  exports.getDomSnapshots = getDomSnapshots;
46
47
  exports.getTimeline = getTimeline;
47
48
  exports.getTestTitle = getTestTitle;
48
49
  exports.getSummary = getSummary;
49
- exports.getReportFailurePatterns = getReportFailurePatterns;
50
- exports.summarizeReportFailurePatterns = summarizeReportFailurePatterns;
51
50
  exports.getFailedTraceSelections = getFailedTraceSelections;
52
51
  exports.getFailedTestSummaries = getFailedTestSummaries;
53
52
  const fs = __importStar(require("fs"));
@@ -413,6 +412,66 @@ async function extractScreenshots(traceContext, outDir) {
413
412
  }
414
413
  return screenshots;
415
414
  }
415
+ /**
416
+ * For each failure anchor, locates the nearest screencast frame `before`
417
+ * (timestamp ≤ anchor), `action` (closest in time), and `after`
418
+ * (timestamp ≥ anchor), writes the referenced image blobs into `outDir`, and
419
+ * returns the saved file names per anchor.
420
+ *
421
+ * Frames are de-duplicated by SHA1 — the same underlying image is written once
422
+ * and referenced by multiple roles/anchors. Returns an empty array when the
423
+ * trace has no screencast frames (e.g. API-only tests or capture disabled).
424
+ */
425
+ async function extractFailureScreenshots(traceContext, anchors, outDir) {
426
+ const frames = await getScreenshotMetadata(traceContext);
427
+ if (frames.length === 0 || anchors.length === 0)
428
+ return [];
429
+ frames.sort((a, b) => a.timestamp - b.timestamp);
430
+ await fs.promises.mkdir(outDir, { recursive: true });
431
+ // SHA1 → relative file name (written once, referenced many times).
432
+ const writtenBySha1 = new Map();
433
+ const ensureWritten = async (sha1) => {
434
+ const cached = writtenBySha1.get(sha1);
435
+ if (cached !== undefined)
436
+ return cached;
437
+ const buf = await (0, parseTrace_1.getResourceBuffer)(traceContext, sha1);
438
+ if (!buf)
439
+ return null;
440
+ const ext = sha1.endsWith('.jpeg') ? 'jpeg' : 'png';
441
+ const shortSha1 = sha1.replace(/\.(jpeg|png)$/, '').slice(0, 12);
442
+ const fileName = `frame-${shortSha1}.${ext}`;
443
+ await fs.promises.writeFile(path.join(outDir, fileName), buf);
444
+ writtenBySha1.set(sha1, fileName);
445
+ return fileName;
446
+ };
447
+ const sets = [];
448
+ for (const anchor of anchors) {
449
+ let before = null;
450
+ let after = null;
451
+ let action = null;
452
+ let actionDistance = Number.POSITIVE_INFINITY;
453
+ for (const frame of frames) {
454
+ if (frame.timestamp <= anchor.timestamp)
455
+ before = frame; // frames are sorted, so the last match wins
456
+ if (after === null && frame.timestamp >= anchor.timestamp)
457
+ after = frame;
458
+ const distance = Math.abs(frame.timestamp - anchor.timestamp);
459
+ if (distance < actionDistance) {
460
+ actionDistance = distance;
461
+ action = frame;
462
+ }
463
+ }
464
+ sets.push({
465
+ anchorCallId: anchor.callId,
466
+ anchorTitle: anchor.title,
467
+ anchorTimestamp: anchor.timestamp,
468
+ before: before ? await ensureWritten(before.sha1) : null,
469
+ action: action ? await ensureWritten(action.sha1) : null,
470
+ after: after ? await ensureWritten(after.sha1) : null,
471
+ });
472
+ }
473
+ return sets;
474
+ }
416
475
  /**
417
476
  * Builds the post-order DFS node list for a snapshot tree (mirroring
418
477
  * Playwright's `snapshotNodes()` in snapshotRenderer.ts). Only "real"
@@ -452,20 +511,25 @@ const VOID_TAGS = new Set([
452
511
  'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
453
512
  'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr',
454
513
  ]);
514
+ /** Maximum iframe nesting depth to inline before bailing out (cycle/runaway guard). */
515
+ const MAX_IFRAME_DEPTH = 10;
455
516
  /**
456
- * Resolves a snapshot node tree into an HTML string.
517
+ * Resolves a snapshot node tree into an HTML string for a given frame.
457
518
  *
458
- * `snapshotIndex` is the 0-based index of the current snapshot in `frameHistory`.
459
- * `frameHistory` is the ordered list of all raw snapshot HTMLs seen so far for
460
- * this frame (current snapshot is already appended before this call).
461
- * `dfsCache` is a memoization cache shared across the entire trace-file pass to
462
- * avoid rebuilding the same DFS node lists repeatedly.
519
+ * `snapshotIndex` is the 0-based index of the current snapshot in the frame's
520
+ * history. `frameId` identifies the frame so back-references resolve against the
521
+ * correct history and child iframes can be inlined recursively.
463
522
  *
464
523
  * Back-references `[[offset, nodeIdx]]` are resolved as:
465
524
  * refIndex = snapshotIndex - offset
466
525
  * node = snapshotNodes(frameHistory[refIndex])[nodeIdx]
526
+ *
527
+ * `<iframe>` / `<frame>` elements whose `src` is `/snapshot/<childFrameId>` are
528
+ * replaced with the recursively-rendered child frame HTML inlined via `srcdoc`,
529
+ * producing a complete, self-contained page.
467
530
  */
468
- function resolveSnapshotNode(node, snapshotIndex, frameHistory, dfsCache) {
531
+ function resolveSnapshotNode(node, snapshotIndex, frameId, ctx) {
532
+ const frameHistory = ctx.frameHistory.get(frameId) ?? [];
469
533
  if (typeof node === 'string') {
470
534
  return escapeHtml(node);
471
535
  }
@@ -480,9 +544,9 @@ function resolveSnapshotNode(node, snapshotIndex, frameHistory, dfsCache) {
480
544
  const refIndex = snapshotIndex - offset;
481
545
  if (refIndex >= 0 && refIndex < frameHistory.length) {
482
546
  const refHtml = frameHistory[refIndex];
483
- const nodes = buildSnapshotNodeList(refHtml, dfsCache);
547
+ const nodes = buildSnapshotNodeList(refHtml, ctx.dfsCache);
484
548
  if (nodeIdx >= 0 && nodeIdx < nodes.length) {
485
- return resolveSnapshotNode(nodes[nodeIdx], refIndex, frameHistory, dfsCache);
549
+ return resolveSnapshotNode(nodes[nodeIdx], refIndex, frameId, ctx);
486
550
  }
487
551
  }
488
552
  return `<!-- ref: [${offset}, ${nodeIdx}] unresolved -->`;
@@ -494,18 +558,70 @@ function resolveSnapshotNode(node, snapshotIndex, frameHistory, dfsCache) {
494
558
  const tag = tagName.toLowerCase();
495
559
  if (tag === 'script')
496
560
  return ''; // not useful for AI analysis
497
- const attrStr = attrs && typeof attrs === 'object' && !Array.isArray(attrs)
498
- ? Object.entries(attrs)
499
- .filter(([k]) => !k.startsWith('__playwright'))
561
+ const safeAttrs = attrs && typeof attrs === 'object' && !Array.isArray(attrs)
562
+ ? attrs
563
+ : {};
564
+ // Inline child frames: <iframe>/<frame> with src="/snapshot/<frameId>".
565
+ if (tag === 'iframe' || tag === 'frame') {
566
+ const childFrameId = parseSnapshotFrameId(safeAttrs['src']);
567
+ const baseAttrs = Object.entries(safeAttrs)
568
+ .filter(([k]) => !k.startsWith('__playwright') && k.toLowerCase() !== 'src' && k.toLowerCase() !== 'srcdoc')
500
569
  .map(([k, v]) => ` ${k}="${escapeAttr(String(v))}"`)
501
- .join('')
502
- : '';
570
+ .join('');
571
+ if (childFrameId) {
572
+ const childHtml = renderChildFrame(childFrameId, ctx);
573
+ if (childHtml !== null) {
574
+ return `<${tag}${baseAttrs} srcdoc="${escapeAttr(childHtml)}"></${tag}>`;
575
+ }
576
+ return `<${tag}${baseAttrs}><!-- child frame ${escapeHtml(childFrameId)} not captured for ${escapeHtml(ctx.snapshotName)} --></${tag}>`;
577
+ }
578
+ return `<${tag}${baseAttrs}></${tag}>`;
579
+ }
580
+ const attrStr = Object.entries(safeAttrs)
581
+ .filter(([k]) => !k.startsWith('__playwright'))
582
+ .map(([k, v]) => ` ${k}="${escapeAttr(String(v))}"`)
583
+ .join('');
503
584
  if (VOID_TAGS.has(tag)) {
504
585
  return `<${tag}${attrStr}>`;
505
586
  }
506
- const inner = children.map(c => resolveSnapshotNode(c, snapshotIndex, frameHistory, dfsCache)).join('');
587
+ const inner = children.map(c => resolveSnapshotNode(c, snapshotIndex, frameId, ctx)).join('');
507
588
  return `<${tag}${attrStr}>${inner}</${tag}>`;
508
589
  }
590
+ /**
591
+ * Extracts the child frameId from an iframe `src` of the form
592
+ * `/snapshot/<frameId>` (Playwright's capture-time rewrite). Returns null for
593
+ * any other value (empty, blank, or a real URL).
594
+ */
595
+ function parseSnapshotFrameId(src) {
596
+ if (!src)
597
+ return null;
598
+ const prefix = '/snapshot/';
599
+ if (!src.startsWith(prefix))
600
+ return null;
601
+ const id = src.substring(prefix.length).trim();
602
+ return id.length > 0 ? id : null;
603
+ }
604
+ /**
605
+ * Renders a child frame's snapshot (matching the current action's snapshotName)
606
+ * to an HTML string, recursing into its own child frames. Returns null when the
607
+ * frame has no snapshot for this action or when the depth/cycle guard trips.
608
+ */
609
+ function renderChildFrame(childFrameId, ctx) {
610
+ if (ctx.stack.has(childFrameId))
611
+ return null; // cycle guard
612
+ if (ctx.stack.size >= MAX_IFRAME_DEPTH)
613
+ return null; // runaway depth guard
614
+ const entry = ctx.frameSnapshotsByName.get(childFrameId)?.get(ctx.snapshotName);
615
+ if (!entry)
616
+ return null;
617
+ ctx.stack.add(childFrameId);
618
+ try {
619
+ return resolveSnapshotNode(entry.html, entry.historyIndex, childFrameId, ctx);
620
+ }
621
+ finally {
622
+ ctx.stack.delete(childFrameId);
623
+ }
624
+ }
509
625
  function escapeHtml(s) {
510
626
  return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
511
627
  }
@@ -527,19 +643,33 @@ function escapeAttr(s) {
527
643
  async function getDomSnapshots(traceContext, options) {
528
644
  const files = await fs.promises.readdir(traceContext.traceDir);
529
645
  const traceFiles = files.filter(f => f.endsWith('.trace') && f !== 'test.trace').sort();
530
- // Per-frame snapshot history: frameId → ordered list of raw html nodes
646
+ // Per-frame snapshot history: frameId → ordered list of raw html nodes (for back-refs).
531
647
  const frameHistory = new Map();
648
+ // Per-frame snapshot lookup: frameId → snapshotName → entry (for inlining child frames).
649
+ const frameSnapshotsByName = new Map();
532
650
  // Memoization cache for buildSnapshotNodeList — keyed by html object reference
533
651
  const dfsCache = new Map();
534
- // Collect resolved snapshots keyed by callId → phase
535
- const rawByCallId = new Map();
652
+ const mainFrameRecords = [];
653
+ // ---- Pass 1: collect every frame snapshot (main + child iframes) ----
536
654
  for (const traceFile of traceFiles) {
537
655
  const filePath = path.join(traceContext.traceDir, traceFile);
538
656
  for await (const event of (0, parseTrace_1.readNdjson)(filePath)) {
539
657
  if (event.type !== 'frame-snapshot')
540
658
  continue;
541
659
  const snap = event.snapshot;
542
- const { snapshotName, callId, frameId, frameUrl, pageId, viewport, timestamp, html } = snap;
660
+ const { snapshotName, callId, frameId, frameUrl, pageId, viewport, timestamp, html, isMainFrame } = snap;
661
+ // Append to per-frame history BEFORE anything else (so refs can point back to it)
662
+ if (!frameHistory.has(frameId))
663
+ frameHistory.set(frameId, []);
664
+ const history = frameHistory.get(frameId);
665
+ history.push(html);
666
+ const snapshotIndex = history.length - 1;
667
+ // Index by snapshotName so parent frames can inline this child by name.
668
+ if (!frameSnapshotsByName.has(frameId))
669
+ frameSnapshotsByName.set(frameId, new Map());
670
+ frameSnapshotsByName.get(frameId).set(snapshotName, { html, historyIndex: snapshotIndex });
671
+ if (!isMainFrame)
672
+ continue; // child frames are only inlined, never top-level entries
543
673
  // Determine phase from snapshotName prefix
544
674
  let phase;
545
675
  if (snapshotName.startsWith('before@')) {
@@ -554,33 +684,42 @@ async function getDomSnapshots(traceContext, options) {
554
684
  else {
555
685
  continue; // unknown phase, skip
556
686
  }
557
- // Append to per-frame history BEFORE resolving (so refs can point back to it)
558
- if (!frameHistory.has(frameId))
559
- frameHistory.set(frameId, []);
560
- const history = frameHistory.get(frameId);
561
- history.push(html);
562
- const snapshotIndex = history.length - 1;
563
- // Resolve the full html to a string using the correct ref algorithm
564
- const resolvedHtml = resolveSnapshotNode(html, snapshotIndex, history, dfsCache);
565
- // Extract the __playwright_target__ attribute to identify the targeted element
566
- const targetElement = findPlaywrightTarget(html);
567
- const domSnapshot = {
568
- callId,
569
- phase,
570
- snapshotName,
571
- frameId,
572
- frameUrl,
573
- pageId,
574
- timestamp,
575
- viewport,
576
- html: resolvedHtml,
577
- targetElement,
578
- };
579
- if (!rawByCallId.has(callId))
580
- rawByCallId.set(callId, new Map());
581
- rawByCallId.get(callId).set(phase, domSnapshot);
687
+ mainFrameRecords.push({
688
+ callId, phase, snapshotName, frameId, frameUrl, pageId, timestamp, viewport, html, snapshotIndex,
689
+ });
582
690
  }
583
691
  }
692
+ // ---- Pass 2: render each main-frame snapshot, inlining child iframes ----
693
+ const rawByCallId = new Map();
694
+ for (const rec of mainFrameRecords) {
695
+ const ctx = {
696
+ frameHistory,
697
+ frameSnapshotsByName,
698
+ dfsCache,
699
+ snapshotName: rec.snapshotName,
700
+ stack: new Set([rec.frameId]),
701
+ };
702
+ const resolvedHtml = resolveSnapshotNode(rec.html, rec.snapshotIndex, rec.frameId, ctx);
703
+ const targetElement = findPlaywrightTarget(rec.html, {
704
+ ...ctx,
705
+ stack: new Set([rec.frameId]),
706
+ });
707
+ const domSnapshot = {
708
+ callId: rec.callId,
709
+ phase: rec.phase,
710
+ snapshotName: rec.snapshotName,
711
+ frameId: rec.frameId,
712
+ frameUrl: rec.frameUrl,
713
+ pageId: rec.pageId,
714
+ timestamp: rec.timestamp,
715
+ viewport: rec.viewport,
716
+ html: resolvedHtml,
717
+ targetElement,
718
+ };
719
+ if (!rawByCallId.has(rec.callId))
720
+ rawByCallId.set(rec.callId, new Map());
721
+ rawByCallId.get(rec.callId).set(rec.phase, domSnapshot);
722
+ }
584
723
  // Assemble into ActionDomSnapshots
585
724
  let result = [];
586
725
  for (const [callId, phases] of rawByCallId) {
@@ -628,8 +767,14 @@ async function getDomSnapshots(traceContext, options) {
628
767
  }
629
768
  return result;
630
769
  }
631
- /** Recursively searches the snapshot tree for a node with __playwright_target__ */
632
- function findPlaywrightTarget(node) {
770
+ /**
771
+ * Recursively searches the snapshot tree for a node with __playwright_target__.
772
+ *
773
+ * When `ctx` is provided, the search also descends into child `<iframe>`/`<frame>`
774
+ * elements (matched by `src="/snapshot/<frameId>"`) so a target living inside a
775
+ * child frame is still found. Cycles and runaway depth are guarded via `ctx.stack`.
776
+ */
777
+ function findPlaywrightTarget(node, ctx) {
633
778
  if (!Array.isArray(node) || node.length < 2)
634
779
  return null;
635
780
  const attrs = node[1];
@@ -637,11 +782,32 @@ function findPlaywrightTarget(node) {
637
782
  const target = attrs['__playwright_target__'];
638
783
  if (target)
639
784
  return target;
785
+ // Descend into child frames so targets inside iframes are still found.
786
+ if (ctx && typeof node[0] === 'string') {
787
+ const tag = node[0].toLowerCase();
788
+ if (tag === 'iframe' || tag === 'frame') {
789
+ const childFrameId = parseSnapshotFrameId(attrs['src']);
790
+ if (childFrameId && !ctx.stack.has(childFrameId) && ctx.stack.size < MAX_IFRAME_DEPTH) {
791
+ const entry = ctx.frameSnapshotsByName.get(childFrameId)?.get(ctx.snapshotName);
792
+ if (entry) {
793
+ ctx.stack.add(childFrameId);
794
+ try {
795
+ const found = findPlaywrightTarget(entry.html, ctx);
796
+ if (found)
797
+ return found;
798
+ }
799
+ finally {
800
+ ctx.stack.delete(childFrameId);
801
+ }
802
+ }
803
+ }
804
+ }
805
+ }
640
806
  }
641
807
  for (let i = 2; i < node.length; i++) {
642
808
  const child = node[i];
643
809
  if (Array.isArray(child)) {
644
- const found = findPlaywrightTarget(child);
810
+ const found = findPlaywrightTarget(child, ctx);
645
811
  if (found)
646
812
  return found;
647
813
  }
@@ -717,71 +883,6 @@ function buildActionDiagnostics(networkCalls, issues) {
717
883
  return rightScore - leftScore;
718
884
  });
719
885
  }
720
- function buildReportFailurePatterns(selections) {
721
- const realFailures = selections.filter(selection => selection.summary.outcome !== 'skipped');
722
- const repeatedFailingRequests = new Map();
723
- const repeatedIssues = new Map();
724
- for (const selection of realFailures) {
725
- for (const entry of selection.summary.networkCalls) {
726
- if (entry.status < 400)
727
- continue;
728
- const signature = buildRequestPatternSignature(entry);
729
- const bucket = repeatedFailingRequests.get(signature) ?? {
730
- method: entry.method,
731
- url: stripQuery(entry.url),
732
- traces: new Set(),
733
- statuses: new Set(),
734
- relatedActions: new Map(),
735
- };
736
- bucket.traces.add(selection.traceSha1);
737
- bucket.statuses.add(entry.status);
738
- if (entry.relatedAction)
739
- bucket.relatedActions.set(entry.relatedAction.callId, { callId: entry.relatedAction.callId, title: entry.relatedAction.title });
740
- repeatedFailingRequests.set(signature, bucket);
741
- }
742
- for (const issue of selection.summary.issues) {
743
- if (!issue.relatedAction)
744
- continue;
745
- const signature = buildIssuePatternSignature(issue);
746
- const bucket = repeatedIssues.get(signature) ?? {
747
- source: issue.source,
748
- name: issue.name,
749
- message: firstLine(issue.message) ?? issue.message,
750
- traces: new Set(),
751
- relatedActions: new Map(),
752
- };
753
- bucket.traces.add(selection.traceSha1);
754
- bucket.relatedActions.set(issue.relatedAction.callId, { callId: issue.relatedAction.callId, title: issue.relatedAction.title });
755
- repeatedIssues.set(signature, bucket);
756
- }
757
- }
758
- return {
759
- repeatedFailingRequests: [...repeatedFailingRequests.entries()]
760
- .map(([signature, bucket]) => ({
761
- signature,
762
- method: bucket.method,
763
- url: bucket.url,
764
- count: bucket.traces.size,
765
- traceSha1s: [...bucket.traces].sort(),
766
- statuses: [...bucket.statuses].sort((left, right) => left - right),
767
- relatedActions: [...bucket.relatedActions.values()],
768
- }))
769
- .filter(pattern => pattern.count > 1)
770
- .sort((left, right) => right.count - left.count),
771
- repeatedIssues: [...repeatedIssues.entries()]
772
- .map(([signature, bucket]) => ({
773
- signature,
774
- source: bucket.source,
775
- name: bucket.name,
776
- message: bucket.message,
777
- count: bucket.traces.size,
778
- traceSha1s: [...bucket.traces].sort(),
779
- relatedActions: [...bucket.relatedActions.values()],
780
- }))
781
- .filter(pattern => pattern.count > 1)
782
- .sort((left, right) => right.count - left.count),
783
- };
784
- }
785
886
  async function attachmentSize(traceContext, attachment) {
786
887
  if (attachment.sha1) {
787
888
  const buffer = await (0, parseTrace_1.getResourceBuffer)(traceContext, attachment.sha1);
@@ -886,60 +987,6 @@ function filterNetworkEntries(entries, options) {
886
987
  filtered = filtered.slice(0, options.limit);
887
988
  return filtered;
888
989
  }
889
- function buildRequestPatternSignature(entry) {
890
- try {
891
- const parsed = new URL(entry.url);
892
- return `${entry.method.toUpperCase()} ${normalizePathname(parsed.pathname)}`;
893
- }
894
- catch {
895
- return `${entry.method.toUpperCase()} ${entry.url}`;
896
- }
897
- }
898
- function buildIssuePatternSignature(issue) {
899
- return [
900
- issue.source,
901
- issue.name ?? 'Error',
902
- normalizeIssueMessage(firstLine(issue.message) ?? issue.message),
903
- ].join(' | ');
904
- }
905
- function normalizePathname(pathname) {
906
- const segments = pathname.split('/').filter(Boolean);
907
- if (segments.length === 0)
908
- return '/';
909
- return `/${segments.map(normalizePathSegment).join('/')}`;
910
- }
911
- function normalizePathSegment(segment) {
912
- if (/^\d+$/.test(segment))
913
- return ':id';
914
- if (/^[0-9a-f]{8,}$/i.test(segment))
915
- return ':id';
916
- if (/^[0-9a-f]{8}-[0-9a-f-]{27,}$/i.test(segment))
917
- return ':id';
918
- if (/^trace-[\w-]+$/i.test(segment))
919
- return ':id';
920
- return segment;
921
- }
922
- function normalizeIssueMessage(message) {
923
- return message
924
- .replace(/trace-[\w-]+/gi, ':trace')
925
- .replace(/call@[\w-]+/gi, 'call@:id')
926
- .replace(/\b[0-9a-f]{8,}\b/gi, ':id')
927
- .replace(/\b\d+\b/g, ':n');
928
- }
929
- function stripQuery(urlText) {
930
- try {
931
- const parsed = new URL(urlText);
932
- parsed.search = '';
933
- parsed.hash = '';
934
- return parsed.toString();
935
- }
936
- catch {
937
- return urlText;
938
- }
939
- }
940
- function firstLine(value) {
941
- return value ? value.split(/\r?\n/, 1)[0] ?? null : null;
942
- }
943
990
  /**
944
991
  * Merges all trace event types (steps, screenshots, DOM snapshots, network
945
992
  * calls) into a single chronologically sorted array.
@@ -1086,13 +1133,6 @@ async function getSummary(traceContext, options) {
1086
1133
  : null,
1087
1134
  };
1088
1135
  }
1089
- async function getReportFailurePatterns(reportDataDir, options) {
1090
- const selections = await getFailedTraceSelections(reportDataDir, options);
1091
- return buildReportFailurePatterns(selections);
1092
- }
1093
- function summarizeReportFailurePatterns(selections) {
1094
- return buildReportFailurePatterns(selections);
1095
- }
1096
1136
  async function getFailedTraceSelections(reportDataDir, options) {
1097
1137
  const traces = await (0, parseTrace_1.listTraces)(reportDataDir);
1098
1138
  const meta = await (0, parseTrace_1.getReportMetadata)(reportDataDir);