@piwitests/reporter 0.69.0 → 0.70.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
@@ -100,6 +100,119 @@ function isInsidePath(file) {
100
100
  return file.split(/[\\/]/).every((part) => part !== "..");
101
101
  }
102
102
 
103
+ // ../core/src/editor-discovery.ts
104
+ var EDITORS_DIR_ENV = "PIWI_EDITORS_DIR";
105
+ var EDITORS_DIR_PARTS = [".piwi", "editors"];
106
+ var NAME = /^([1-9]\d{0,9})\.json$/;
107
+ var TOKEN = /^[A-Za-z0-9_-]{16,256}$/;
108
+ var HUB_URL = /^ws:\/\/127\.0\.0\.1:\d{1,5}\/[\w/-]{0,64}$/;
109
+ function pidOfDiscoveryName(name) {
110
+ const m = NAME.exec(name);
111
+ return m ? Number(m[1]) : null;
112
+ }
113
+ function isObject(value) {
114
+ return typeof value === "object" && value !== null && !Array.isArray(value);
115
+ }
116
+ function text(value, max) {
117
+ return typeof value === "string" && value.length > 0 && value.length <= max && !value.includes("\0") ? value : null;
118
+ }
119
+ function readHub(value) {
120
+ if (!isObject(value)) return null;
121
+ const { url, token } = value;
122
+ return typeof url === "string" && HUB_URL.test(url) && typeof token === "string" && TOKEN.test(token) ? { url, token } : null;
123
+ }
124
+ function readChannel(value) {
125
+ if (!isObject(value)) return null;
126
+ const path44 = text(value.path, 4096);
127
+ return path44 && typeof value.token === "string" && TOKEN.test(value.token) ? { path: path44, token: value.token } : null;
128
+ }
129
+ function readAgents(value) {
130
+ if (!isObject(value) || typeof value.url !== "string" || typeof value.token !== "string") return {};
131
+ if (!/^http:\/\/127\.0\.0\.1:\d{1,5}\/mcp$/.test(value.url) || !/^[A-Za-z0-9_-]{32,256}$/.test(value.token))
132
+ return {};
133
+ return { agents: { url: value.url, token: value.token } };
134
+ }
135
+ function readSend(value) {
136
+ if (!isObject(value) || typeof value.url !== "string" || typeof value.token !== "string") return {};
137
+ const send2 = parsePairing(formatPairing({ url: value.url, token: value.token }));
138
+ return send2 ? { send: send2 } : {};
139
+ }
140
+ function parseEditorDiscovery(content) {
141
+ let value;
142
+ try {
143
+ value = JSON.parse(content);
144
+ } catch {
145
+ return null;
146
+ }
147
+ if (!isObject(value)) return null;
148
+ const { pid } = value;
149
+ if (typeof pid !== "number" || !Number.isInteger(pid) || pid < 1) return null;
150
+ const roots = Array.isArray(value.roots) ? value.roots.slice(0, 64).map((root) => text(root, 4096)).filter((root) => root !== null) : [];
151
+ return {
152
+ pid,
153
+ host: text(value.host, 255) ?? "",
154
+ version: text(value.version, 64) ?? "",
155
+ client: text(value.client, 200),
156
+ startedAt: text(value.startedAt, 64) ?? "",
157
+ roots,
158
+ hub: readHub(value.hub),
159
+ runChannel: readChannel(value.runChannel),
160
+ recorderBundle: text(value.recorderBundle, 4096),
161
+ ...value.unattended === true ? { unattended: true } : {},
162
+ ...value.checkout === true ? { checkout: true } : {},
163
+ ...readSend(value.send),
164
+ ...readAgents(value.agents)
165
+ };
166
+ }
167
+ function readLiveEditors(folder) {
168
+ const found = [];
169
+ for (const name of folder.names()) {
170
+ const pid = pidOfDiscoveryName(name);
171
+ if (pid === null || !folder.owned(name)) continue;
172
+ const content = folder.read(name);
173
+ const discovery = content === null ? null : parseEditorDiscovery(content);
174
+ if (discovery?.pid !== pid || discovery.host.toLowerCase() !== folder.host.toLowerCase()) continue;
175
+ if (folder.alive(pid)) found.push(discovery);
176
+ else folder.remove(name);
177
+ }
178
+ return found.sort((a, b) => a.startedAt.localeCompare(b.startedAt) || a.pid - b.pid);
179
+ }
180
+ var CLOCK_SLACK_MS = 6e4;
181
+ function sinceBoot(time, now, uptimeMs) {
182
+ return time >= now - uptimeMs - CLOCK_SLACK_MS;
183
+ }
184
+ function writtenSinceBoot(editor, now, uptimeMs) {
185
+ const written = Date.parse(editor.startedAt);
186
+ return !Number.isFinite(written) || sinceBoot(written, now, uptimeMs);
187
+ }
188
+ function comparable(folder, win324) {
189
+ const slashed = win324 ? folder.replace(/\\/g, "/").toLowerCase() : folder;
190
+ return slashed.length > 1 ? slashed.replace(/\/+$/, "") : slashed;
191
+ }
192
+ function holdsFolder(root, dir) {
193
+ return dir === root || dir.startsWith(root.endsWith("/") ? root : `${root}/`);
194
+ }
195
+ function editorForRun(editors, dirs, real, win324) {
196
+ const runDirs = dirs.flatMap((dir) => {
197
+ const found = real(dir);
198
+ return found ? [comparable(found, win324)] : [];
199
+ });
200
+ let best = null;
201
+ for (const editor of editors) {
202
+ if (!editor.runChannel) continue;
203
+ for (const root of editor.roots) {
204
+ const found = real(root);
205
+ if (!found) continue;
206
+ const folder = comparable(found, win324);
207
+ if (!runDirs.some((dir) => holdsFolder(folder, dir))) continue;
208
+ const depth = folder.length;
209
+ const later2 = !!best && depth === best.depth && editor.startedAt.localeCompare(best.editor.startedAt) > 0;
210
+ if (!best || depth > best.depth || later2) best = { editor, depth };
211
+ }
212
+ }
213
+ return best?.editor ?? null;
214
+ }
215
+
103
216
  // ../core/src/ide-recorder.ts
