@piwitests/reporter 0.50.0 → 0.51.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.
package/dist/index.js CHANGED
@@ -4225,7 +4225,9 @@ function probeItemForTest(test) {
4225
4225
  return matchProbeItem(plan, { title: test.title, filePath, suitePath });
4226
4226
  }
4227
4227
  function classifyProbeHandled(signals) {
4228
- return signals.consoleErrors > 0 || signals.dialogs > 0 || signals.backendError ? "degraded" : "graceful";
4228
+ const blank = signals.blankPage === true;
4229
+ if ((signals.pageErrors ?? 0) > 0 || signals.backendError && blank) return "unhandled";
4230
+ return signals.consoleErrors > 0 || signals.dialogs > 0 || signals.backendError || blank ? "degraded" : "graceful";
4229
4231
  }
4230
4232
  function outcomeFromStatus(status, applied) {
4231
4233
  if (!applied) return "inconclusive";
@@ -12101,6 +12103,8 @@ function createSink() {
12101
12103
  stashedAriaJson: null,
12102
12104
  pageInventories: [],
12103
12105
  probeItem: null,
12106
+ probePageErrors: 0,
12107
+ probeBlankPage: false,
12104
12108
  probeInterception: null,
12105
12109
  flake: null,
12106
12110
  pickOffered: false,
@@ -12385,9 +12389,16 @@ async function stashPageState(sink, closing) {
12385
12389
  if (!belongsToClosing) return;
12386
12390
  await internalCall(page, () => readPageBeforeClose(sink, page));
12387
12391
  }
12392
+ async function readBlankPage(page) {
12393
+ await page.waitForLoadState("domcontentloaded", { timeout: 1e3 }).catch(() => {
12394
+ });
12395
+ const aria = await ariaSnapshotBestEffort(page.locator("body"), 1e3);
12396
+ return aria != null && aria.trim() === "";
12397
+ }
12388
12398
  async function readPageBeforeClose(sink, page) {
12389
12399
  const vitals = await readWebVitals(page);
12390
12400
  if (vitals) sink.stashedWebVitals = vitals;
12401
+ if (sink.probeItem?.level === "server") sink.probeBlankPage = await readBlankPage(page);
12391
12402
  if (process.env.PIWI_CAPTURE_PAGE_STATE !== "false") {
12392
12403
  const pageState = await readPageState(page);
12393
12404
  if (pageState) sink.stashedPageState = pageState;
@@ -12790,6 +12801,10 @@ function instrumentPage(page) {
12790
12801
  });
12791
12802
  });
12792
12803
  }
