reporting-labs 0.6.11 → 0.6.13

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/dist/reporter.js CHANGED
@@ -44,6 +44,8 @@ const child_process_1 = require("child_process");
44
44
  const template_1 = require("./template");
45
45
  const mask_1 = require("./mask");
46
46
  const explain_1 = require("./explain");
47
+ const pdf_1 = require("./pdf");
48
+ const comments_1 = require("./comments");
47
49
  const DEFAULT_EMBED_LIMIT = 2 * 1024 * 1024;
48
50
  /** Attach steps created by log() and the automatic API capture; the data shows in its own section, so hide the step. */
49
51
  function isInternalAttach(s) {
@@ -134,7 +136,8 @@ class ReportingLabsReporter {
134
136
  const last = test.results[test.results.length - 1];
135
137
  const resultAnn = (last?.annotations ?? []);
136
138
  const annotations = [...test.annotations, ...resultAnn.filter(a => !test.annotations.some(b => b.type === a.type && b.description === a.description))];
137
- const extracted = this.extractMeta(test);
139
+ const fromComments = this.commentMeta(test);
140
+ const extracted = this.extractMeta(test, fromComments);
138
141
  tests.push({
139
142
  id: test.id,
140
143
  key: `${project}::${file}::${[...titlePath, test.title].join(' › ')}${test.repeatEachIndex ? ' #' + (test.repeatEachIndex + 1) : ''}`,
@@ -144,7 +147,7 @@ class ReportingLabsReporter {
144
147
  line: test.location.line,
145
148
  column: test.location.column,
146
149
  project,
147
- tags: test.tags,
150
+ tags: [...test.tags, ...fromComments.tags.filter(g => !test.tags.includes(g))],
148
151
  annotations,
149
152
  meta: extracted.meta,
150
153
  links: Object.keys(extracted.links).length ? extracted.links : undefined,
@@ -247,31 +250,14 @@ class ReportingLabsReporter {
247
250
  await this.writePdf(file);
248
251
  this.maybeOpen(file, result);
249
252
  }
250
- /** Render the report's print layout to a PDF with the Chromium that Playwright already ships. Best-effort:
251
- * a failure here (no browser, sandbox) never fails the run — the report and its Export PDF button remain. */
253
+ /** report.pdf next to the HTML; see writeReportPdf for which browser prints it. Never fails the run. */
252
254
  async writePdf(htmlFile) {
253
- const name = (typeof this.options.pdf === 'object' && this.options.pdf?.file) || 'report.pdf';
254
- const pdfFile = path.join(this.outDir, name);
255
- try {
256
- const { chromium } = await import('@playwright/test');
257
- const { pathToFileURL } = await import('url');
258
- const browser = await chromium.launch();
259
- try {
260
- const page = await browser.newPage();
261
- await page.goto(pathToFileURL(htmlFile).href, { waitUntil: 'load' });
262
- await page.evaluate(() => window.reportingLabsPreparePrint?.());
263
- await page.pdf({ path: pdfFile, printBackground: true, preferCSSPageSize: true });
264
- }
265
- finally {
266
- await browser.close();
267
- }
268
- if (this.options.announce !== false)
269
- console.log(` reporting-labs: PDF written to ${path.relative(process.cwd(), pdfFile)}\n`);
270
- }
271
- catch (e) {
272
- if (this.options.announce !== false)
273
- console.log(` reporting-labs: PDF skipped — ${String(e.message).split('\n')[0]}\n`);
274
- }
255
+ const pdfOpt = typeof this.options.pdf === 'object' ? this.options.pdf : {};
256
+ const pdfFile = path.join(this.outDir, pdfOpt.file || 'report.pdf');
257
+ const r = await (0, pdf_1.writeReportPdf)(htmlFile, pdfFile, pdfOpt.chromePath);
258
+ if (this.options.announce === false)
259
+ return;
260
+ console.log(r.ok ? ` reporting-labs: PDF written to ${path.relative(process.cwd(), pdfFile)}\n` : ` reporting-labs: PDF skipped — ${r.reason}\n`);
275
261
  }
276
262
  /** One short list of tests that carry no meta() at all, so the whole team keeps the report useful. */
277
263
  printMissingMeta(tests) {
@@ -289,7 +275,8 @@ class ReportingLabsReporter {
289
275
  console.log(` ${(t.file + ':' + t.line).padEnd(w)} ${t.title}`);
290
276
  if (missing.length > show.length)
291
277
  console.log(` … and ${missing.length - show.length} more`);
292
- console.log(" Add meta({ priority: 'P1', owner: 'name', feature: 'area' }) at the top of the test. Set warnMissingMeta: false to hide this.");
278
+ console.log(" Add meta({ priority: 'P1', owner: 'name', feature: 'area' }) at the top of the test, or a comment right above it:");
279
+ console.log(" /** @priority P1 @owner name @feature area */. Set warnMissingMeta: false to hide this.");
293
280
  }
294
281
  /** Open the report in the default browser, like Playwright's HTML reporter. Never in CI. */
295
282
  maybeOpen(file, result) {
@@ -439,12 +426,36 @@ class ReportingLabsReporter {
439
426
  * An object value (meta({ octaneTestCase: { id, p } })) is folded to its display text and, when the key has a
440
427
  * link template, to a ready-made href in `links`; the other fields never show in the report.
441
428
  */
442
- extractMeta(test) {
429
+ /** Meta from comments above the test and its describe blocks (outer first, the test's own comment last). */
430
+ commentMeta(test) {
431
+ const out = { meta: {}, tags: [] };
432
+ if (this.options.commentMeta === false)
433
+ return out;
434
+ try {
435
+ const dims = this.metaKeys();
436
+ const at = [];
437
+ for (let s = test.parent; s; s = s.parent)
438
+ if (s.type === 'describe' && s.location)
439
+ at.unshift(s.location);
440
+ at.push(test.location);
441
+ for (const loc of at) {
442
+ const c = (0, comments_1.commentMetaAt)(loc.file, loc.line);
443
+ Object.assign(out.meta, c.meta);
444
+ // a meta key left without a value (`@priority`) is not a tag
445
+ for (const g of c.tags)
446
+ if (!out.tags.includes(g) && !dims.includes(g.slice(1).toLowerCase()))
447
+ out.tags.push(g);
448
+ }
449
+ }
450
+ catch { /* comments are a convenience: never fail the report over them */ }
451
+ return out;
452
+ }
453
+ extractMeta(test, fromComments = { meta: {}, tags: [] }) {
443
454
  const dims = this.metaKeys();
444
455
  const meta = {};
445
456
  const links = {};
446
- // Tags first (describe-level, then test-level), annotations last so a test can override its describe's tags.
447
- for (const raw of test.tags) {
457
+ // Tags first (describe-level, then test-level), then comments, then annotations: meta() in the code wins.
458
+ for (const raw of [...test.tags, ...fromComments.tags]) {
448
459
  const tag = raw.replace(/^@/, '');
449
460
  const m = tag.match(/^([a-z_-]+)[:=](.+)$/i);
450
461
  if (m && dims.includes(m[1].toLowerCase())) {
@@ -456,6 +467,9 @@ class ReportingLabsReporter {
456
467
  if (/^(blocker|critical|major|minor|trivial)$/i.test(tag) && dims.includes('severity') && !meta.severity)
457
468
  meta.severity = tag.toLowerCase();
458
469
  }
470
+ for (const [k, v] of Object.entries(fromComments.meta))
471
+ if (dims.includes(k))
472
+ meta[k] = v;
459
473
  for (const a of test.annotations) {
460
474
  const k = a.type.toLowerCase();
461
475
  if (!dims.includes(k) || !a.description)
@@ -344,6 +344,10 @@ li.collapsed>ul{display:none}
344
344
  .wk .row{display:grid;grid-template-columns:36px 1fr 120px;gap:10px;align-items:center;font-size:12px}
345
345
  .wk .k{font:12px var(--mono);color:var(--ink-3)} .wk .bar{height:12px;display:flex;border-radius:3px;overflow:hidden;background:var(--skip-bg)} .wk .bar i{display:block;height:100%}
346
346
  .wk .n{font:11px var(--mono);color:var(--ink-3);text-align:right}
347
+ .wk .row{grid-template-columns:36px 1fr auto} .wk .n{white-space:nowrap}
348
+ .proj-sfx{font-weight:400;color:var(--ink-3);font-size:.9em}
349
+ /* the Breakdown card keeps its own height: a two-priority suite should not leave a tall empty card */
350
+ .bd-card{align-self:start}
347
351
  .wk-sum{font-size:13px;color:var(--ink-2);margin-bottom:10px}
348
352
  /* list: group toggle + folder tree */
349
353
  .tools .seg,.bug-tools .seg{display:inline-flex;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
@@ -379,7 +383,9 @@ table.tbl{border-collapse:collapse;font-size:12.5px;width:100%;min-width:100%}
379
383
  .api-head .m{font:11px/1 var(--mono);font-weight:600;padding:4px 7px;border-radius:3px;color:#fff;background:var(--ink-3)}
380
384
  .api-head .m.GET{background:#2A7FBF} .api-head .m.POST{background:var(--pass)} .api-head .m.PUT,.api-head .m.PATCH{background:#C77D14} .api-head .m.DELETE{background:var(--fail)}
381
385
  .api-head .u{flex:1;font:12px var(--mono);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
382
- .api-head .sc{font:12px var(--mono);font-weight:600} .api-head .sc.ok{color:var(--pass)} .api-head .sc.bad{color:var(--fail)} .api-head .sc.warn{color:#9A6A00}
386
+ .api-head .sc{font:12px var(--mono);font-weight:600} .api-head .sc.ok{color:var(--pass)} .api-head .sc.bad{color:var(--fail)} .api-head .sc.warn{color:#9A6A00} .api-head .sc.exp{color:var(--ink-2)}
387
+ .sc-exp{margin-left:6px;font:500 10.5px var(--sans);color:var(--ink-3);background:var(--surface-2);border:1px solid var(--line);border-radius:999px;padding:1px 7px;vertical-align:1px}
388
+ .api-stats .exp b{color:var(--ink-2)} .api-proj{color:var(--ink-3)}
383
389
  .api-head .d{font:11px var(--mono);color:var(--ink-3)}
384
390
  .api-body{display:grid;grid-template-columns:1fr 1fr;gap:0}
385
391
  @media (max-width:900px){.api-body{grid-template-columns:1fr}}
@@ -559,13 +565,15 @@ html,body{-webkit-font-smoothing:antialiased}
559
565
  .runbanner{margin-bottom:14px;padding:10px 14px;border-radius:10px;background:var(--flaky-bg);color:var(--flaky-ink);border:1px solid color-mix(in srgb,var(--flaky) 40%,transparent)}
560
566
  .note{padding:10px 14px;border-radius:8px;margin-bottom:10px;border:1px solid var(--line)} .note.ok{background:var(--pass-bg);color:var(--ink)} .note.warn{background:var(--flaky-bg);color:var(--flaky-ink)}
561
567
  .badge.xfail{background:var(--flaky-bg);color:var(--flaky-ink)}
568
+ .xp{font-weight:500} .xp.all{color:var(--ink)} .xp.some{color:var(--flaky-ink)}
569
+ .badge.xp{background:var(--surface-2);border:1px solid var(--line)} .badge.xp.some{background:var(--flaky-bg);border-color:transparent}
562
570
  .errwrap+.errwrap{margin-top:14px}
563
571
  .why{border:1px solid var(--line);border-radius:var(--radius);padding:10px 14px;margin-bottom:10px;background:var(--surface)}
564
572
  .why-c{font-size:12.5px;color:var(--ink);margin-bottom:2px;line-height:1.4;overflow-wrap:anywhere} .why-c .why-k{margin-right:2px}
565
573
  .why-l{display:flex;align-items:center;gap:8px;margin-bottom:4px} .why-k{font-size:12px;font-weight:600;color:var(--fail)} .why-a{font:11.5px var(--mono);color:var(--ink-3)}
566
574
  .why-s{font-size:var(--fs);color:var(--ink);line-height:1.45;overflow-wrap:anywhere} .why-h{font-size:12.5px;color:var(--ink-2);margin-top:4px;line-height:1.45;overflow-wrap:anywhere}
567
575
  .why.assertion .why-k,.why.visual .why-k{color:#9A6A00}
568
- .why.script .why-k,.why.thrown .why-k,.why.file .why-k{color:var(--ink-2)}
576
+ .why.script .why-k,.why.thrown .why-k,.why.file .why-k,.why.crashed .why-k{color:var(--ink-2)}
569
577
  .errloc{font-family:var(--mono);color:var(--ink-3);margin-bottom:6px} .errloc a{color:var(--accent-2);text-decoration:none} .errloc a:hover{text-decoration:underline}
570
578
  .snip{margin:10px 0 0;background:var(--surface-2);border:1px solid var(--line);border-radius:8px;padding:10px 12px;font-family:var(--mono);line-height:1.55;white-space:pre;overflow:auto;color:var(--ink-2)}
571
579
  /* ---------- triage extras: history, diff, export, env, heatmap ---------- */
@@ -765,6 +773,14 @@ const HIST = data.history||[];
765
773
  const HRUNS = HIST.filter(e=>e&&e.tests); // entries that carry per-test outcomes; the last one is this run
766
774
  const PREV = HRUNS.length>1 ? HRUNS.slice(0,-1) : []; // earlier runs only
767
775
  const runLabel = e => e.label || new Date(e.time).toLocaleDateString(undefined,{month:'short',day:'numeric'});
776
+ /* Run-level trends (Trend card, KPI sparklines and "from last run", pass rate by priority) only use full-size
777
+ runs. A debug run of one spec or a --grep shares the history file with the full suite; a failing 1-test run
778
+ would read as a 0% day. A run is "small" when it ran fewer than half the median size of the recorded runs.
779
+ Per-test history (dots, flaky, new vs known) still uses every run: there a run only counts for the tests in it. */
780
+ const MED_SIZE = (()=>{ const z=HIST.map(e=>e.total||0).sort((a,b)=>a-b); return z.length? z[Math.floor(z.length/2)] : 0; })();
781
+ const isSmallRun = e => HIST.length>=3 && (e.total||0) < MED_SIZE/2;
782
+ const TREND = (()=>{ const f=HIST.filter((e,i)=>!isSmallRun(e)); return f.length>=2? f : HIST; })();
783
+ const SMALL_HIDDEN = HIST.length - TREND.length;
768
784
 
769
785
  const state = { q:'', status:'all', project:'all', dims:{}, selected:null, retry:null, group:'file', open:{}, view:'overview' };
770
786
  const DIMS = data.options.dimensions.filter(d=>data.tests.some(t=>t.meta[d]));
@@ -826,17 +842,20 @@ function failuresView(){
826
842
  h('td',{class:'t'},t.file.split('/').pop()+(data.projects.length>1?' · '+t.project:'')), h('td',{},[t.meta.priority,t.meta.severity].filter(Boolean).join(' · ')), h('td',{},t.meta.owner||''), h('td',{},t.meta.story||t.meta.issue||''), h('td',{},t.results.length), PREV.length?h('td',{},(()=>{ const si=sinceInfo(t); return si? h('span',{class:'since-txt '+si.kind}, si.kind==='new'?'new':runLabel(si.since)) : h('span',{class:'t'},'–'); })()):null, HRUNS.length>1?h('td',{},dots(t,10)):null, h('td',{class:'t'},ms(t.duration))); })))));
827
843
  return grid;
828
844
  }
845
+ /** A 4xx/5xx is a failure only when the attempt that made the call failed. In a passing attempt it is the
846
+ * answer the test asked for (a 404 after a DELETE, a 401 for a bad token) — shown as "expected", never red. */
847
+ function apiCls(c,r){ const st=c.status||0; return st>=400 ? (r&&r.status==='passed'?'exp':'bad') : st>=300?'warn':'ok'; }
829
848
  function apiView(){
830
- const calls=[]; for(const t of data.tests) for(const r of t.results) for(const c of r.api) calls.push({c,t,r});
849
+ const calls=[]; for(const t of data.tests) for(const r of t.results) for(const c of r.api) calls.push({c,t,r,cls:apiCls(c,r)});
831
850
  if(!calls.length) return h('div',{class:'card'},h('b',{},'No API calls recorded.'),' Add ',h('code',{},"import 'reporting-labs/auto'"),' to playwright.config.ts and every request.get / request.post / page.request call shows up here with headers, bodies and a cURL command. Calls made with other clients can be recorded with api().');
832
- const bad=calls.filter(x=>(x.c.status||0)>=400).length, avg=Math.round(calls.reduce((a,x)=>a+(x.c.duration||0),0)/calls.length), slow=calls.filter(x=>(x.c.duration||0)>1000).length;
833
- calls.sort((a,b)=>((b.c.status||0)>=400)-((a.c.status||0)>=400)||(b.c.duration||0)-(a.c.duration||0));
851
+ const bad=calls.filter(x=>x.cls==='bad').length, expd=calls.filter(x=>x.cls==='exp').length, avg=Math.round(calls.reduce((a,x)=>a+(x.c.duration||0),0)/calls.length), slow=calls.filter(x=>(x.c.duration||0)>1000).length;
852
+ calls.sort((a,b)=>(b.cls==='bad')-(a.cls==='bad')||(b.c.duration||0)-(a.c.duration||0));
834
853
  const byHost=new Map(); for(const x of calls){ try{ const hst=new URL(x.c.url).host; byHost.set(hst,(byHost.get(hst)||0)+1);}catch(e){} }
835
- return h('div',{}, h('div',{class:'api-stats'}, h('span',{},h('b',{},calls.length),' calls'), h('span',{class:bad?'bad':''},h('b',{},bad),' failed (4xx/5xx)'), h('span',{},h('b',{},ms(avg)),' avg'), h('span',{},h('b',{},slow),' over 1s'), h('span',{},h('b',{},byHost.size),' host'+(byHost.size===1?'':'s'))),
854
+ return h('div',{}, h('div',{class:'api-stats'}, h('span',{},h('b',{},calls.length),' calls'), h('span',{class:bad?'bad':'',title:'4xx / 5xx responses in tests that failed'},h('b',{},bad),' failed (4xx/5xx)'), expd?h('span',{class:'exp',title:'4xx / 5xx responses in tests that passed: the answer the test expected, e.g. a 404 after a DELETE'},h('b',{},expd),' expected 4xx/5xx'):null, h('span',{},h('b',{},ms(avg)),' avg'), h('span',{},h('b',{},slow),' over 1s'), h('span',{},h('b',{},byHost.size),' host'+(byHost.size===1?'':'s'))),
836
855
  h('div',{class:'card w12'}, h('table',{class:'apitbl'}, h('thead',{}, h('tr',{}, ['Method','URL','Status','Time','Test'].map(x=>h('th',{},x)))),
837
- h('tbody',{}, calls.map(({c,t})=>{ const st=c.status||0, cls=st>=400?'bad':st>=300?'warn':'ok'; return h('tr',{onclick:()=>select(t.id)},
856
+ h('tbody',{}, calls.map(({c,t,cls})=>{ const st=c.status||0; return h('tr',{onclick:()=>select(t.id)},
838
857
  h('td',{}, h('span',{class:'m '+c.method.toUpperCase(),style:'font:11px var(--mono);font-weight:600;padding:3px 6px;border-radius:3px;color:#fff;background:'+({GET:'#2A7FBF',POST:'var(--pass)',PUT:'#C77D14',PATCH:'#C77D14',DELETE:'var(--fail)'}[c.method.toUpperCase()]||'var(--ink-3)')},c.method.toUpperCase())),
839
- h('td',{class:'u',title:c.url},c.url), h('td',{}, h('span',{class:'sc '+cls,style:'font:12px var(--mono);font-weight:600;color:'+(cls==='bad'?'var(--fail)':cls==='warn'?'var(--flaky-ink)':'var(--pass)')},st||'—')), h('td',{class:'t'},c.duration!=null?ms(c.duration):'—'), h('td',{class:'t',title:t.title},t.title)); })))));
858
+ h('td',{class:'u',title:c.url},c.url), h('td',{}, h('span',{class:'sc '+cls,style:'font:12px var(--mono);font-weight:600;color:'+(cls==='bad'?'var(--fail)':cls==='warn'?'var(--flaky-ink)':cls==='exp'?'var(--ink-2)':'var(--pass)'),title:cls==='exp'?'The test passed: this is the response it expected':''},st||'—'), cls==='exp'?h('span',{class:'sc-exp'},'expected'):null), h('td',{class:'t'},c.duration!=null?ms(c.duration):'—'), h('td',{class:'t',title:t.title},t.title, data.projects.length>1?h('span',{class:'api-proj'},' · '+t.project):null)); })))));
840
859
  }
841
860
  function timelineView(){
842
861
  const W=data.options.widgets, cards=[];
@@ -852,8 +871,9 @@ function graphsView(){
852
871
  return h('div',{class:'view-pad'},
853
872
  h('div',{class:'grid graphs-grid'},
854
873
  chartCard('outcomes-by-priority', 'Outcomes by priority', 'Stacked pass / fail / flaky / skipped for each priority tier.', chartPriorityOutcome),
874
+ data.projects.length>1? chartCard('outcomes-by-project', 'Outcomes by project', 'Pass / fail / flaky / skipped and the pass rate for each project (browser, device).', chartProjectOutcome) : null,
855
875
  chartCard('failure-categories', 'Failure categories', 'What kinds of failures are hurting the suite.', chartFailureCategories),
856
- chartCard('duration-distribution','Duration distribution', 'How test durations are spread across the run.', chartDurationHistogram),
876
+ chartCard('duration-distribution','Duration distribution', 'How the durations of the tests that ran are spread.', chartDurationHistogram),
857
877
  chartCard('trend-by-priority', 'Pass rate trend by priority', 'How each priority tier trends over the last runs.', chartTrendByPriority),
858
878
  chartCard('owner-leaderboard', 'Owner leaderboard', 'Failures and flakes ranked by owner. Add meta({owner:...}) to see this.', chartOwnerLeaderboard),
859
879
  ));
@@ -908,6 +928,29 @@ function chartCard(id, title, sub, chartFn){
908
928
  }
909
929
 
910
930
  /* Chart 1: horizontal stacked bar per priority (P0..P4 in order, plus 'no priority') */
931
+ /* Chart 1b: the same stacked bars per Playwright project (chromium, firefox, Microsoft Edge...), with each
932
+ project's pass rate, so a browser that fails more than the others stands out. */
933
+ function chartProjectOutcome(){
934
+ if(data.projects.length<2) return null;
935
+ const outs=['passed','flaky','failed','timedOut','interrupted','skipped'];
936
+ const colors={passed:'var(--pass)', flaky:'var(--flaky)', failed:'var(--fail)', timedOut:'var(--fail)', interrupted:'var(--fail)', skipped:'var(--skip)'};
937
+ const rows=data.projects.map(p=>{ const m={}; for(const o of outs) m[o]=0; for(const t of data.tests) if(t.project===p) m[t.outcome]=(m[t.outcome]||0)+1; return {p,m}; }).filter(r=>outs.some(o=>r.m[o]));
938
+ if(!rows.length) return null;
939
+ const tot=r=>outs.reduce((a,o)=>a+r.m[o],0), maxN=Math.max(...rows.map(tot));
940
+ const longest=Math.max(...rows.map(r=>r.p.length));
941
+ const W=520, rowH=28, gap=10, labW=Math.min(170,Math.max(70,longest*7+10)), barW=W-labW-96;
942
+ const H=rows.length*(rowH+gap)+30;
943
+ const parts=rows.map((r,i)=>{
944
+ const y=i*(rowH+gap)+18, n=tot(r), ran=n-r.m.skipped, rate=ran?Math.round(r.m.passed/ran*100):null, scale=barW/maxN;
945
+ let x=labW; const segs=[];
946
+ for(const o of outs){ const w=r.m[o]*scale; if(w<=0) continue; segs.push('<rect x="'+x+'" y="'+y+'" width="'+w+'" height="'+rowH+'" fill="'+colors[o]+'" data-outcome="'+o+'"><title>'+gEsc(r.p)+' · '+label[o]+' '+r.m[o]+'</title></rect>'); x+=w; }
947
+ return '<text x="0" y="'+(y+rowH/2+4)+'" fill="var(--ink)" font-size="12" font-weight="600">'+gEsc(r.p)+'</text>'+segs.join('')+
948
+ '<text x="'+(labW+barW+8)+'" y="'+(y+rowH/2+4)+'" fill="var(--ink-2)" font-size="12" font-variant-numeric="tabular-nums">'+n+(rate==null?'':' · <tspan fill="'+(rate===100?'var(--pass)':r.m.failed+r.m.timedOut+r.m.interrupted?'var(--fail)':'var(--ink-2)')+'" font-weight="600">'+rate+'%</tspan>')+'</text>';
949
+ }).join('');
950
+ const legend=outs.filter(o=>rows.some(r=>r.m[o]>0)).map(o=>'<rect width="10" height="10" fill="'+colors[o]+'"/><text x="14" y="9" fill="var(--ink-2)" font-size="11">'+label[o]+'</text>');
951
+ const legendSvg='<g transform="translate('+labW+','+(H-2)+')">'+legend.map((g,i)=>'<g transform="translate('+(i*90)+',0)">'+g+'</g>').join('')+'</g>';
952
+ return h('div',{class:'gchart-body',html:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '+W+' '+(H+18)+'" width="100%">'+parts+legendSvg+'</svg>'});
953
+ }
911
954
  function chartPriorityOutcome(){
912
955
  const order = ['P0','P1','P2','P3','P4'];
913
956
  const outs = ['passed','flaky','failed','timedOut','interrupted','skipped'];
@@ -962,7 +1005,7 @@ function chartDurationHistogram(){
962
1005
  {label:'30s+', min:30000,max:Infinity},
963
1006
  ];
964
1007
  const counts = buckets.map(()=>0);
965
- for(const t of data.tests){ const d=t.duration||0; for(let i=0;i<buckets.length;i++){ if(d>=buckets[i].min && d<buckets[i].max){ counts[i]++; break; } } }
1008
+ for(const t of data.tests){ if(t.outcome==='skipped') continue; const d=t.duration||0; for(let i=0;i<buckets.length;i++){ if(d>=buckets[i].min && d<buckets[i].max){ counts[i]++; break; } } }
966
1009
  const maxN = Math.max(1,...counts);
967
1010
  const W=520, colW=80, gap=16, padL=32, padT=24, padB=36, chartH=180;
968
1011
  const H = chartH+padT+padB;
@@ -977,7 +1020,7 @@ function chartDurationHistogram(){
977
1020
 
978
1021
  /* Chart 4: multi-line — pass rate per priority over the last N history entries */
979
1022
  function chartTrendByPriority(){
980
- const hist = data.history || [];
1023
+ const hist = TREND;
981
1024
  if(hist.length < 2) return null;
982
1025
  const orders = ['P0','P1','P2','P3','P4'];
983
1026
  const seenPri = new Set();
@@ -1129,12 +1172,12 @@ function summary(){
1129
1172
  const hasFail=data.tests.some(t=>isFail(t.outcome)||t.outcome==='flaky');
1130
1173
  if(W.attention && hasFail) g.push(h('div',{class:'card w6 fail-rail'}, h('h2',{},'Needs attention', h('span',{class:'hint'},(failed+s.flaky)+' open · ranked by priority and severity')), attention(8)));
1131
1174
  const clusters=failureClusters(); if(clusters.length) g.push(h('div',{class:'card w6 fail-rail'}, h('h2',{},'Failure clusters', h('span',{class:'hint'},clusters.length+' root cause'+(clusters.length>1?'s':'')+' · '+clusters.reduce((a,c)=>a+c.tests.length,0)+' failures')), clustersView(clusters.slice(0,6)), clusters.length>6?h('div',{class:'attn-foot'}, h('button',{onclick:()=>showView('failures')},'View all '+clusters.length+' clusters →')):null));
1132
- if(W.dimensions) g.push(h('div',{class:'card w8'}, h('h2',{},'Breakdown', h('span',{class:'hint'},'click a row to filter')), breakdown()));
1175
+ if(W.dimensions) g.push(h('div',{class:'card w8 bd-card'}, h('h2',{},'Breakdown', h('span',{class:'hint'},'click a row to filter')), breakdown()));
1133
1176
  if(W.slowest){ const reg=regressions().length; g.push(h('div',{class:'card'}, h('h2',{},'Slowest tests', reg?h('span',{class:'hint badge'},reg+' got slower'):null), tabbed([['slow','Slowest',slowest],['reg','Got slower'+(reg?' ('+reg+')':''),slowerView]]))); }
1134
1177
  if(W.flaky!==false && HRUNS.length>1) g.push(h('div',{class:'card'}, h('h2',{},'Flakiest tests', h('span',{class:'hint'},'last '+Math.min(10,HRUNS.length)+' runs')), flakiest()));
1135
1178
  if(W.skipped!==false) { const sc=skippedCard(); if(sc) g.push(sc); }
1136
1179
  if(W.environment!==false) { const ec=envCard(); if(ec) g.push(ec); }
1137
- if(data.history.length>1) g.push(h('div',{class:'card w12'}, h('h2',{},'Trend', h('span',{class:'hint'},'last '+data.history.length+' runs')), trend()));
1180
+ if(data.history.length>1) g.push(h('div',{class:'card w12'}, h('h2',{},'Trend', h('span',{class:'hint'},'last '+TREND.length+' runs'+(SMALL_HIDDEN?' · '+SMALL_HIDDEN+' small run'+(SMALL_HIDDEN>1?'s':'')+' (under '+Math.ceil(MED_SIZE/2)+' tests) not plotted':''))), trend()));
1138
1181
  else if(data.history.length===1) g.push(h('div',{class:'card w12'}, h('h2',{},'Trend', h('span',{class:'hint'},'from the second run')), h('div',{class:'nudge'}, h('b',{},'First run recorded.'),' Run the suite once more and this card shows the pass-rate trend, and every failure gets "new this run" or "failing since #…", last-10-runs dots, a Flakiest tests card and a Got slower tab. History lives in ',h('code',{},data.historyFile||'reporting-labs.history.json'),', commit it or cache it in CI.')));
1139
1182
  const ge=data.globalErrors||[], go=data.globalOutput||[];
1140
1183
  if(ge.length||go.some(x=>x.stream==='err')) g.unshift(h('div',{class:'card w12 fail-rail'}, h('h2',{}, ge.length? ge.length+' error'+(ge.length>1?'s':'')+' outside tests' : 'Output outside tests', h('span',{class:'hint'},'spec files that failed to load, global setup, worker crashes')),
@@ -1148,10 +1191,15 @@ function pill(key,text,n,color,sub,tone,series){
1148
1191
  series? spark(series,color) : null, h('div',{class:'l'},text), h('div',{class:'v'},n), h('div',{class:'d '+(tone||'')},sub||''));
1149
1192
  }
1150
1193
  function initials(name){ return (name||'').split(/[\s\-–—·]+/).filter(Boolean).slice(0,2).map(w=>w[0]).join('').toUpperCase()||'R'; }
1194
+ /* The run this one is compared with: the latest earlier run of a comparable size (a full run is not compared
1195
+ with a one-spec debug run, nor a debug run with the full suite); with a build label, a different build. */
1151
1196
  function prevRun(){
1152
1197
  const H=data.history||[]; if(H.length<2) return null;
1153
- const cur=H[H.length-1]; for(let i=H.length-2;i>=0;i--){ if(!cur.label||H[i].label!==cur.label) return H[i]; }
1154
- return H[H.length-2];
1198
+ const cur=H[H.length-1], n=cur.total||0;
1199
+ const comparable=e=> isSmallRun(cur) ? (e.total||0)>=n/2 && (e.total||0)<=n*2 : !isSmallRun(e);
1200
+ let fallback=null;
1201
+ for(let i=H.length-2;i>=0;i--){ if(!comparable(H[i])) continue; if(!cur.label||H[i].label!==cur.label) return H[i]; if(!fallback) fallback=H[i]; }
1202
+ return fallback;
1155
1203
  }
1156
1204
 
1157
1205
  /* ---------- run history per test ---------- */
@@ -1199,7 +1247,7 @@ function slowerView(){
1199
1247
  const rows=regressions().slice(0,6);
1200
1248
  if(!rows.length) return h('div',{class:'ok'},'No test got 2× slower than last run.');
1201
1249
  return h('ul',{class:'slow'}, rows.map(({t,prev,cur,ratio})=>h('li',{}, h('button',{onclick:()=>select(t.id)},
1202
- h('span',{}, h('span',{class:'t'},t.title), h('span',{class:'bar',style:'--w:'+Math.min(100,Math.round(prev/cur*100))+'%'}, h('i',{style:'background:var(--flaky)'}))),
1250
+ h('span',{}, h('span',{class:'t'},t.title, data.projects.length>1?h('small',{class:'proj-sfx'},' · '+t.project):null), h('span',{class:'bar',style:'--w:'+Math.min(100,Math.round(prev/cur*100))+'%'}, h('i',{style:'background:var(--flaky)'}))),
1203
1251
  h('span',{class:'d'}, h('b',{style:'color:var(--fail)'},'×'+(ratio>=10?Math.round(ratio):ratio.toFixed(1))), ' ', ms(prev)+' → '+ms(cur))))));
1204
1252
  }
1205
1253
  /* sparklines from the whole history (counts, no per-test data needed) */
@@ -1210,7 +1258,7 @@ function spark(series, color, w, h2){
1210
1258
  const pts=series.map((v,i)=>x(i)+','+y(v)).join(' ');
1211
1259
  return h('span',{class:'sp','aria-hidden':'true',html:'<svg viewBox="0 0 '+w+' '+h2+'" width="'+w+'" height="'+h2+'"><polyline points="'+pts+'" fill="none" stroke="'+color+'" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round" opacity=".9"/><circle cx="'+x(n-1)+'" cy="'+y(series[n-1])+'" r="2.2" fill="'+color+'"/></svg>'});
1212
1260
  }
1213
- function hseries(f){ return HIST.slice(-12).map(f); }
1261
+ function hseries(f){ return TREND.slice(-12).map(f); }
1214
1262
  /* owner rollup for the Failures view and the copied summary */
1215
1263
  function byOwner(){
1216
1264
  const m=new Map();
@@ -1348,13 +1396,28 @@ function donut(){
1348
1396
  const svg=h('div',{html:'<svg viewBox="0 0 132 132">'+arcs+'<text class="c" x="66" y="64" text-anchor="middle">'+rate+'%</text><text class="cl" x="66" y="80" text-anchor="middle">pass rate</text></svg>'}).firstChild;
1349
1397
  return h('div',{class:'donut'}, svg, h('div',{class:'legend'}, parts.map(([k,n])=>h('button',{onclick:()=>{state.status=k;refresh();showView('tests');}}, h('span',{class:'dot',style:'background:'+colorOf(k)}), h('span',{},label[k]), h('span',{class:'n'},n)))));
1350
1398
  }
1399
+ /* Cross-project signal. The same test (file, describe path, title) runs once per project — a browser, a
1400
+ device. Failing in every project it ran in points at the app or the test itself; failing in some projects
1401
+ only points at those browsers. Skipped runs do not count; a flaky pass counts as a pass. */
1402
+ var XP=null; // var: the views are built before this line runs
1403
+ function xpKey(t){ return t.file+'::'+t.path.join('/')+'::'+t.title; }
1404
+ function xproj(t){
1405
+ if(data.projects.length<2) return null;
1406
+ if(!XP){ XP=new Map(); for(const u of data.tests){ if(u.outcome==='skipped') continue; const g=XP.get(xpKey(u))||[]; g.push(u); XP.set(xpKey(u),g); } }
1407
+ const g=XP.get(xpKey(t))||[]; if(g.length<2) return null;
1408
+ const bad=g.filter(u=>isFail(u.outcome)); if(!bad.length) return null;
1409
+ if(bad.length===g.length) return {all:true, text:g.length===2?'fails on both projects':'fails on all '+g.length+' projects', tip:'The same failure in every project it ran in: look at the app or the test, not the browser'};
1410
+ const names=bad.map(u=>u.project), good=g.filter(u=>!isFail(u.outcome)).map(u=>u.project);
1411
+ return {all:false, text: names.length<=2? 'only on '+names.join(' and ') : 'on '+names.length+' of '+g.length+' projects', tip:'Passes on '+good.join(', ')+': specific to '+names.join(', ')};
1412
+ }
1413
+ function xpTag(xp,cls){ return h('span',{class:'xp '+(xp.all?'all':'some')+(cls?' '+cls:''),title:xp.tip},xp.text); }
1351
1414
  function attention(limit){
1352
1415
  const bad=data.tests.filter(t=>isFail(t.outcome)||t.outcome==='flaky').sort((a,b)=>rank(a)-rank(b)||(isFail(b.outcome)-isFail(a.outcome))||b.duration-a.duration);
1353
1416
  if(!bad.length) return h('div',{class:'ok'},'No failures. Ship it.');
1354
1417
  const groups=new Map(); for(const t of bad){ const k=t.file+'::'+t.path.join('/')+'::'+t.title; const g=groups.get(k)||{t,projects:[]}; g.projects.push(t.project); groups.set(k,g); }
1355
1418
  const all=[...groups.values()], rows=limit?all.slice(0,limit):all;
1356
1419
  const sub=(t,projects)=>{ const parts=[t.file.split('/').pop()];
1357
- if(data.projects.length>1) parts.push(projects.length>1? projects.length+' projects' : projects[0]);
1420
+ if(data.projects.length>1){ const xp=xproj(t); parts.push(xp? xpTag(xp) : projects.length>1? projects.length+' projects' : projects[0]); }
1358
1421
  const si=sinceInfo(t); if(si) parts.push(si.kind==='new'? h('b',{class:'new'},'new this run') : 'failing since '+runLabel(si.since));
1359
1422
  const le=t.results[t.results.length-1]&&t.results[t.results.length-1].errors[0]; if(le&&le.explain) parts.push(h('span',{class:'rsn',title:le.explain.summary},le.explain.label));
1360
1423
  else if(t.outcome==='flaky') parts.push('passed on retry '+t.results.length);
@@ -1438,7 +1501,7 @@ function clusterLine(c){
1438
1501
  // in place and "show fewer" folds it again. Each name opens that test.
1439
1502
  function clusterWho(byTitle, all){
1440
1503
  const entries=[...byTitle.entries()], names=all?entries:entries.slice(0,6), extra=entries.length-names.length;
1441
- const who=names.map(([title,ts])=>h('button',{onclick:()=>select(ts[0].id),title:ts.map(t=>t.project).join(', ')}, h('span',{class:'tri'},'›'), title, data.projects.length>1&&ts.length>1? h('small',{},' ×'+ts.length) : null));
1504
+ const who=names.map(([title,ts])=>h('button',{onclick:()=>select(ts[0].id),title:ts.map(t=>t.project).join(', ')}, h('span',{class:'tri'},'›'), title, data.projects.length>1&&ts.length>1? h('small',{},' ×'+ts.length) : null, (()=>{ const xp=xproj(ts[0]); return xp? h('small',{class:'xp '+(xp.all?'all':'some'),title:xp.tip},' · '+xp.text) : null; })()));
1442
1505
  const swap=(ev,toAll)=>{ const d=ev.currentTarget.closest('.who'); d.replaceChildren(); for(const n of clusterWho(byTitle,toAll)) d.append(n); };
1443
1506
  if(extra>0) who.push(h('button',{class:'ex',onclick:ev=>swap(ev,true),title:'Show all '+entries.length+' tests'},'+'+extra+' more'));
1444
1507
  else if(all&&entries.length>6) who.push(h('button',{class:'ex',onclick:ev=>swap(ev,false)},'show fewer'));
@@ -1452,7 +1515,7 @@ function clustersView(cl){
1452
1515
  }));
1453
1516
  }
1454
1517
  function trend(){
1455
- const H=data.history, W=760, HT=170, padL=34, padR=12, padT=12, padB=26, n=H.length;
1518
+ const H=TREND, W=760, HT=170, padL=34, padR=12, padT=12, padB=26, n=H.length;
1456
1519
  const x=i=>padL+(n===1?0:i/(n-1))*(W-padL-padR), y=v=>padT+(1-v/100)*(HT-padT-padB);
1457
1520
  const rate=e=>{ const ran=e.total-e.skipped; return ran?Math.round(e.passed/ran*100):0; };
1458
1521
  const failPct=e=>{ const ran=e.total-e.skipped; return ran?Math.round(e.failed/ran*100):0; };
@@ -1462,9 +1525,14 @@ function trend(){
1462
1525
  svg+='<path class="area" d="M'+x(0)+','+y(0)+' '+H.map((e,i)=>'L'+x(i)+','+y(rate(e))).join(' ')+' L'+x(n-1)+','+y(0)+' Z"/>';
1463
1526
  svg+='<polyline class="fail" points="'+H.map((e,i)=>x(i)+','+y(failPct(e))).join(' ')+'"/>';
1464
1527
  svg+='<polyline class="pass" points="'+H.map((e,i)=>x(i)+','+y(rate(e))).join(' ')+'"/>';
1465
- svg+=H.map((e,i)=>'<circle class="pt'+(i===n-1?' now':'')+'" cx="'+x(i)+'" cy="'+y(rate(e))+'" r="3.5"><title>'+new Date(e.time).toLocaleString()+(e.label?' · '+e.label:'')+' · '+rate(e)+'% pass · '+e.failed+' failed · '+ms(e.duration)+'</title></circle>').join('');
1466
- const step=Math.max(1,Math.ceil(n/8));
1467
- svg+=H.map((e,i)=>(i===n-1||(i%step===0&&n-1-i>=step))?'<text x="'+x(i)+'" y="'+(HT-6)+'" text-anchor="'+(i===n-1&&n>1?'end':'middle')+'">'+(e.label||new Date(e.time).toLocaleDateString(undefined,{month:'short',day:'numeric'}))+'</text>':'').join('');
1528
+ svg+=H.map((e,i)=>'<circle class="pt'+(i===n-1&&e===HIST[HIST.length-1]?' now':'')+'" cx="'+x(i)+'" cy="'+y(rate(e))+'" r="3.5"><title>'+new Date(e.time).toLocaleString()+(e.label?' · '+e.label:'')+' · '+rate(e)+'% pass · '+e.failed+' failed · '+ms(e.duration)+'</title></circle>').join('');
1529
+ // Several runs on one day get the time too; longer labels mean fewer of them, so they never overlap
1530
+ const day=e=>new Date(e.time).toLocaleDateString(undefined,{month:'short',day:'numeric'});
1531
+ const days=H.filter(e=>!e.label).map(day), twice=days.length!==new Set(days).size;
1532
+ const step=Math.max(1,Math.ceil(n/(twice?5:8)));
1533
+ const shown=H.map((e,i)=>i===n-1||(i%step===0&&n-1-i>=step));
1534
+ const axis=e=> e.label || (twice ? day(e)+' '+new Date(e.time).toLocaleTimeString(undefined,{hour:'numeric',minute:'2-digit'}) : day(e));
1535
+ svg+=H.map((e,i)=>shown[i]?'<text x="'+x(i)+'" y="'+(HT-6)+'" text-anchor="'+(i===n-1&&n>1?'end':i===0&&twice?'start':'middle')+'">'+escape(axis(e))+'</text>':'').join('');
1468
1536
  const colW=n>1?(x(1)-x(0)):(W-padL-padR);
1469
1537
  svg+='<line class="guide" x1="0" x2="0" y1="'+padT+'" y2="'+y(0)+'" style="display:none"/>';
1470
1538
  svg+=H.map((e,i)=>'<rect class="hit" data-i="'+i+'" x="'+(x(i)-colW/2)+'" y="0" width="'+colW+'" height="'+HT+'" fill="transparent"/>').join('');
@@ -1489,7 +1557,7 @@ function trend(){
1489
1557
  svgEl.addEventListener('mousemove',ev=>{ const r=ev.target.closest&&ev.target.closest('.hit'); if(!r){ tip.hidden=true; guide.style.display='none'; return; } show(+r.dataset.i,ev); });
1490
1558
  svgEl.addEventListener('mouseleave',()=>{ tip.hidden=true; guide.style.display='none'; });
1491
1559
  wrap.append(
1492
- h('div',{class:'trend-cap'}, h('span',{style:'color:var(--pass)'},'— pass rate'), h('span',{style:'color:var(--fail)'},'- - fail rate'), h('span',{style:'color:var(--accent)'},'▮ duration'), h('span',{style:'margin-left:auto'}, 'this run: '+rate(H[n-1])+'% · '+ms(H[n-1].duration))));
1560
+ h('div',{class:'trend-cap'}, h('span',{style:'color:var(--pass)'},'— pass rate'), h('span',{style:'color:var(--fail)'},'- - fail rate'), h('span',{style:'color:var(--accent)'},'▮ duration'), h('span',{style:'margin-left:auto'}, 'this run: '+rate(HIST[HIST.length-1])+'% · '+ms(HIST[HIST.length-1].duration)+(isSmallRun(HIST[HIST.length-1])?' · small run, not plotted':''))));
1493
1561
  return wrap;
1494
1562
  }
1495
1563
  function workers(){
@@ -1528,7 +1596,7 @@ function slowest(){
1528
1596
  const top=[...data.tests].filter(t=>t.outcome!=='skipped').sort((a,b)=>b.duration-a.duration).slice(0,5);
1529
1597
  const max=top[0]?top[0].duration:1;
1530
1598
  return h('ul',{class:'slow'}, top.map(t=>h('li',{}, h('button',{onclick:()=>select(t.id)},
1531
- h('span',{}, h('span',{class:'t'},t.title), h('span',{class:'bar',style:'--w:'+Math.max(4,Math.round(t.duration/max*100))+'%'}, h('i',{}))), h('span',{class:'d'},ms(t.duration))))));
1599
+ h('span',{}, h('span',{class:'t'},t.title, data.projects.length>1?h('small',{class:'proj-sfx'},' · '+t.project):null), h('span',{class:'bar',style:'--w:'+Math.max(4,Math.round(t.duration/max*100))+'%'}, h('i',{}))), h('span',{class:'d'},ms(t.duration))))));
1532
1600
  }
1533
1601
  function projects(){
1534
1602
  return h('div',{class:'proj'}, data.projects.map(p=>{
@@ -1632,7 +1700,7 @@ function renderDetail(t, d, retryIdx){
1632
1700
  h('button',{class:'btn',onclick:e=>copyText(location.href.split('#')[0]+'#t='+t.id,e.currentTarget,'Link copied')},'Copy link'),
1633
1701
  (()=>{ const r=t.results[t.results.length-1]; const e=r&&r.errors[0]; return e? [h('button',{class:'btn',onclick:ev=>copyText(t.title+'\n'+t.file+':'+t.line+'\n\n'+e.message,ev.currentTarget,'Error copied')},'Copy error'), h('button',{class:'btn primary',onclick:()=>openBugReport(t)},'Bug report')] : null; })(),
1634
1702
  editorLink(t))),
1635
- h('div',{class:'badges'}, h('span',{class:'badge '+t.outcome},label[t.outcome]), t.expectedFailure? h('span',{class:'badge xfail',title:'Marked test.fail(): failing is the expected result'},'Expected failure') : null, sinceBadge(t), dots(t,10), data.bdd?h('span',{class:'badge scenario'},'Scenario'):null, t.tags.map(g=>h('span',{class:'badge tag'},g)), data.projects.length>1?h('span',{class:'badge tag'},t.project):null, h('span',{class:'loc'}, t.file+':'+t.line+' · '+ms(t.duration)+(t.outcome==='timedOut'&&t.timeout?' · timeout '+ms(t.timeout):'')+(t.retries?' · retries '+t.retries:''))));
1703
+ h('div',{class:'badges'}, h('span',{class:'badge '+t.outcome},label[t.outcome]), t.expectedFailure? h('span',{class:'badge xfail',title:'Marked test.fail(): failing is the expected result'},'Expected failure') : null, sinceBadge(t), dots(t,10), data.bdd?h('span',{class:'badge scenario'},'Scenario'):null, t.tags.map(g=>h('span',{class:'badge tag'},g)), data.projects.length>1?h('span',{class:'badge tag'},t.project):null, (()=>{ const xp=isFail(t.outcome)&&xproj(t); return xp? xpTag(xp,'badge') : null; })(), h('span',{class:'loc'}, t.file+':'+t.line+' · '+ms(t.duration)+(t.outcome==='timedOut'&&t.timeout?' · timeout '+ms(t.timeout):'')+(t.retries?' · retries '+t.retries:''))));
1636
1704
  const metaKeys=Object.keys(t.meta);
1637
1705
  const linkFor=(k,v)=>{ if(t.links&&t.links[k]) return t.links[k]; const tpl=data.options.links[k]||data.options.links['*']; if(tpl) return tpl.replace('{id}',encodeURIComponent(v)); if(/^https?:\/\//.test(v)) return v; return null; };
1638
1706
  if(metaKeys.length) d.append(h('div',{class:'metas'}, metaKeys.map(k=>{ const v=t.meta[k], low=/^(P[3-4]|low|minor|trivial|normal|medium)$/i.test(v); const parts=(t.links&&t.links[k])||!data.options.links[k]&&!data.options.links['*']?[v]:v.split(/,\s+/); const nodes=[]; parts.forEach((part,i)=>{ const href=linkFor(k,part); if(i) nodes.push(', '); nodes.push(href? h('a',{href,target:'_blank',rel:'noopener'},part) : h('span',{class:'v'},part)); }); return h('span',{class:'meta '+k+(low?' low':'')}, h('span',{class:'k'},k), ...nodes); })));
@@ -1648,7 +1716,7 @@ function renderDetail(t, d, retryIdx){
1648
1716
  if(r.steps.length){ const stepTotal=Math.max(1, r.duration||0, r.steps.reduce((a,x)=>a+x.duration,0)); body.append(h('h4',{},data.bdd?'Scenario steps':'Steps', h('span',{class:'hint'},'bar = share of '+ms(stepTotal))), stepTree(r.steps, stepTotal)); }
1649
1717
  if(r.logs.length){ const t0=r.startTime; body.append(h('h4',{},'Log'), h('div',{class:'logs'}, r.logs.map(l=>h('div',{class:'ln'+(/\b(error|fail|exception)\b/i.test(l.msg)?' err':/\bwarn/i.test(l.msg)?' warn':'')}, h('span',{class:'ts'},'+'+ms(Math.max(0,l.t-t0))), h('span',{class:'lm'},l.msg))))); }
1650
1718
  for(const b of r.data){ body.append(h('h4',{},b.name), dataBlock(b)); }
1651
- if(r.api.length){ body.append(h('h4',{},r.api.length+' API call'+(r.api.length>1?'s':'')), ...r.api.map(apiPanel)); body.append(h('div',{class:'mask-note'},'Secrets and auth headers are masked as ****')); }
1719
+ if(r.api.length){ body.append(h('h4',{},r.api.length+' API call'+(r.api.length>1?'s':'')), ...r.api.map(c=>apiPanel(c,r))); body.append(h('div',{class:'mask-note'},'Secrets and auth headers are masked as ****')); }
1652
1720
  const imgs=r.attachments.filter(a=>a.src&&a.contentType.startsWith('image/'));
1653
1721
  const vids=r.attachments.filter(a=>a.src&&a.contentType.startsWith('video/'));
1654
1722
  const traces=r.attachments.filter(a=>a.src&&(a.name==='trace'||/\.zip$/.test(a.src)));
@@ -1693,10 +1761,10 @@ function dataBlock(b){
1693
1761
  if(b.kind==='kv') return h('dl',{class:'kv2'}, b.kv.map(([k,v])=>[h('dt',{},k),h('dd',{class:v==='****'?'mask':''},v)]));
1694
1762
  return h('pre',{class:'txt'},b.text);
1695
1763
  }
1696
- function apiPanel(c){
1697
- const st=c.status||0, cls=st>=500||st>=400?'bad':st>=300?'warn':'ok';
1764
+ function apiPanel(c,r){
1765
+ const st=c.status||0, cls=apiCls(c,r);
1698
1766
  const wrap=h('div',{class:'api collapsed'});
1699
- const head=h('button',{class:'api-head',onclick:()=>wrap.classList.toggle('collapsed')}, h('span',{class:'m '+c.method.toUpperCase()},c.method.toUpperCase()), h('span',{class:'u',title:c.url},c.url), st?h('span',{class:'sc '+cls},st):null, c.duration!=null?h('span',{class:'d'},ms(c.duration)):null);
1767
+ const head=h('button',{class:'api-head',onclick:()=>wrap.classList.toggle('collapsed')}, h('span',{class:'m '+c.method.toUpperCase()},c.method.toUpperCase()), h('span',{class:'u',title:c.url},c.url), st?h('span',{class:'sc '+cls,title:cls==='exp'?'The test passed: this is the response it expected':''},st):null, cls==='exp'?h('span',{class:'sc-exp'},'expected'):null, c.duration!=null?h('span',{class:'d'},ms(c.duration)):null);
1700
1768
  const pre=v=>v==null?null:h('pre',{}, typeof v==='string'?v:JSON.stringify(v,null,2));
1701
1769
  const col=(title,headers,bodyv)=>h('div',{class:'api-col'}, h('h5',{},title), headers&&Object.keys(headers).length? [h('h5',{},'Headers'), pre(headers)] : null, bodyv!=null? [h('h5',{},'Body'), pre(bodyv)] : h('div',{style:'font-size:12px;color:var(--ink-3)'},'no body'));
1702
1770
  const tools=h('div',{class:'api-tools'}, h('button',{class:'btn',onclick:e=>copyText(curlOf(c),e.currentTarget,'Copied')},'Copy as cURL'), h('button',{class:'btn',onclick:e=>copyText(c.url,e.currentTarget,'Copied')},'Copy URL'));