104
217
  var IDE_RECORDER_BINDING = "__piwiRecorder";
105
218
  var IDE_DISPATCH_GLOBAL = "__piwiIdeDispatch";
@@ -116,7 +229,7 @@ function parseRecordChannel(value) {
116
229
  const path44 = text2.slice(0, hash);
117
230
  return /^[A-Za-z0-9_-]{16,}$/.test(token) && !path44.includes("\0") ? { path: path44, token } : null;
118
231
  }
119
- function isObject(value) {
232
+ function isObject2(value) {
120
233
  return typeof value === "object" && value !== null && !Array.isArray(value);
121
234
  }
122
235
  function parseHandoffToTest(line) {
@@ -126,7 +239,7 @@ function parseHandoffToTest(line) {
126
239
  } catch {
127
240
  return null;
128
241
  }
129
- if (!isObject(value)) return null;
242
+ if (!isObject2(value)) return null;
130
243
  switch (value.type) {
131
244
  case "refused":
132
245
  return typeof value.message === "string" ? { type: "refused", message: value.message } : null;
@@ -178,9 +291,8 @@ function ownProcessAlive(pid) {
178
291
  return false;
179
292
  }
180
293
  }
181
- var CLOCK_SLACK_MS = 6e4;
182
- function sinceBoot(time, now = Date.now()) {
183
- return time >= now - os.uptime() * 1e3 - CLOCK_SLACK_MS;
294
+ function sinceBoot2(time, now = Date.now()) {
295
+ return sinceBoot(time, now, os.uptime() * 1e3);
184
296
  }
185
297
  function readDesktopConfig(filePath3) {
186
298
  const file = readDesktopFile(filePath3);
@@ -196,7 +308,7 @@ function readDesktopHub(filePath3) {
196
308
  const parsed2 = JSON.parse(fs.readFileSync(filePath3, "utf8"));
197
309
  const file = desktopFields(parsed2);
198
310
  if (!file || file.pid === null || !ownProcessAlive(file.pid)) return null;
199
- if (typeof parsed2.hubSince !== "number" || !sinceBoot(parsed2.hubSince)) return null;
311
+ if (typeof parsed2.hubSince !== "number" || !sinceBoot2(parsed2.hubSince)) return null;
200
312
  const channel = parsed2?.runChannel;
201
313
  const runChannel = typeof channel?.path === "string" && typeof channel?.token === "string" ? parseRecordChannel(`${channel.path}#${channel.token}`) : null;
202
314
  if (!runChannel) return null;
@@ -865,110 +977,6 @@ var fs4 = __toESM(require("fs"));
865
977
  var os3 = __toESM(require("os"));
866
978
  var path4 = __toESM(require("path"));
867
979
 
868
- // ../core/src/editor-discovery.ts
869
- var EDITORS_DIR_ENV = "PIWI_EDITORS_DIR";
870
- var EDITORS_DIR_PARTS = [".piwi", "editors"];
871
- var NAME = /^([1-9]\d{0,9})\.json$/;
872
- var TOKEN = /^[A-Za-z0-9_-]{16,256}$/;
873
- var HUB_URL = /^ws:\/\/127\.0\.0\.1:\d{1,5}\/[\w/-]{0,64}$/;
874
- function pidOfDiscoveryName(name) {
875
- const m = NAME.exec(name);
876
- return m ? Number(m[1]) : null;
877
- }
878
- function isObject2(value) {
879
- return typeof value === "object" && value !== null && !Array.isArray(value);
880
- }
881
- function text(value, max) {
882
- return typeof value === "string" && value.length > 0 && value.length <= max && !value.includes("\0") ? value : null;
883
- }
884
- function readHub(value) {
885
- if (!isObject2(value)) return null;
886
- const { url, token } = value;
887
- return typeof url === "string" && HUB_URL.test(url) && typeof token === "string" && TOKEN.test(token) ? { url, token } : null;
888
- }
889
- function readChannel(value) {
890
- if (!isObject2(value)) return null;
891
- const path44 = text(value.path, 4096);
892
- return path44 && typeof value.token === "string" && TOKEN.test(value.token) ? { path: path44, token: value.token } : null;
893
- }
894
- function readAgents(value) {
895
- if (!isObject2(value) || typeof value.url !== "string" || typeof value.token !== "string") return {};
896
- if (!/^http:\/\/127\.0\.0\.1:\d{1,5}\/mcp$/.test(value.url) || !/^[A-Za-z0-9_-]{32,256}$/.test(value.token))
897
- return {};
898
- return { agents: { url: value.url, token: value.token } };
899
- }
900
- function readSend(value) {
901
- if (!isObject2(value) || typeof value.url !== "string" || typeof value.token !== "string") return {};
902
- const send2 = parsePairing(formatPairing({ url: value.url, token: value.token }));
903
- return send2 ? { send: send2 } : {};
904
- }
905
- function parseEditorDiscovery(content) {
906
- let value;
907
- try {
908
- value = JSON.parse(content);
909
- } catch {
910
- return null;
911
- }
912
- if (!isObject2(value)) return null;
913
- const { pid } = value;
914
- if (typeof pid !== "number" || !Number.isInteger(pid) || pid < 1) return null;
915
- const roots = Array.isArray(value.roots) ? value.roots.slice(0, 64).map((root) => text(root, 4096)).filter((root) => root !== null) : [];
916
- return {
917
- pid,
918
- host: text(value.host, 255) ?? "",
919
- version: text(value.version, 64) ?? "",
920
- client: text(value.client, 200),
921
- startedAt: text(value.startedAt, 64) ?? "",
922
- roots,
923
- hub: readHub(value.hub),
924
- runChannel: readChannel(value.runChannel),
925
- recorderBundle: text(value.recorderBundle, 4096),
926
- ...value.unattended === true ? { unattended: true } : {},
927
- ...readSend(value.send),
928
- ...readAgents(value.agents)
929
- };
930
- }
931
- function readLiveEditors(folder) {
932
- const found = [];
933
- for (const name of folder.names()) {
934
- const pid = pidOfDiscoveryName(name);
935
- if (pid === null || !folder.owned(name)) continue;
936
- const content = folder.read(name);
937
- const discovery = content === null ? null : parseEditorDiscovery(content);
938
- if (discovery?.pid !== pid || discovery.host.toLowerCase() !== folder.host.toLowerCase()) continue;
939
- if (folder.alive(pid)) found.push(discovery);
940
- else folder.remove(name);
941
- }
942
- return found.sort((a, b) => a.startedAt.localeCompare(b.startedAt) || a.pid - b.pid);
943
- }
944
- function comparable(folder, win324) {
945
- const slashed = win324 ? folder.replace(/\\/g, "/").toLowerCase() : folder;
946
- return slashed.length > 1 ? slashed.replace(/\/+$/, "") : slashed;
947
- }
948
- function holdsFolder(root, dir) {
949
- return dir === root || dir.startsWith(root.endsWith("/") ? root : `${root}/`);
950
- }
951
- function editorForRun(editors, dirs, real, win324) {
952
- const runDirs = dirs.flatMap((dir) => {
953
- const found = real(dir);
954
- return found ? [comparable(found, win324)] : [];
955
- });
956
- let best = null;
957
- for (const editor of editors) {
958
- if (!editor.runChannel) continue;
959
- for (const root of editor.roots) {
960
- const found = real(root);
961
- if (!found) continue;
962
- const folder = comparable(found, win324);
963
- if (!runDirs.some((dir) => holdsFolder(folder, dir))) continue;
964
- const depth = folder.length;
965
- const later2 = !!best && depth === best.depth && editor.startedAt.localeCompare(best.editor.startedAt) > 0;
966
- if (!best || depth > best.depth || later2) best = { editor, depth };
967
- }
968
- }
969
- return best?.editor ?? null;
970
- }
971
-
972
980
  // ../core/src/live-layer-bounds.ts
973
981
  var LANE_LAYERS = ["calls", "events", "text", "filmstrip"];
974
982
  var MAX_LANE_TEXT = 96 * 1024;
@@ -1462,6 +1470,23 @@ function isSecretValue(value) {
1462
1470
  return /^[A-Za-z0-9+/_-]{40,}={0,2}$/.test(text2) && looksRandom(text2);
1463
1471
  }
1464
1472
  var URL_IN_TEXT = /\b[a-z][a-z0-9+.-]{0,31}:\/\/[^\s"'<>`]+/gi;
1473
+ function urlEndInText(url) {
1474
+ const counts = { "(": 0, ")": 0, "[": 0, "]": 0 };
1475
+ for (const c of url) if (c in counts) counts[c]++;
1476
+ let end = url.length;
1477
+ while (end > 0) {
1478
+ const last = url[end - 1];
1479
+ if (".,;:!?".includes(last)) {
1480
+ end--;
1481
+ continue;
1482
+ }
1483
+ const open4 = last === ")" ? "(" : last === "]" ? "[" : "";
1484
+ if (!open4 || counts[open4] >= counts[last]) break;
1485
+ counts[last]--;
1486
+ end--;
1487
+ }
1488
+ return end;
1489
+ }
1465
1490
  var URL_PARTS = /^(?:([a-z][a-z0-9+.-]*:)?\/\/([^/?#]*))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?$/i;
1466
1491
  function decodeSafe(text2) {
1467
1492
  try {
@@ -1578,8 +1603,9 @@ function hideSecretsInText(text2, count = { n: 0 }) {
1578
1603
  let out = "";
1579
1604
  let last = 0;
1580
1605
  for (const url of text2.matchAll(URL_IN_TEXT)) {
1581
- out += hideInText(text2.slice(last, url.index), count) + hideSecretsInUrl(url[0], count);
1582
- last = url.index + url[0].length;
1606
+ const end = urlEndInText(url[0]);
1607
+ out += hideInText(text2.slice(last, url.index), count) + hideSecretsInUrl(url[0].slice(0, end), count);
1608
+ last = url.index + end;
1583
1609
  }
1584
1610
  return out + hideInText(text2.slice(last), count);
1585
1611
  }
@@ -3274,7 +3300,7 @@ var RUN_TAKES = [
3274
3300
  ];
3275
3301
  var RUN_INTENT_NAMES = {
3276
3302
  pick: "Pick a locator",
3277
- record: "Record here",
3303
+ record: "Record",
3278
3304
  assert: "Assert",
3279
3305
  "assert-region": "Assert a region"
3280
3306
  };
@@ -3598,8 +3624,7 @@ function privateFolder(dir) {
3598
3624
  }
3599
3625
  }
3600
3626
  function stillServing(editor, now = Date.now()) {
3601
- const written = Date.parse(editor.startedAt);
3602
- if (Number.isFinite(written) && !sinceBoot(written, now)) return false;
3627
+ if (!writtenSinceBoot(editor, now, os3.uptime() * 1e3)) return false;
3603
3628
  if (!editor.runChannel || process.platform === "win32") return true;
3604
3629
  return privateFolder(path4.dirname(editor.runChannel.path)) && ownSocket(editor.runChannel.path);
3605
3630
  }
@@ -11168,14 +11193,16 @@ var RunSubmitter = class {
11168
11193
  * @param streamManager Streaming session (may be `null` when streaming is disabled).
11169
11194
  * @param logger Prefixed logger.
11170
11195
  * @param failureLinks Failed tests collected during the run, for the per-failure links.
11196
+ * @param retryDelaysMs The waits before each repeat of a request whose answer may have been lost.
11171
11197
  */
11172
- constructor(httpClient, uploader, recovery, streamManager, logger2 = new Logger(), failureLinks = null) {
11198
+ constructor(httpClient, uploader, recovery, streamManager, logger2 = new Logger(), failureLinks = null, retryDelaysMs = RETRY_DELAYS_MS) {
11173
11199
  this.httpClient = httpClient;
11174
11200
  this.uploader = uploader;
11175
11201
  this.recovery = recovery;
11176
11202
  this.streamManager = streamManager;
11177
11203
  this.logger = logger2;
11178
11204
  this.failureLinks = failureLinks;
11205
+ this.retryDelaysMs = retryDelaysMs;
11179
11206
  /** The key every batch delivery of this run carries, so the dashboard stores the run once. */
11180
11207
  this.deliveryKey = (0, import_node_crypto3.randomUUID)();
11181
11208
  /** The run's `submitTimeout` budget, and when it runs out (ms since the epoch); null without one. */
@@ -11418,7 +11445,7 @@ var RunSubmitter = class {
11418
11445
  });
11419
11446
  }
11420
11447
  /**
11421
- * Make `request`, and make it again after each of `RETRY_DELAYS_MS` while its answer may have been lost
11448
+ * Make `request`, and make it again after each of `retryDelaysMs` while its answer may have been lost
11422
11449
  * (`answerMayBeLost`), the waits ending with the budget. `request` gets the number of the try, from 0. Throws the
11423
11450
  * last failure.
11424
11451
  */
@@ -11427,7 +11454,7 @@ var RunSubmitter = class {
11427
11454
  try {
11428
11455
  return await request3(attempt3);
11429
11456
  } catch (error) {
11430
- const delay = RETRY_DELAYS_MS[attempt3];
11457
+ const delay = this.retryDelaysMs[attempt3];
11431
11458
  if (delay === void 0 || this.httpClient.closed || !answerMayBeLost(error)) throw error;
11432
11459
  this.logger.warn(`${what} failed (${errorMessage(error)}), perhaps after the dashboard took it: asking again.`);
11433
11460
  const wait = this.budget ? Math.min(delay, Math.max(this.budget.end - Date.now(), 0)) : delay;
@@ -13831,6 +13858,10 @@ function userFixturesOf(steps) {
13831
13858
  walk(steps);
13832
13859
  return [...new Set(out)];
13833
13860
  }
13861
+ function fixturesTornDownOf(steps) {
13862
+ const after = steps.find((step) => step.category === "hook" && step.title === "After Hooks" && !step.location);
13863
+ return (after?.steps ?? []).filter((step) => step.category === "fixture" && step.location).map((step) => `${fixtureName(step)}|${relativeFile(step.location.file)}:${step.location.line}`);
13864
+ }
13834
13865
  function fixtureName(step) {
13835
13866
  return step.title.replace(/^(?:Fixture\s+|fixture:\s*)/, "").replace(/^"(.*)"$/, "$1");
13836
13867
  }
@@ -13946,10 +13977,11 @@ function buildResourceReport(input2) {
13946
13977
  const testCensuses = censuses.filter((census) => census.test !== null);
13947
13978
  const workerEnded = censuses.some((census) => census.test === null);
13948
13979
  const timedTests = timedFixtureTests(tracked2.values());
13980
+ const testFixtures = input2.testFixtures ?? /* @__PURE__ */ new Map();
13949
13981
  for (const entry of tracked2.values()) {
13950
13982
  all.push(entry);
13951
13983
  if (entry.birth.kind === "page" && entry.used === false && !entry.bornCensus.test?.failed) idle.push(entry);
13952
- const verdict = leakVerdict(entry, testCensuses, workerEnded, timedTests);
13984
+ const verdict = leakVerdict(entry, testCensuses, workerEnded, timedTests, testFixtures);
13953
13985
  if (verdict) leaked.push({ tracked: entry, ...verdict });
13954
13986
  const tailMs = verdict ? null : lingerTail(entry);
13955
13987
  if (tailMs !== null) lingering.push({ tracked: entry, tailMs });
@@ -13987,9 +14019,12 @@ function timedFixtureTests(tracked2) {
13987
14019
  }
13988
14020
  return out;
13989
14021
  }
13990
- function judgedAsTestScoped(entry, timedTests) {
14022
+ function judgedAsTestScoped(entry, timedTests, testFixtures) {
13991
14023
  const fixture = entry.birth.fixture;
13992
- if (!fixture?.timed || (timedTests.get(fixtureKey(fixture))?.size ?? 0) < 2) return false;
14024
+ if (!fixture?.worker || !fixture.location) return false;
14025
+ const key = fixtureKey(fixture);
14026
+ const tornDownWithTest = !!entry.birth.test && !!testFixtures.get(entry.birth.test.id)?.includes(key);
14027
+ if (!tornDownWithTest && (!fixture.timed || (timedTests.get(key)?.size ?? 0) < 2)) return false;
13993
14028
  const close2 = entry.close?.fixture;
13994
14029
  if (close2 && fixtureKey(close2) === fixtureKey(fixture)) return false;
13995
14030
  return !(entry.lastUse?.test && entry.lastUse.test !== entry.birth.test?.id);
@@ -13997,10 +14032,10 @@ function judgedAsTestScoped(entry, timedTests) {
13997
14032
  function isImplicit(birth) {
13998
14033
  return (birth.kind === "context" || birth.kind === "browser") && !!birth.implicit;
13999
14034
  }
14000
- function leakVerdict(entry, testCensuses, workerEnded, timedTests) {
14035
+ function leakVerdict(entry, testCensuses, workerEnded, timedTests, testFixtures) {
14001
14036
  const { birth, close: close2, bornCensus } = entry;
14002
14037
  if (birth.reused || birth.phase === "worker" || !birth.test || isImplicit(birth)) return null;
14003
- if (birth.fixture?.worker && !judgedAsTestScoped(entry, timedTests)) return null;
14038
+ if (birth.fixture?.worker && !judgedAsTestScoped(entry, timedTests, testFixtures)) return null;
14004
14039
  if (close2?.byPiwi) return { scope: "test", from: bornCensus.at, to: bornCensus.at, heldMs: 0, untilWorkerEnd: false };
14005
14040
  const closedByShutdown = !!close2 && (close2.phase === "worker" || close2.test === null);
14006
14041
  if (birth.phase === "beforeAll" || birth.phase === "afterAll") {
@@ -18124,6 +18159,8 @@ var PiwiDashboardReporter = class _PiwiDashboardReporter {
18124
18159
  this.sourceLines = sourceLineReader();
18125
18160
  /** The user fixtures set up by the tests that left a page unused, by test id. */
18126
18161
  this.fixturesByTest = /* @__PURE__ */ new Map();
18162
+ /** Per test that a fixture with a timeout of its own opened something in: the fixtures torn down with it. */
18163
+ this.testFixtures = /* @__PURE__ */ new Map();
18127
18164
  /** The file workers append their shutdown census to, set in `onBegin`. */
18128
18165
  this.resourcesFile = null;
18129
18166
  /** Samples the run's processes and the machine from `onBegin` to `onEnd`. */
@@ -18893,6 +18930,9 @@ var PiwiDashboardReporter = class _PiwiDashboardReporter {
18893
18930
  if (resources) testCase.resources = resources;
18894
18931
  const leftIdle = census.closed.some((c) => c.used === false) || census.open.some((o) => o.used === false);
18895
18932
  if (leftIdle) this.fixturesByTest.set(test2.id, userFixturesOf(result.steps ?? []));
18933
+ if (census.born.some((birth) => birth.fixture?.worker && birth.fixture.location)) {
18934
+ this.testFixtures.set(test2.id, fixturesTornDownOf(result.steps ?? []));
18935
+ }
18896
18936
  return;
18897
18937
  }
18898
18938
  if (!result.steps?.length) return;
@@ -18927,7 +18967,12 @@ var PiwiDashboardReporter = class _PiwiDashboardReporter {
18927
18967
  }
18928
18968
  const lines = [];
18929
18969
  try {
18930
- const report = censuses.length > 0 || this.lifecycleTallies.length > 0 ? buildResourceReport({ censuses, fixturesByTest: this.fixturesByTest, tallies: this.lifecycleTallies }) : null;
18970
+ const report = censuses.length > 0 || this.lifecycleTallies.length > 0 ? buildResourceReport({
18971
+ censuses,
18972
+ fixturesByTest: this.fixturesByTest,
18973
+ testFixtures: this.testFixtures,
18974
+ tallies: this.lifecycleTallies
18975
+ }) : null;
18931
18976
  if (report) lines.push(...formatResourceSummary(report, readLeakCheck(this.options.leakCheck)));
18932
18977
  if (profile) {
18933
18978
  lines.push(
@@ -20471,26 +20516,70 @@ function showPauseBar(arg) {
20471
20516
  bar.remove();
20472
20517
  delete g.__piwiPauseCleanup;
20473
20518
  };
20474
- const buttons = [
20519
+ const glyphs = {
20520
+ resume: ["fill:M5 3.2v9.6l7.5-4.8z"],
20521
+ step: ["M3 9.5a5 5 0 0 1 10 0", "M11 7.7l2 2 2-2", "fill:M6.9 13a1.1 1.1 0 1 0 2.2 0a1.1 1.1 0 1 0-2.2 0z"],
20522
+ finish: ["M8 11V3", "M5 6l3-3 3 3", "M4 13.5h8"],
20523
+ end: ["M2.5 8a5.5 5.5 0 1 0 11 0a5.5 5.5 0 1 0-11 0z", "M4.1 4.1l7.8 7.8"],
20524
+ pick: ["M2.5 8a5.5 5.5 0 1 0 11 0a5.5 5.5 0 1 0-11 0z", "fill:M6.5 8a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0z"],
20525
+ record: ["fill:M3.5 8a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0-9 0z"]
20526
+ };
20527
+ const SVG = "http://www.w3.org/2000/svg";
20528
+ const glyph = (choice) => {
20529
+ const svg = doc.createElementNS(SVG, "svg");
20530
+ svg.setAttribute("viewBox", "0 0 16 16");
20531
+ svg.setAttribute("aria-hidden", "true");
20532
+ svg.setAttribute("data-piwi-glyph", choice);
20533
+ svg.style.cssText = "flex:none;display:block;width:14px;height:14px;margin:0;padding:0;overflow:visible;";
20534
+ for (const part of glyphs[choice] ?? []) {
20535
+ const path44 = doc.createElementNS(SVG, "path");
20536
+ const filled = part.startsWith("fill:");
20537
+ path44.setAttribute("d", filled ? part.slice(5) : part);
20538
+ path44.style.cssText = filled ? "fill:currentColor;stroke:none;" : "fill:none;stroke:currentColor;stroke-width:1.5px;stroke-linecap:round;stroke-linejoin:round;";
20539
+ svg.appendChild(path44);
20540
+ }
20541
+ return svg;
20542
+ };
20543
+ const steering = [
20475
20544
  arg.failure ? ["Resume", "resume", "Let the test end as it failed (Esc)", true] : ["Resume", "resume", "Run on to the next breakpoint (Esc)", true],
20476
20545
  ...arg.failure ? [] : [["Step", "step", "Pause again before the next call", false]],
20477
- ["Pick a locator", "pick", "Pick an element on the page and confirm a locator for it", false],
20478
- ...arg.record ? [
20479
- ["Record here", "record", "Record steps in this page: the editor writes them before this line", false]
20480
- ] : [],
20481
20546
  ...arg.failure ? [] : [
20482
- ["Finish", "finish", "Run the test on without stopping at a breakpoint again in this attempt", false]
20547
+ [
20548
+ "Finish",
20549
+ "finish",
20550
+ "Run the test on without stopping at a breakpoint again in this attempt",
20551
+ false
20552
+ ]
20483
20553
  ],
20484
- ...arg.end && !arg.failure ? [
20485
- ["End the test", "end", "Skip the rest of this test: it is reported as skipped", false]
20554
+ ...arg.end && !arg.failure ? [["End the test", "end", "Skip the rest of this test: it is reported as skipped", false]] : []
20555
+ ];
20556
+ const code = [
20557
+ ["Pick a locator", "pick", "Pick an element on the page and confirm a locator for it", false],
20558
+ ...arg.record ? [
20559
+ [
20560
+ "Record",
20561
+ "record",
20562
+ "Record steps in this page: the editor writes them before this line",
20563
+ false
20564
+ ]
20486
20565
  ] : []
20487
20566
  ];
20488
- for (const [label, choice, hint, primary] of buttons) {
20567
+ const buttons = [...steering, "divider", ...code];
20568
+ for (const entry of buttons) {
20569
+ if (entry === "divider") {
20570
+ const divider = doc.createElement("span");
20571
+ divider.setAttribute("aria-hidden", "true");
20572
+ divider.style.cssText = "width:1px;align-self:stretch;margin:2px 4px;background:#374151;";
20573
+ bar.appendChild(divider);
20574
+ continue;
20575
+ }
20576
+ const [label, choice, hint, primary] = entry;
20489
20577
  const btn = doc.createElement("button");
20490
20578
  btn.type = "button";
20491
- btn.textContent = label;
20579
+ btn.appendChild(glyph(choice));
20580
+ btn.appendChild(doc.createTextNode(label));
20492
20581
  btn.title = hint;
20493
- btn.style.cssText = "border-radius:6px;padding:4px 12px;cursor:pointer;font:600 12px/1.5 system-ui,sans-serif;" + (primary ? "background:#7c3aed;color:#fff;border:1px solid #7c3aed;" : "background:#1f2937;color:#f3f4f6;border:1px solid #374151;");
20582
+ btn.style.cssText = "display:inline-flex;align-items:center;gap:6px;border-radius:6px;padding:4px 12px 4px 10px;cursor:pointer;font:600 12px/1.5 system-ui,sans-serif;" + (primary ? "background:#7c3aed;color:#fff;border:1px solid #7c3aed;" : "background:#1f2937;color:#f3f4f6;border:1px solid #374151;");
20494
20583
  btn.addEventListener("click", (e) => {
20495
20584
  e.preventDefault();
20496
20585
  e.stopImmediatePropagation();
@@ -21020,20 +21109,26 @@ async function pickLocator(page, probe, failing, ended) {
21020
21109
  const wait = page.waitForFunction(
21021
21110
  ([key, endedKey]) => {
21022
21111
  const g = globalThis;
21023
- if (g[endedKey] !== true) return g[key] !== void 0;
21024
- delete g[endedKey];
21025
- return true;
21112
+ if (g[endedKey] === true) {
21113
+ delete g[endedKey];
21114
+ return true;
21115
+ }
21116
+ if (g[key] !== void 0) return true;
21117
+ const shown2 = ["__piwiPickCleanup", "__piwiAnchorCleanup", "__piwiChoiceCleanup"].some(
21118
+ (cleanup) => typeof g[cleanup] === "function"
21119
+ );
21120
+ return shown2 ? false : "gone";
21026
21121
  },
21027
21122
  [name, PICK_ENDED],
21028
21123
  { timeout: 0, polling: 250 }
21029
21124
  );
21030
21125
  polling = true;
21031
- const done = await unlessEnded(
21032
- wait.then(() => true),
21126
+ const outcome = await unlessEnded(
21127
+ wait.then((handle) => handle.jsonValue()),
21033
21128
  ended
21034
21129
  );
21035
- if (done) polling = false;
21036
- return !ended?.aborted;
21130
+ if (outcome !== void 0) polling = false;
21131
+ return !ended?.aborted && outcome !== "gone";
21037
21132
  };
21038
21133
  try {
21039
21134
  const overlayArg = { transport: "global", failing };
@@ -22430,7 +22525,7 @@ async function pauseHere(page, point, probe, onPick, onRecord, ended, intents, o
22430
22525
  ...point.end ? { end: true } : {}
22431
22526
  };
22432
22527
  console.log(
22433
- point.failure ? `[piwi] The test failed at ${callSiteLine(point.location)}: Resume, Pick a locator${onRecord ? " or Record here" : ""} in the browser (Esc resumes, and the test ends as it failed).` : `[piwi] Paused at ${callSiteLine(point.location)} before ${call}: Resume, Step, Pick a locator${onRecord ? ", Record here" : ""}, Finish${point.end ? " or End the test" : ""} in the browser (Esc resumes).`
22528
+ point.failure ? `[piwi] The test failed at ${callSiteLine(point.location)}: Resume, Pick a locator${onRecord ? " or Record" : ""} in the browser (Esc resumes, and the test ends as it failed).` : `[piwi] Paused at ${callSiteLine(point.location)} before ${call}: Resume, Step, Finish${point.end ? ", End the test" : ""}, then Pick a locator${onRecord ? " or Record" : ""} in the browser (Esc resumes).`
22434
22529
  );
22435
22530
  let navigated = 0;
22436
22531
  for (; ; ) {
@@ -29254,12 +29349,16 @@ function instrumentContext(context) {
29254
29349
  }
29255
29350
  context.on("page", (page) => instrumentPage(page));
29256
29351
  }
29352
+ function runsNoScript(options) {
29353
+ return options?.javaScriptEnabled === false;
29354
+ }
29257
29355
  function patchBrowser(browser) {
29258
29356
  if (!browser || PATCHED_BROWSERS.has(browser)) return;
29259
29357
  PATCHED_BROWSERS.add(browser);
29260
29358
  const originalNewPage = browser.newPage.bind(browser);
29261
29359
  browser.newPage = async (...args) => {
29262
29360
  const page = await originalNewPage(...args);
29361
+ if (runsNoScript(args[0])) return page;
29263
29362
  instrumentPage(page);
29264
29363
  await armStops([pageContext(page)]);
29265
29364
  await awaitFlakeConditions();
@@ -29272,6 +29371,7 @@ function patchBrowser(browser) {
29272
29371
  const emulation = flake?.role === "target" ? flakeContextOptions(flake.plan) : null;
29273
29372
  const context = await originalNewContext(...emulation ? [{ ...args[0], ...emulation }] : args);
29274
29373
  if (emulation) markFlakeContext(context);
29374
+ if (runsNoScript(args[0])) return context;
29275
29375
  instrumentContext(context);
29276
29376
  await armStops([context]);
29277
29377
  return context;