@piwitests/reporter 0.70.0 → 0.72.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.
@@ -1447,6 +1447,7 @@ function parseManifestJson(text) {
1447
1447
  method: r.method,
1448
1448
  pattern: r.pattern,
1449
1449
  handler: typeof r.handler === "string" ? r.handler : void 0,
1450
+ line: typeof r.handler === "string" && Number.isInteger(r.line) && r.line > 0 ? r.line : void 0,
1450
1451
  responses: Array.isArray(r.responses) ? r.responses.filter((c) => Number.isInteger(c)) : void 0
1451
1452
  })) : void 0;
1452
1453
  const pages = Array.isArray(obj.pages) ? obj.pages.filter((p) => !!p && typeof p === "object").filter((p) => typeof p.pattern === "string").map((p) => ({ pattern: p.pattern, name: typeof p.name === "string" ? p.name : void 0 })) : void 0;
package/dist/index.js CHANGED
@@ -3280,7 +3280,9 @@ var RUN_REF_ENV = "PIWI_RUN_REF";
3280
3280
  var TERMINAL_REF_PREFIX = "terminal-";
3281
3281
  var UNATTENDED_REF_SUFFIX = "-unattended";
3282
3282
  var RUN_HOLDS = ["failure"];
3283
- var RUN_FEATURES = ["view-lane", "give-up", "front", "layers", "trace"];
3283
+ var RUN_FEATURES = ["view-lane", "give-up", "front", "layers", "trace", "positions"];
3284
+ var POSITIONS_PER_SECOND = 4;
3285
+ var MAX_POSITION_TITLE = 300;
3284
3286
  var MAX_WAITING_TITLE = 500;
3285
3287
  var RUN_INTENTS = ["pick", "record", "assert", "assert-region"];
3286
3288
  var RUN_TAKES = [
@@ -3454,6 +3456,8 @@ function parseHubToRun(line) {
3454
3456
  const layers = readLaneLayers(value.layers);
3455
3457
  return layers ? { type: "layers", layers } : null;
3456
3458
  }
3459
+ case "positions":
3460
+ return typeof value.on === "boolean" ? { type: "positions", on: value.on } : null;
3457
3461
  case "share": {
3458
3462
  if (typeof value.on !== "boolean") return null;
3459
3463
  return isInt2(value.after, 1) ? { type: "share", on: value.on, after: value.after } : { type: "share", on: value.on };
@@ -8873,6 +8877,7 @@ function parseManifestJson(text2) {
8873
8877
  method: r.method,
8874
8878
  pattern: r.pattern,
8875
8879
  handler: typeof r.handler === "string" ? r.handler : void 0,
8880
+ line: typeof r.handler === "string" && Number.isInteger(r.line) && r.line > 0 ? r.line : void 0,
8876
8881
  responses: Array.isArray(r.responses) ? r.responses.filter((c) => Number.isInteger(c)) : void 0
8877
8882
  })) : void 0;
8878
8883
  const pages = Array.isArray(obj.pages) ? obj.pages.filter((p) => !!p && typeof p === "object").filter((p) => typeof p.pattern === "string").map((p) => ({ pattern: p.pattern, name: typeof p.name === "string" ? p.name : void 0 })) : void 0;
@@ -25581,6 +25586,11 @@ var pickingAt = false;
25581
25586
  var runName = "";
25582
25587
  var eventsOn = false;
25583
25588
  var testRunning = false;
25589
+ var runningTestId = null;
25590
+ var positionsOn = false;
25591
+ var positionToldAt = -Infinity;
25592
+ var pendingPosition = null;
25593
+ var positionTimer = null;
25584
25594
  var eventRate = new RateWindow(MAX_RUN_EVENT_RATE);
25585
25595
  var droppedEvents = 0;
25586
25596
  var agentTurn = Promise.resolve();
