@plune-ai/playwright 0.2.7 → 0.2.8

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/index.cjs CHANGED
@@ -252,6 +252,7 @@ var BATCH_DEFAULT = 100;
252
252
  var EXPECTED_MAX = 1e4;
253
253
  var KEY_MAX = 1024;
254
254
  var TITLE_MAX = 300;
255
+ var COUNTED = ["accepted", "duplicate", "conflict", "rejected"];
255
256
  function boundKey(key) {
256
257
  if (key.value.length <= KEY_MAX) return key;
257
258
  const digest = (0, import_crypto.createHash)("sha256").update(key.value).digest("hex").slice(0, 16);
@@ -362,11 +363,13 @@ async function startRun(passed, declared2) {
362
363
  "/v1/test-cases/resolve",
363
364
  { keys: part }
364
365
  );
365
- if (!out.ok) {
366
- log(`plune: could not look up test cases (${out.detail || out.kind}).`);
366
+ if (!out.ok || !Array.isArray(out.body?.results)) {
367
+ log(`plune: could not look up test cases (${out.ok ? "the answer had no results" : out.detail || out.kind}).`);
367
368
  return;
368
369
  }
369
- for (const row of out.body.results) resolved.set(row.key.value, row.testCaseId);
370
+ for (const row of out.body.results) {
371
+ if (typeof row?.key?.value === "string") resolved.set(row.key.value, row.testCaseId);
372
+ }
370
373
  }
371
374
  }
372
375
  if (!offline) {
@@ -403,12 +406,13 @@ async function startRun(passed, declared2) {
403
406
  title: defaultRunTitle(),
404
407
  ...described
405
408
  });
406
- if (start.ok) {
409
+ if (start.ok && typeof start.body?.run?.id === "string") {
407
410
  runId = start.body.run.id;
408
411
  joined = start.status === 200;
409
412
  warnIfDropped(described, start.body.run, log);
410
413
  } else {
411
- log(`plune: could not start the run (${start.detail || start.kind}). Results will be written to ${fallbackPath}.`);
414
+ const why = start.ok ? "the answer had no run" : start.detail || start.kind;
415
+ log(`plune: could not start the run (${why}). Results will be written to ${fallbackPath}.`);
412
416
  }
413
417
  }
414
418
  function matchFor(result) {
@@ -443,15 +447,15 @@ async function startRun(passed, declared2) {
443
447
  discovered: batch,
444
448
  runId
445
449
  });
446
- if (!out.ok) {
450
+ if (!out.ok || !Array.isArray(out.body?.results)) {
447
451
  stats.unoffered = batches.slice(index).reduce((n, rest) => n + rest.length, 0);
448
452
  log(
449
- `plune: could not offer ${stats.unoffered} unknown test(s) for review (${out.detail || out.kind}).`
453
+ `plune: could not offer ${stats.unoffered} unknown test(s) for review (${out.ok ? "the answer had no results" : out.detail || out.kind}).`
450
454
  );
451
455
  return;
452
456
  }
453
- stats.offered += out.body.results.filter((r) => r.outcome === "queued").length;
454
- stats.created += out.body.results.filter((r) => r.outcome === "created").length;
457
+ stats.offered += out.body.results.filter((r) => r?.outcome === "queued").length;
458
+ stats.created += out.body.results.filter((r) => r?.outcome === "created").length;
455
459
  }
456
460
  }
457
461
  async function flush() {
@@ -491,11 +495,9 @@ async function startRun(passed, declared2) {
491
495
  results: part
492
496
  });
493
497
  const counts = out.ok ? out.body?.counts : void 0;
494
- if (counts !== void 0) {
495
- stats.accepted += counts.accepted ?? 0;
496
- stats.duplicate += counts.duplicate ?? 0;
497
- stats.conflict += counts.conflict ?? 0;
498
- stats.rejected += counts.rejected ?? 0;
498
+ const told = COUNTED.filter((k) => typeof counts?.[k] === "number");
499
+ if (told.length > 0) {
500
+ for (const k of told) stats[k] += counts[k];
499
501
  progress();
500
502
  continue;
501
503
  }
@@ -559,7 +561,7 @@ async function startRun(passed, declared2) {
559
561
  ...reason !== void 0 ? { reason } : {}
560
562
  });
561
563
  if (!out.ok) log(`plune: could not close run ${runId} (${out.detail || out.kind}).`);
562
- else if (typeof out.body.detached === "number" && out.body.detached > 0) {
564
+ else if (typeof out.body?.detached === "number" && out.body.detached > 0) {
563
565
  log(`plune: ${out.body.detached} test case(s) marked detached \u2014 this full run no longer reports them.`);
564
566
  }
565
567
  }