12804
+ page.on("pageerror", () => {
12805
+ const sink = currentSink;
12806
+ if (sink?.probeItem?.level === "server" && sink.probeInterception?.applied()) sink.probePageErrors++;
12807
+ });
12793
12808
  page.on("console", (msg) => {
12794
12809
  const sink = currentSink;
12795
12810
  if (!sink) return;
@@ -12846,6 +12861,9 @@ function instrumentPage(page) {
12846
12861
  };
12847
12862
  if (failure) entry.failure = failure;
12848
12863
  if (response) {
12864
+ if (timing.requestStart < 0 && typeof response.serverAddr === "function") {
12865
+ if (await response.serverAddr().catch(() => void 0) === null) entry.fulfilled = true;
12866
+ }
12849
12867
  const headers = response.headers();
12850
12868
  const contentType = headers["content-type"];
12851
12869
  if (contentType) entry.contentType = contentType.split(";")[0].trim();
@@ -13169,10 +13187,12 @@ var piwiFixtures = {
13169
13187
  if (sink.probeItem) {
13170
13188
  const applied = sink.probeInterception?.applied() ?? false;
13171
13189
  const level = sink.probeItem.level ?? "client";
13172
- const handled = level === "server" ? classifyProbeHandled({
13190
+ const handled = level === "server" && applied ? classifyProbeHandled({
13173
13191
  consoleErrors: sink.consoleEntries.filter((e) => e.type === "error").length,
13174
13192
  dialogs: sink.dialogs.length,
13175
- backendError: sink.probeInterception?.serverError() ?? false
13193
+ backendError: sink.probeInterception?.serverError() ?? false,
13194
+ pageErrors: sink.probePageErrors,
13195
+ blankPage: sink.probeBlankPage
13176
13196
  }) : "n/a";
13177
13197
  recordProbeOutcome({
13178
13198
  testCaseId: sink.probeItem.testCaseId,
@@ -2416,7 +2416,9 @@ function probeItemForTest(test) {
2416
2416
  return matchProbeItem(plan, { title: test.title, filePath, suitePath });
2417
2417
  }
2418
2418
  function classifyProbeHandled(signals) {
2419
- return signals.consoleErrors > 0 || signals.dialogs > 0 || signals.backendError ? "degraded" : "graceful";
2419
+ const blank = signals.blankPage === true;
2420
+ if ((signals.pageErrors ?? 0) > 0 || signals.backendError && blank) return "unhandled";
2421
+ return signals.consoleErrors > 0 || signals.dialogs > 0 || signals.backendError || blank ? "degraded" : "graceful";
2420
2422
  }
2421
2423
  function outcomeFromStatus(status, applied) {
2422
2424
  if (!applied) return "inconclusive";
@@ -5304,6 +5306,8 @@ function createSink() {
5304
5306
  stashedAriaJson: null,
5305
5307
  pageInventories: [],
5306
5308
  probeItem: null,
5309
+ probePageErrors: 0,
5310
+ probeBlankPage: false,
5307
5311
  probeInterception: null,
5308
5312
  flake: null,
5309
5313
  pickOffered: false,
@@ -5588,9 +5592,16 @@ async function stashPageState(sink, closing) {
5588
5592
  if (!belongsToClosing) return;
5589
5593
  await internalCall(page, () => readPageBeforeClose(sink, page));
5590
5594
  }
5595
+ async function readBlankPage(page) {
5596
+ await page.waitForLoadState("domcontentloaded", { timeout: 1e3 }).catch(() => {
5597
+ });
5598
+ const aria = await ariaSnapshotBestEffort(page.locator("body"), 1e3);
5599
+ return aria != null && aria.trim() === "";
5600
+ }
5591
5601
  async function readPageBeforeClose(sink, page) {
5592
5602
  const vitals = await readWebVitals(page);
5593
5603
  if (vitals) sink.stashedWebVitals = vitals;
5604
+ if (sink.probeItem?.level === "server") sink.probeBlankPage = await readBlankPage(page);
5594
5605
  if (process.env.PIWI_CAPTURE_PAGE_STATE !== "false") {
5595
5606
  const pageState = await readPageState(page);
5596
5607
  if (pageState) sink.stashedPageState = pageState;
@@ -5993,6 +6004,10 @@ function instrumentPage(page) {
5993
6004
  });
5994
6005
  });
5995
6006
  }
6007
+ page.on("pageerror", () => {
6008
+ const sink = currentSink;
6009
+ if (sink?.probeItem?.level === "server" && sink.probeInterception?.applied()) sink.probePageErrors++;
6010
+ });
5996
6011
  page.on("console", (msg) => {
5997
6012
  const sink = currentSink;
5998
6013
  if (!sink) return;
@@ -6049,6 +6064,9 @@ function instrumentPage(page) {
6049
6064
  };
6050
6065
  if (failure) entry.failure = failure;
6051
6066
  if (response) {
6067
+ if (timing.requestStart < 0 && typeof response.serverAddr === "function") {
6068
+ if (await response.serverAddr().catch(() => void 0) === null) entry.fulfilled = true;
6069
+ }
6052
6070
  const headers = response.headers();
6053
6071
  const contentType = headers["content-type"];
6054
6072
  if (contentType) entry.contentType = contentType.split(";")[0].trim();
@@ -6372,10 +6390,12 @@ var piwiFixtures = {
6372
6390
  if (sink.probeItem) {
6373
6391
  const applied = sink.probeInterception?.applied() ?? false;
6374
6392
  const level = sink.probeItem.level ?? "client";
6375
- const handled = level === "server" ? classifyProbeHandled({
6393
+ const handled = level === "server" && applied ? classifyProbeHandled({
6376
6394
  consoleErrors: sink.consoleEntries.filter((e) => e.type === "error").length,
6377
6395
  dialogs: sink.dialogs.length,
6378
- backendError: sink.probeInterception?.serverError() ?? false
6396
+ backendError: sink.probeInterception?.serverError() ?? false,
6397
+ pageErrors: sink.probePageErrors,
6398
+ blankPage: sink.probeBlankPage
6379
6399
  }) : "n/a";
6380
6400
  recordProbeOutcome({
6381
6401
  testCaseId: sink.probeItem.testCaseId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piwitests/reporter",
3
- "version": "0.50.0",
3
+ "version": "0.51.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",