@piwitests/reporter 0.33.0 → 0.34.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.
Files changed (2) hide show
  1. package/dist/index.js +54 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -530,6 +530,40 @@ function toWireTestCase(tc) {
530
530
  blockedBy: rest.blockedBy ?? null
531
531
  };
532
532
  }
533
+ function browserProjectName(browser) {
534
+ if (browser && typeof browser === "object" && typeof browser.projectName === "string") {
535
+ return browser.projectName;
536
+ }
537
+ return "";
538
+ }
539
+ function computeDistinctRunCounts(testCases) {
540
+ const final = /* @__PURE__ */ new Map();
541
+ for (const tc of testCases) {
542
+ const key = `${tc.title}\0${tc.location}\0${browserProjectName(tc.browser)}`;
543
+ const retries = tc.retries ?? 0;
544
+ const prev = final.get(key);
545
+ if (!prev || retries >= prev.retries) final.set(key, { status: tc.status ?? "", retries });
546
+ }
547
+ const counts = {
548
+ totalTests: final.size,
549
+ passedTests: 0,
550
+ failedTests: 0,
551
+ timedOutTests: 0,
552
+ skippedTests: 0,
553
+ didNotRunTests: 0,
554
+ flakyTests: 0
555
+ };
556
+ for (const { status, retries } of final.values()) {
557
+ if (status === "passed") {
558
+ counts.passedTests++;
559
+ if (retries > 0) counts.flakyTests++;
560
+ } else if (status === "failed") counts.failedTests++;
561
+ else if (status === "timedOut" || status === "timedout") counts.timedOutTests++;
562
+ else if (status === "skipped") counts.skippedTests++;
563
+ else if (status === "didnotrun") counts.didNotRunTests++;
564
+ }
565
+ return counts;
566
+ }
533
567
  function serializeRun(payload, opts) {
534
568
  const body = {
535
569
  projectName: payload.projectName,
@@ -1674,7 +1708,7 @@ var StreamManager = class {
1674
1708
  return this.pendingEvents.lostResults || this.pendingBeginEvents.lostResults;
1675
1709
  }
1676
1710
  /** Begin the streaming session after `onBegin` fires. Non-blocking — the actual handshake runs asynchronously. */
1677
- start(startTime, metadata, instanceId, playwrightVersion, reporterVersion, shardInfo, isFullRun, filterDetails) {
1711
+ start(startTime, metadata, instanceId, playwrightVersion, reporterVersion, shardInfo, isFullRun, filterDetails, plannedTotal) {
1678
1712
  this._startPromise = this._doStart(
1679
1713
  startTime,
1680
1714
  metadata,
@@ -1683,10 +1717,11 @@ var StreamManager = class {
1683
1717
  reporterVersion,
1684
1718
  shardInfo,
1685
1719
  isFullRun,
1686
- filterDetails
1720
+ filterDetails,
1721
+ plannedTotal
1687
1722
  );
1688
1723
  }
1689
- async _doStart(startTime, metadata, instanceId, playwrightVersion, reporterVersion, shardInfo, isFullRun, filterDetails) {
1724
+ async _doStart(startTime, metadata, instanceId, playwrightVersion, reporterVersion, shardInfo, isFullRun, filterDetails, plannedTotal) {
1690
1725
  const setupInfo = readSetupInfo(this.options.projectName);
1691
1726
  try {
1692
1727
  this._auth = await this.httpClient.resolveAuth(this.options);
@@ -1700,7 +1735,7 @@ var StreamManager = class {
1700
1735
  `/api/test-runs/${setupInfo.runId}/begin`,
1701
1736
  {
1702
1737
  setupToken: setupInfo.setupToken,
1703
- totalTests: 0,
1738
+ totalTests: plannedTotal ?? 0,
1704
1739
  metadata,
1705
1740
  playwrightVersion,
1706
1741
  reporterVersion,
@@ -1729,7 +1764,8 @@ var StreamManager = class {
1729
1764
  shardIndex,
1730
1765
  shardTotal,
1731
1766
  isFullRun,
1732
- filterDetails
1767
+ filterDetails,
1768
+ totalTests: plannedTotal ?? 0
1733
1769
  },
1734
1770
  this._auth
1735
1771
  );
@@ -1750,7 +1786,8 @@ var StreamManager = class {
1750
1786
  shardIndex,
1751
1787
  shardTotal,
1752
1788
  isFullRun,
1753
- filterDetails
1789
+ filterDetails,
1790
+ totalTests: plannedTotal ?? 0
1754
1791
  },
1755
1792
  this._auth
1756
1793
  );
@@ -2998,6 +3035,13 @@ var RunSubmitter = class {
2998
3035
  async submit(run, result) {
2999
3036
  const endTime = (/* @__PURE__ */ new Date()).toISOString();
3000
3037
  const duration = new Date(endTime).getTime() - new Date(run.startTime).getTime();
3038
+ const counts = computeDistinctRunCounts(run.testCases);
3039
+ run.totalTests = counts.totalTests;
3040
+ run.passedTests = counts.passedTests;
3041
+ run.failedTests = counts.failedTests;
3042
+ run.timedOutTests = counts.timedOutTests;
3043
+ run.skippedTests = counts.skippedTests;
3044
+ run.didNotRunTests = counts.didNotRunTests;
3001
3045
  const overallStatus = resolveOverallStatus(result, {
3002
3046
  failedTests: run.failedTests,
3003
3047
  timedOutTests: run.timedOutTests,
@@ -4151,7 +4195,10 @@ var PiwiDashboardReporter = class _PiwiDashboardReporter {
4151
4195
  this.reporterVersion,
4152
4196
  this.shardInfo,
4153
4197
  this.isFullRun,
4154
- this.filterDetails
4198
+ this.filterDetails,
4199
+ // The planned suite size for this shard, known before any test runs, so
4200
+ // the dashboard shows the real total from the first render.
4201
+ this.plannedTests.length
4155
4202
  );
4156
4203
  }
4157
4204
  /** Playwright reporter hook: called when an individual test begins */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piwitests/reporter",
3
- "version": "0.33.0",
3
+ "version": "0.34.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/platform",
6
6
  "homepage": "https://piwitests.dev",