@@ -626,13 +628,15 @@ var PATH_START = "(?<![\\w.~%/\\\\-])";
626
628
  var TEXT_LIMIT = 524288;
627
629
  var HEADLINE_LIMIT = 8 * 1024;
628
630
  var jsonBytes = (text) => Buffer.byteLength(JSON.stringify(text)) - 2;
629
- var ANY_HOME = /(?<=^|[\s'"`(=,[])(?:file:\/\/\/?)?(?:\/home\/|\/Users\/|[A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s'"`:*?<>|]+/g;
631
+ var ANY_HOME = /(?<=^|[\s'"`(=,[])(?:(?:file|webpack|webpack-internal):(?:\\*\/){2,3})?(?:\\*\/home\\*\/|\\*\/Users\\*\/|[A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s'"`:*?<>|]+/g;
630
632
  function pathIn(path3) {
631
633
  const parts = path3.split(/[\\/]+/);
632
634
  while (parts.length > 1 && parts.at(-1) === "") parts.pop();
633
635
  if (!parts.some((part) => part !== "" && !/^[A-Za-z]:$/.test(part))) return void 0;
634
- const escaped = parts.map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]+");
635
- return new RegExp(`(?:file:\\/\\/\\/?)?${escaped}`, /^[A-Za-z]:$/.test(parts[0]) ? "gi" : "g");
636
+ const joined = parts.map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]+");
637
+ const escaped = /^\/(?!\/)/.test(path3) ? joined.replace("[\\\\/]+", "\\\\*\\/") : joined;
638
+ const url = "(?:(?:file|webpack|webpack-internal):(?:\\\\*\\/){2,3})?";
639
+ return new RegExp(`${url}${escaped}`, /^[A-Za-z]:$/.test(parts[0]) ? "gi" : "g");
636
640
  }
637
641
  var fileNameOf = (name) => /^(?:file:\/\/|[\\/]|~[\\/]|[A-Za-z]:[\\/])/.test(name) ? name.split(/[\\/]/).pop() ?? "" : name;
638
642
  function cut(text) {
package/dist/index.js CHANGED
@@ -218,6 +218,7 @@ var BATCH_DEFAULT = 100;
218
218
  var EXPECTED_MAX = 1e4;
219
219
  var KEY_MAX = 1024;
220
220
  var TITLE_MAX = 300;
221
+ var COUNTED = ["accepted", "duplicate", "conflict", "rejected"];
221
222
  function boundKey(key) {
222
223
  if (key.value.length <= KEY_MAX) return key;
223
224
  const digest = createHash("sha256").update(key.value).digest("hex").slice(0, 16);
@@ -328,11 +329,13 @@ async function startRun(passed, declared2) {
328
329
  "/v1/test-cases/resolve",
329
330
  { keys: part }
330
331
  );
331
- if (!out.ok) {
332
- log(`plune: could not look up test cases (${out.detail || out.kind}).`);
332
+ if (!out.ok || !Array.isArray(out.body?.results)) {
333
+ log(`plune: could not look up test cases (${out.ok ? "the answer had no results" : out.detail || out.kind}).`);
333
334
  return;
334
335
  }
335
- for (const row of out.body.results) resolved.set(row.key.value, row.testCaseId);
336
+ for (const row of out.body.results) {
337
+ if (typeof row?.key?.value === "string") resolved.set(row.key.value, row.testCaseId);
338
+ }
336
339
  }
337
340
  }
338
341
  if (!offline) {
@@ -369,12 +372,13 @@ async function startRun(passed, declared2) {
369
372
  title: defaultRunTitle(),
370
373
  ...described
371
374
  });
372
- if (start.ok) {
375
+ if (start.ok && typeof start.body?.run?.id === "string") {
373
376
  runId = start.body.run.id;
374
377
  joined = start.status === 200;
375
378
  warnIfDropped(described, start.body.run, log);
376
379
  } else {
377
- log(`plune: could not start the run (${start.detail || start.kind}). Results will be written to ${fallbackPath}.`);
380
+ const why = start.ok ? "the answer had no run" : start.detail || start.kind;
381
+ log(`plune: could not start the run (${why}). Results will be written to ${fallbackPath}.`);
378
382
  }
379
383
  }
380
384
  function matchFor(result) {
@@ -409,15 +413,15 @@ async function startRun(passed, declared2) {
409
413
  discovered: batch,
410
414
  runId
411
415
  });
412
- if (!out.ok) {
416
+ if (!out.ok || !Array.isArray(out.body?.results)) {
413
417
  stats.unoffered = batches.slice(index).reduce((n, rest) => n + rest.length, 0);
414
418
  log(
415
- `plune: could not offer ${stats.unoffered} unknown test(s) for review (${out.detail || out.kind}).`
419
+ `plune: could not offer ${stats.unoffered} unknown test(s) for review (${out.ok ? "the answer had no results" : out.detail || out.kind}).`
416
420
  );
417
421
  return;
418
422
  }
419
- stats.offered += out.body.results.filter((r) => r.outcome === "queued").length;
420
- stats.created += out.body.results.filter((r) => r.outcome === "created").length;
423
+ stats.offered += out.body.results.filter((r) => r?.outcome === "queued").length;
424
+ stats.created += out.body.results.filter((r) => r?.outcome === "created").length;
421
425
  }
422
426
  }
423
427
  async function flush() {
@@ -457,11 +461,9 @@ async function startRun(passed, declared2) {
457
461
  results: part
458
462
  });
459
463
  const counts = out.ok ? out.body?.counts : void 0;
460
- if (counts !== void 0) {
461
- stats.accepted += counts.accepted ?? 0;
462
- stats.duplicate += counts.duplicate ?? 0;
463
- stats.conflict += counts.conflict ?? 0;
464
- stats.rejected += counts.rejected ?? 0;
464
+ const told = COUNTED.filter((k) => typeof counts?.[k] === "number");
465
+ if (told.length > 0) {
466
+ for (const k of told) stats[k] += counts[k];
465
467
  progress();
466
468
  continue;
467
469
  }
@@ -525,7 +527,7 @@ async function startRun(passed, declared2) {
525
527
  ...reason !== void 0 ? { reason } : {}
526
528
  });
527
529
  if (!out.ok) log(`plune: could not close run ${runId} (${out.detail || out.kind}).`);
528
- else if (typeof out.body.detached === "number" && out.body.detached > 0) {
530
+ else if (typeof out.body?.detached === "number" && out.body.detached > 0) {
529
531
  log(`plune: ${out.body.detached} test case(s) marked detached \u2014 this full run no longer reports them.`);
530
532
  }
531
533
  }
@@ -592,13 +594,15 @@ var PATH_START = "(?<![\\w.~%/\\\\-])";
592
594
  var TEXT_LIMIT = 524288;
593
595
  var HEADLINE_LIMIT = 8 * 1024;
594
596
  var jsonBytes = (text) => Buffer.byteLength(JSON.stringify(text)) - 2;
595
- var ANY_HOME = /(?<=^|[\s'"`(=,[])(?:file:\/\/\/?)?(?:\/home\/|\/Users\/|[A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s'"`:*?<>|]+/g;
597
+ var ANY_HOME = /(?<=^|[\s'"`(=,[])(?:(?:file|webpack|webpack-internal):(?:\\*\/){2,3})?(?:\\*\/home\\*\/|\\*\/Users\\*\/|[A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s'"`:*?<>|]+/g;
596
598
  function pathIn(path3) {
597
599
  const parts = path3.split(/[\\/]+/);
598
600
  while (parts.length > 1 && parts.at(-1) === "") parts.pop();
599
601
  if (!parts.some((part) => part !== "" && !/^[A-Za-z]:$/.test(part))) return void 0;
600
- const escaped = parts.map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]+");
601
- return new RegExp(`(?:file:\\/\\/\\/?)?${escaped}`, /^[A-Za-z]:$/.test(parts[0]) ? "gi" : "g");
602
+ const joined = parts.map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]+");
603
+ const escaped = /^\/(?!\/)/.test(path3) ? joined.replace("[\\\\/]+", "\\\\*\\/") : joined;
604
+ const url = "(?:(?:file|webpack|webpack-internal):(?:\\\\*\\/){2,3})?";
605
+ return new RegExp(`${url}${escaped}`, /^[A-Za-z]:$/.test(parts[0]) ? "gi" : "g");
602
606
  }
603
607
  var fileNameOf = (name) => /^(?:file:\/\/|[\\/]|~[\\/]|[A-Za-z]:[\\/])/.test(name) ? name.split(/[\\/]/).pop() ?? "" : name;
604
608
  function cut(text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plune-ai/playwright",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Report Playwright results to Plune — a reporter and, later, a test importer.",
5
5
  "keywords": [
6
6
  "playwright",
@@ -38,7 +38,7 @@
38
38
  "tsup": "^8.0.0",
39
39
  "typescript": "^5.4.0",
40
40
  "vitest": "^1.6.0",
41
- "@plune-ai/cli": "0.14.1"
41
+ "@plune-ai/cli": "0.14.2"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",