@piwitests/reporter 0.69.0 → 0.71.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
  }
@@ -8848,6 +8873,7 @@ function parseManifestJson(text2) {
8848
8873
  method: r.method,
8849
8874
  pattern: r.pattern,
8850
8875
  handler: typeof r.handler === "string" ? r.handler : void 0,
8876
+ line: typeof r.handler === "string" && Number.isInteger(r.line) && r.line > 0 ? r.line : void 0,
8851
8877
  responses: Array.isArray(r.responses) ? r.responses.filter((c) => Number.isInteger(c)) : void 0
8852
8878
  })) : void 0;
8853
8879
  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;
@@ -11168,14 +11194,16 @@ var RunSubmitter = class {
11168
11194
  * @param streamManager Streaming session (may be `null` when streaming is disabled).
11169
11195
  * @param logger Prefixed logger.
11170
11196
  * @param failureLinks Failed tests collected during the run, for the per-failure links.
11197
+ * @param retryDelaysMs The waits before each repeat of a request whose answer may have been lost.
11171
11198
  */
11172
- constructor(httpClient, uploader, recovery, streamManager, logger2 = new Logger(), failureLinks = null) {
11199
+ constructor(httpClient, uploader, recovery, streamManager, logger2 = new Logger(), failureLinks = null, retryDelaysMs = RETRY_DELAYS_MS) {
11173
11200
  this.httpClient = httpClient;
11174
11201
  this.uploader = uploader;
11175
11202
  this.recovery = recovery;
11176
11203
  this.streamManager = streamManager;
11177
11204
  this.logger = logger2;
11178
11205
  this.failureLinks = failureLinks;
11206
+ this.retryDelaysMs = retryDelaysMs;
11179
11207
  /** The key every batch delivery of this run carries, so the dashboard stores the run once. */
11180
11208
  this.deliveryKey = (0, import_node_crypto3.randomUUID)();
11181
11209
  /** The run's `submitTimeout` budget, and when it runs out (ms since the epoch); null without one. */
@@ -11418,7 +11446,7 @@ var RunSubmitter = class {
11418
11446
  });
11419
11447
  }
11420
11448
  /**
11421
- * Make `request`, and make it again after each of `RETRY_DELAYS_MS` while its answer may have been lost
11449
+ * Make `request`, and make it again after each of `retryDelaysMs` while its answer may have been lost
11422
11450
  * (`answerMayBeLost`), the waits ending with the budget. `request` gets the number of the try, from 0. Throws the
11423
11451
  * last failure.
11424
11452
  */
@@ -11427,7 +11455,7 @@ var RunSubmitter = class {
11427
11455
  try {
11428
11456
  return await request3(attempt3);
11429
11457
  } catch (error) {
11430
- const delay = RETRY_DELAYS_MS[attempt3];
11458
+ const delay = this.retryDelaysMs[attempt3];
11431
11459
  if (delay === void 0 || this.httpClient.closed || !answerMayBeLost(error)) throw error;
11432
11460
  this.logger.warn(`${what} failed (${errorMessage(error)}), perhaps after the dashboard took it: asking again.`);
11433
11461
  const wait = this.budget ? Math.min(delay, Math.max(this.budget.end - Date.now(), 0)) : delay;
@@ -13831,6 +13859,10 @@ function userFixturesOf(steps) {
13831
13859
  walk(steps);
13832
13860
  return [...new Set(out)];
13833
13861
  }
13862
+ function fixturesTornDownOf(steps) {
13863
+ const after = steps.find((step) => step.category === "hook" && step.title === "After Hooks" && !step.location);
13864
+ return (after?.steps ?? []).filter((step) => step.category === "fixture" && step.location).map((step) => `${fixtureName(step)}|${relativeFile(step.location.file)}:${step.location.line}`);
13865
+ }
13834
13866
  function fixtureName(step) {
13835
13867
  return step.title.replace(/^(?:Fixture\s+|fixture:\s*)/, "").replace(/^"(.*)"$/, "$1");
13836
13868
  }
@@ -13946,10 +13978,11 @@ function buildResourceReport(input2) {
13946
13978
  const testCensuses = censuses.filter((census) => census.test !== null);
13947
13979
  const workerEnded = censuses.some((census) => census.test === null);
13948
13980
  const timedTests = timedFixtureTests(tracked2.values());
13981
+ const testFixtures = input2.testFixtures ?? /* @__PURE__ */ new Map();
13949
13982
  for (const entry of tracked2.values()) {
13950
13983
  all.push(entry);
13951
13984
  if (entry.birth.kind === "page" && entry.used === false && !entry.bornCensus.test?.failed) idle.push(entry);
13952
- const verdict = leakVerdict(entry, testCensuses, workerEnded, timedTests);
13985
+ const verdict = leakVerdict(entry, testCensuses, workerEnded, timedTests, testFixtures);
13953
13986
  if (verdict) leaked.push({ tracked: entry, ...verdict });
13954
13987
  const tailMs = verdict ? null : lingerTail(entry);
13955
13988
  if (tailMs !== null) lingering.push({ tracked: entry, tailMs });
@@ -13987,9 +14020,12 @@ function timedFixtureTests(tracked2) {
13987
14020
  }
13988
14021
  return out;
13989
14022
  }
13990
- function judgedAsTestScoped(entry, timedTests) {
14023
+ function judgedAsTestScoped(entry, timedTests, testFixtures) {
13991
14024
  const fixture = entry.birth.fixture;
13992
- if (!fixture?.timed || (timedTests.get(fixtureKey(fixture))?.size ?? 0) < 2) return false;
14025
+ if (!fixture?.worker || !fixture.location) return false;
14026
+ const key = fixtureKey(fixture);
14027
+ const tornDownWithTest = !!entry.birth.test && !!testFixtures.get(entry.birth.test.id)?.includes(key);
14028
+ if (!tornDownWithTest && (!fixture.timed || (timedTests.get(key)?.size ?? 0) < 2)) return false;
13993
14029
  const close2 = entry.close?.fixture;
13994
14030
  if (close2 && fixtureKey(close2) === fixtureKey(fixture)) return false;
13995
14031
  return !(entry.lastUse?.test && entry.lastUse.test !== entry.birth.test?.id);
@@ -13997,10 +14033,10 @@ function judgedAsTestScoped(entry, timedTests) {
13997
14033
  function isImplicit(birth) {
13998
14034
  return (birth.kind === "context" || birth.kind === "browser") && !!birth.implicit;
13999
14035
  }
14000
- function leakVerdict(entry, testCensuses, workerEnded, timedTests) {
14036
+ function leakVerdict(entry, testCensuses, workerEnded, timedTests, testFixtures) {
14001
14037
  const { birth, close: close2, bornCensus } = entry;
14002
14038
  if (birth.reused || birth.phase === "worker" || !birth.test || isImplicit(birth)) return null;
14003
- if (birth.fixture?.worker && !judgedAsTestScoped(entry, timedTests)) return null;
14039
+ if (birth.fixture?.worker && !judgedAsTestScoped(entry, timedTests, testFixtures)) return null;
14004
14040
  if (close2?.byPiwi) return { scope: "test", from: bornCensus.at, to: bornCensus.at, heldMs: 0, untilWorkerEnd: false };
14005
14041
  const closedByShutdown = !!close2 && (close2.phase === "worker" || close2.test === null);
14006
14042
  if (birth.phase === "beforeAll" || birth.phase === "afterAll") {
@@ -18124,6 +18160,8 @@ var PiwiDashboardReporter = class _PiwiDashboardReporter {
18124
18160
  this.sourceLines = sourceLineReader();
18125
18161
  /** The user fixtures set up by the tests that left a page unused, by test id. */
18126
18162
  this.fixturesByTest = /* @__PURE__ */ new Map();
18163
+ /** Per test that a fixture with a timeout of its own opened something in: the fixtures torn down with it. */
18164
+ this.testFixtures = /* @__PURE__ */ new Map();
18127
18165
  /** The file workers append their shutdown census to, set in `onBegin`. */
18128
18166
  this.resourcesFile = null;
18129
18167
  /** Samples the run's processes and the machine from `onBegin` to `onEnd`. */
@@ -18893,6 +18931,9 @@ var PiwiDashboardReporter = class _PiwiDashboardReporter {
18893
18931
  if (resources) testCase.resources = resources;
18894
18932
  const leftIdle = census.closed.some((c) => c.used === false) || census.open.some((o) => o.used === false);
18895
18933
  if (leftIdle) this.fixturesByTest.set(test2.id, userFixturesOf(result.steps ?? []));
18934
+ if (census.born.some((birth) => birth.fixture?.worker && birth.fixture.location)) {
18935
+ this.testFixtures.set(test2.id, fixturesTornDownOf(result.steps ?? []));
18936
+ }
18896
18937
  return;
18897
18938
  }
18898
18939
  if (!result.steps?.length) return;
@@ -18927,7 +18968,12 @@ var PiwiDashboardReporter = class _PiwiDashboardReporter {
18927
18968
  }
18928
18969
  const lines = [];
18929
18970
  try {
18930
- const report = censuses.length > 0 || this.lifecycleTallies.length > 0 ? buildResourceReport({ censuses, fixturesByTest: this.fixturesByTest, tallies: this.lifecycleTallies }) : null;
18971
+ const report = censuses.length > 0 || this.lifecycleTallies.length > 0 ? buildResourceReport({
18972
+ censuses,
18973
+ fixturesByTest: this.fixturesByTest,
18974
+ testFixtures: this.testFixtures,
18975
+ tallies: this.lifecycleTallies
18976
+ }) : null;
18931
18977
  if (report) lines.push(...formatResourceSummary(report, readLeakCheck(this.options.leakCheck)));
18932
18978
  if (profile) {
18933
18979
  lines.push(
@@ -20471,26 +20517,70 @@ function showPauseBar(arg) {
20471
20517
  bar.remove();
20472
20518
  delete g.__piwiPauseCleanup;
20473
20519
  };
20474
- const buttons = [
20520
+ const glyphs = {
20521
+ resume: ["fill:M5 3.2v9.6l7.5-4.8z"],
20522
+ 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"],
20523
+ finish: ["M8 11V3", "M5 6l3-3 3 3", "M4 13.5h8"],
20524
+ 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"],
20525
+ 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"],
20526
+ record: ["fill:M3.5 8a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0-9 0z"]
20527
+ };
20528
+ const SVG = "http://www.w3.org/2000/svg";
20529
+ const glyph = (choice) => {
20530
+ const svg = doc.createElementNS(SVG, "svg");
20531
+ svg.setAttribute("viewBox", "0 0 16 16");
20532
+ svg.setAttribute("aria-hidden", "true");
20533
+ svg.setAttribute("data-piwi-glyph", choice);
20534
+ svg.style.cssText = "flex:none;display:block;width:14px;height:14px;margin:0;padding:0;overflow:visible;";
20535
+ for (const part of glyphs[choice] ?? []) {
20536
+ const path44 = doc.createElementNS(SVG, "path");
20537
+ const filled = part.startsWith("fill:");
20538
+ path44.setAttribute("d", filled ? part.slice(5) : part);
20539
+ path44.style.cssText = filled ? "fill:currentColor;stroke:none;" : "fill:none;stroke:currentColor;stroke-width:1.5px;stroke-linecap:round;stroke-linejoin:round;";
20540
+ svg.appendChild(path44);
20541
+ }
20542
+ return svg;
20543
+ };
20544
+ const steering = [
20475
20545
  arg.failure ? ["Resume", "resume", "Let the test end as it failed (Esc)", true] : ["Resume", "resume", "Run on to the next breakpoint (Esc)", true],
20476
20546
  ...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
20547
  ...arg.failure ? [] : [
20482
- ["Finish", "finish", "Run the test on without stopping at a breakpoint again in this attempt", false]
20548
+ [
20549
+ "Finish",
20550
+ "finish",
20551
+ "Run the test on without stopping at a breakpoint again in this attempt",
20552
+ false
20553
+ ]
20483
20554
  ],
20484
- ...arg.end && !arg.failure ? [
20485
- ["End the test", "end", "Skip the rest of this test: it is reported as skipped", false]
20555
+ ...arg.end && !arg.failure ? [["End the test", "end", "Skip the rest of this test: it is reported as skipped", false]] : []
20556
+ ];
20557
+ const code = [
20558
+ ["Pick a locator", "pick", "Pick an element on the page and confirm a locator for it", false],
20559
+ ...arg.record ? [
20560
+ [
20561
+ "Record",
20562
+ "record",
20563
+ "Record steps in this page: the editor writes them before this line",
20564
+ false
20565
+ ]
20486
20566
  ] : []
20487
20567
  ];
20488
- for (const [label, choice, hint, primary] of buttons) {
20568
+ const buttons = [...steering, "divider", ...code];
20569
+ for (const entry of buttons) {
20570
+ if (entry === "divider") {
20571
+ const divider = doc.createElement("span");
20572
+ divider.setAttribute("aria-hidden", "true");
20573
+ divider.style.cssText = "width:1px;align-self:stretch;margin:2px 4px;background:#374151;";
20574
+ bar.appendChild(divider);
20575
+ continue;
20576
+ }
20577
+ const [label, choice, hint, primary] = entry;
20489
20578
  const btn = doc.createElement("button");
20490
20579
  btn.type = "button";
20491
- btn.textContent = label;
20580
+ btn.appendChild(glyph(choice));
20581
+ btn.appendChild(doc.createTextNode(label));
20492
20582
  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;");
20583
+ 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
20584
  btn.addEventListener("click", (e) => {
20495
20585
  e.preventDefault();
20496
20586
  e.stopImmediatePropagation();
@@ -21020,20 +21110,26 @@ async function pickLocator(page, probe, failing, ended) {
21020
21110
  const wait = page.waitForFunction(
21021
21111
  ([key, endedKey]) => {
21022
21112
  const g = globalThis;
21023
- if (g[endedKey] !== true) return g[key] !== void 0;
21024
- delete g[endedKey];
21025
- return true;
21113
+ if (g[endedKey] === true) {
21114
+ delete g[endedKey];
21115
+ return true;
21116
+ }
21117
+ if (g[key] !== void 0) return true;
21118
+ const shown2 = ["__piwiPickCleanup", "__piwiAnchorCleanup", "__piwiChoiceCleanup"].some(
21119
+ (cleanup) => typeof g[cleanup] === "function"
21120
+ );
21121
+ return shown2 ? false : "gone";
21026
21122
  },
21027
21123
  [name, PICK_ENDED],
21028
21124
  { timeout: 0, polling: 250 }
21029
21125
  );
21030
21126
  polling = true;
21031
- const done = await unlessEnded(
21032
- wait.then(() => true),
21127
+ const outcome = await unlessEnded(
21128
+ wait.then((handle) => handle.jsonValue()),
21033
21129
  ended
21034
21130
  );
21035
- if (done) polling = false;
21036
- return !ended?.aborted;
21131
+ if (outcome !== void 0) polling = false;
21132
+ return !ended?.aborted && outcome !== "gone";
21037
21133
  };
21038
21134
  try {
21039
21135
  const overlayArg = { transport: "global", failing };
@@ -22430,7 +22526,7 @@ async function pauseHere(page, point, probe, onPick, onRecord, ended, intents, o
22430
22526
  ...point.end ? { end: true } : {}
22431
22527
  };
22432
22528
  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).`
22529
+ 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
22530
  );
22435
22531
  let navigated = 0;
22436
22532
  for (; ; ) {
@@ -29254,12 +29350,16 @@ function instrumentContext(context) {
29254
29350
  }
29255
29351
  context.on("page", (page) => instrumentPage(page));
29256
29352
  }
29353
+ function runsNoScript(options) {
29354
+ return options?.javaScriptEnabled === false;
29355
+ }
29257
29356
  function patchBrowser(browser) {
29258
29357
  if (!browser || PATCHED_BROWSERS.has(browser)) return;
29259
29358
  PATCHED_BROWSERS.add(browser);
29260
29359
  const originalNewPage = browser.newPage.bind(browser);
29261
29360
  browser.newPage = async (...args) => {
29262
29361
  const page = await originalNewPage(...args);
29362
+ if (runsNoScript(args[0])) return page;
29263
29363
  instrumentPage(page);
29264
29364
  await armStops([pageContext(page)]);
29265
29365
  await awaitFlakeConditions();
@@ -29272,6 +29372,7 @@ function patchBrowser(browser) {
29272
29372
  const emulation = flake?.role === "target" ? flakeContextOptions(flake.plan) : null;
29273
29373
  const context = await originalNewContext(...emulation ? [{ ...args[0], ...emulation }] : args);
29274
29374
  if (emulation) markFlakeContext(context);
29375
+ if (runsNoScript(args[0])) return context;
29275
29376
  instrumentContext(context);
29276
29377
  await armStops([context]);
29277
29378
  return context;
@@ -29649,7 +29750,8 @@ function testEnd(sink, testInfo) {
29649
29750
  type: "test-end",
29650
29751
  testId: testInfo.testId,
29651
29752
  status: testInfo.status ?? "passed",
29652
- pausedMs: sink.stops.reduce((sum, stop2) => sum + stop2.duration, 0)
29753
+ pausedMs: sink.stops.reduce((sum, stop2) => sum + stop2.duration, 0),
29754
+ expectedStatus: testInfo.expectedStatus
29653
29755
  };
29654
29756
  }
29655
29757
  var piwiFixtures = {