@@ -25623,6 +25633,9 @@ async function openRunChannel(worker, handlers, env = process.env) {
25623
25633
  shown = /* @__PURE__ */ new Set();
25624
25634
  runName = `piwi-${ref}-w${worker.workerIndex}`;
25625
25635
  eventsOn = false;
25636
+ positionsOn = false;
25637
+ positionToldAt = -Infinity;
25638
+ dropPendingPosition();
25626
25639
  layersAsked = /* @__PURE__ */ new Set();
25627
25640
  host = null;
25628
25641
  opening.unref();
@@ -25723,11 +25736,15 @@ function runChannelOpen() {
25723
25736
  function tellHub(message) {
25724
25737
  if (message.type === "test-begin") {
25725
25738
  testRunning = true;
25739
+ runningTestId = message.testId;
25740
+ dropPendingPosition();
25726
25741
  laneGeneration++;
25727
25742
  filmstrip2?.forget();
25728
25743
  }
25729
25744
  if (message.type === "test-end") {
25730
25745
  testRunning = false;
25746
+ runningTestId = null;
25747
+ dropPendingPosition();
25731
25748
  void unbind();
25732
25749
  }
25733
25750
  if (socket && !socket.destroyed) socket.write(`${JSON.stringify(message)}
@@ -25736,6 +25753,32 @@ function tellHub(message) {
25736
25753
  function tellActing(stop2, what) {
25737
25754
  if (held?.stop === stop2) tellHub({ type: "acting", stop: stop2, what });
25738
25755
  }
25756
+ function positionsWanted() {
25757
+ return positionsOn && testRunning && runningTestId !== null && runChannelOpen();
25758
+ }
25759
+ function tellPosition(title, place) {
25760
+ if (!positionsWanted()) return;
25761
+ pendingPosition = { title, place };
25762
+ if (positionTimer) return;
25763
+ const wait = positionToldAt + 1e3 / POSITIONS_PER_SECOND - performance.now();
25764
+ if (wait <= 0) return sendPendingPosition();
25765
+ positionTimer = setTimeout(sendPendingPosition, wait);
25766
+ positionTimer.unref?.();
25767
+ }
25768
+ function sendPendingPosition() {
25769
+ if (positionTimer) clearTimeout(positionTimer);
25770
+ positionTimer = null;
25771
+ const position = pendingPosition;
25772
+ pendingPosition = null;
25773
+ if (!position || !positionsWanted()) return;
25774
+ positionToldAt = performance.now();
25775
+ tellHub({ type: "position", testId: runningTestId, title: position.title, place: position.place });
25776
+ }
25777
+ function dropPendingPosition() {
25778
+ pendingPosition = null;
25779
+ if (positionTimer) clearTimeout(positionTimer);
25780
+ positionTimer = null;
25781
+ }
25739
25782
  function runEventsWanted() {
25740
25783
  return eventsOn && testRunning && runChannelOpen();
25741
25784
  }
@@ -26255,6 +26298,10 @@ function onMessage(message) {
26255
26298
  eventRate = new RateWindow(MAX_RUN_EVENT_RATE);
26256
26299
  droppedEvents = 0;
26257
26300
  return;
26301
+ case "positions":
26302
+ positionsOn = message.on;
26303
+ if (!message.on) dropPendingPosition();
26304
+ return;
26258
26305
  case "layers": {
26259
26306
  const before = layersAsked;
26260
26307
  layersAsked = new Set(message.layers);
@@ -26509,7 +26556,7 @@ function callPlace(frames, cwd = process.cwd(), windows = process.platform === "
26509
26556
  function callTitle(zone, channel) {
26510
26557
  const selector = typeof channel?.params?.selector === "string" ? ` ${channel.params.selector}` : "";
26511
26558
  const title = zone.title || `${zone.apiName || "call"}${selector}`;
26512
- return hideSecretsInText(hideTypedText(title)).slice(0, 300);
26559
+ return hideSecretsInText(hideTypedText(title)).slice(0, MAX_POSITION_TITLE);
26513
26560
  }
26514
26561
  function errorText(error) {
26515
26562
  const message = error instanceof Error ? error.message : String(error);
@@ -26523,6 +26570,10 @@ function watchCalls(playwright) {
26523
26570
  const titles = /* @__PURE__ */ new WeakMap();
26524
26571
  instrumentation.addListener({
26525
26572
  onApiCallBegin: (zone, channel) => {
26573
+ if (positionsWanted()) {
26574
+ const place = callPlace(zone.frames);
26575
+ if (place) tellPosition(callTitle(zone, channel), place);
26576
+ }
26526
26577
  if (!runEventsWanted()) return;
26527
26578
  begun.set(zone, Date.now());
26528
26579
  titles.set(zone, callTitle(zone, channel));
@@ -29749,7 +29800,8 @@ function testEnd(sink, testInfo) {
29749
29800
  type: "test-end",
29750
29801
  testId: testInfo.testId,
29751
29802
  status: testInfo.status ?? "passed",
29752
- pausedMs: sink.stops.reduce((sum, stop2) => sum + stop2.duration, 0)
29803
+ pausedMs: sink.stops.reduce((sum, stop2) => sum + stop2.duration, 0),
29804
+ expectedStatus: testInfo.expectedStatus
29753
29805
  };
29754
29806
  }
29755
29807
  var piwiFixtures = {
@@ -8479,7 +8479,9 @@ var RUN_CHANNEL_ENV = "PIWI_RUN_CHANNEL";
8479
8479
  var RUN_REF_ENV = "PIWI_RUN_REF";
8480
8480
  var TERMINAL_REF_PREFIX = "terminal-";
8481
8481
  var RUN_HOLDS = ["failure"];
8482
- var RUN_FEATURES = ["view-lane", "give-up", "front", "layers", "trace"];
8482
+ var RUN_FEATURES = ["view-lane", "give-up", "front", "layers", "trace", "positions"];
8483
+ var POSITIONS_PER_SECOND = 4;
8484
+ var MAX_POSITION_TITLE = 300;
8483
8485
  var MAX_WAITING_TITLE = 500;
8484
8486
  var RUN_INTENTS = ["pick", "record", "assert", "assert-region"];
8485
8487
  var RUN_TAKES = [
@@ -8644,6 +8646,8 @@ function parseHubToRun(line) {
8644
8646
  const layers = readLaneLayers(value.layers);
8645
8647
  return layers ? { type: "layers", layers } : null;
8646
8648
  }
8649
+ case "positions":
8650
+ return typeof value.on === "boolean" ? { type: "positions", on: value.on } : null;
8647
8651
  case "share": {
8648
8652
  if (typeof value.on !== "boolean") return null;
8649
8653
  return isInt2(value.after, 1) ? { type: "share", on: value.on, after: value.after } : { type: "share", on: value.on };
@@ -11570,6 +11574,11 @@ var pickingAt = false;
11570
11574
  var runName = "";
11571
11575
  var eventsOn = false;
11572
11576
  var testRunning = false;
11577
+ var runningTestId = null;
11578
+ var positionsOn = false;
11579
+ var positionToldAt = -Infinity;
11580
+ var pendingPosition = null;
11581
+ var positionTimer = null;
11573
11582
  var eventRate = new RateWindow(MAX_RUN_EVENT_RATE);
11574
11583
  var droppedEvents = 0;
11575
11584
  var agentTurn = Promise.resolve();
@@ -11612,6 +11621,9 @@ async function openRunChannel(worker, handlers, env = process.env) {
11612
11621
  shown = /* @__PURE__ */ new Set();
11613
11622
  runName = `piwi-${ref}-w${worker.workerIndex}`;
11614
11623
  eventsOn = false;
11624
+ positionsOn = false;
11625
+ positionToldAt = -Infinity;
11626
+ dropPendingPosition();
11615
11627
  layersAsked = /* @__PURE__ */ new Set();
11616
11628
  host = null;
11617
11629
  opening.unref();
@@ -11712,11 +11724,15 @@ function runChannelOpen() {
11712
11724
  function tellHub(message) {
11713
11725
  if (message.type === "test-begin") {
11714
11726
  testRunning = true;
11727
+ runningTestId = message.testId;
11728
+ dropPendingPosition();
11715
11729
  laneGeneration++;
11716
11730
  filmstrip2?.forget();
11717
11731
  }
11718
11732
  if (message.type === "test-end") {
11719
11733
  testRunning = false;
11734
+ runningTestId = null;
11735
+ dropPendingPosition();
11720
11736
  void unbind();
11721
11737
  }
11722
11738
  if (socket && !socket.destroyed) socket.write(`${JSON.stringify(message)}
@@ -11725,6 +11741,32 @@ function tellHub(message) {
11725
11741
  function tellActing(stop2, what) {
11726
11742
  if (held?.stop === stop2) tellHub({ type: "acting", stop: stop2, what });
11727
11743
  }
11744
+ function positionsWanted() {
11745
+ return positionsOn && testRunning && runningTestId !== null && runChannelOpen();
11746
+ }
11747
+ function tellPosition(title, place) {
11748
+ if (!positionsWanted()) return;
11749
+ pendingPosition = { title, place };
11750
+ if (positionTimer) return;
11751
+ const wait = positionToldAt + 1e3 / POSITIONS_PER_SECOND - performance.now();
11752
+ if (wait <= 0) return sendPendingPosition();
11753
+ positionTimer = setTimeout(sendPendingPosition, wait);
11754
+ positionTimer.unref?.();
11755
+ }
11756
+ function sendPendingPosition() {
11757
+ if (positionTimer) clearTimeout(positionTimer);
11758
+ positionTimer = null;
11759
+ const position = pendingPosition;
11760
+ pendingPosition = null;
11761
+ if (!position || !positionsWanted()) return;
11762
+ positionToldAt = performance.now();
11763
+ tellHub({ type: "position", testId: runningTestId, title: position.title, place: position.place });
11764
+ }
11765
+ function dropPendingPosition() {
11766
+ pendingPosition = null;
11767
+ if (positionTimer) clearTimeout(positionTimer);
11768
+ positionTimer = null;
11769
+ }
11728
11770
  function runEventsWanted() {
11729
11771
  return eventsOn && testRunning && runChannelOpen();
11730
11772
  }
@@ -12244,6 +12286,10 @@ function onMessage(message) {
12244
12286
  eventRate = new RateWindow(MAX_RUN_EVENT_RATE);
12245
12287
  droppedEvents = 0;
12246
12288
  return;
12289
+ case "positions":
12290
+ positionsOn = message.on;
12291
+ if (!message.on) dropPendingPosition();
12292
+ return;
12247
12293
  case "layers": {
12248
12294
  const before = layersAsked;
12249
12295
  layersAsked = new Set(message.layers);
@@ -12498,7 +12544,7 @@ function callPlace(frames, cwd = process.cwd(), windows = process.platform === "
12498
12544
  function callTitle(zone, channel) {
12499
12545
  const selector = typeof channel?.params?.selector === "string" ? ` ${channel.params.selector}` : "";
12500
12546
  const title = zone.title || `${zone.apiName || "call"}${selector}`;
12501
- return hideSecretsInText(hideTypedText(title)).slice(0, 300);
12547
+ return hideSecretsInText(hideTypedText(title)).slice(0, MAX_POSITION_TITLE);
12502
12548
  }
12503
12549
  function errorText(error) {
12504
12550
  const message = error instanceof Error ? error.message : String(error);
@@ -12512,6 +12558,10 @@ function watchCalls(playwright) {
12512
12558
  const titles = /* @__PURE__ */ new WeakMap();
12513
12559
  instrumentation.addListener({
12514
12560
  onApiCallBegin: (zone, channel) => {
12561
+ if (positionsWanted()) {
12562
+ const place = callPlace(zone.frames);
12563
+ if (place) tellPosition(callTitle(zone, channel), place);
12564
+ }
12515
12565
  if (!runEventsWanted()) return;
12516
12566
  begun.set(zone, Date.now());
12517
12567
  titles.set(zone, callTitle(zone, channel));
@@ -17692,7 +17742,8 @@ function testEnd(sink, testInfo) {
17692
17742
  type: "test-end",
17693
17743
  testId: testInfo.testId,
17694
17744
  status: testInfo.status ?? "passed",
17695
- pausedMs: sink.stops.reduce((sum, stop2) => sum + stop2.duration, 0)
17745
+ pausedMs: sink.stops.reduce((sum, stop2) => sum + stop2.duration, 0),
17746
+ expectedStatus: testInfo.expectedStatus
17696
17747
  };
17697
17748
  }
17698
17749
  var piwiFixtures = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piwitests/reporter",
3
- "version": "0.70.0",
3
+ "version": "0.72.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",