lazyscout 0.4.1 → 0.4.2

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
@@ -268,6 +268,222 @@ function isBlockedLabel(keywords, ...labels) {
268
268
  return keywords.some((keyword) => keyword && haystack.includes(keyword.toLowerCase()));
269
269
  }
270
270
 
271
+ // ../../packages/core/dist/patterns/catalog.js
272
+ var INPUT_TYPE_PATTERN = {
273
+ text: "text-input",
274
+ email: "text-input",
275
+ password: "text-input",
276
+ search: "text-input",
277
+ tel: "text-input",
278
+ url: "text-input",
279
+ number: "number-input",
280
+ range: "slider",
281
+ date: "date-input",
282
+ "datetime-local": "date-input",
283
+ month: "date-input",
284
+ week: "date-input",
285
+ time: "date-input",
286
+ checkbox: "checkbox",
287
+ radio: "radio",
288
+ file: "file-upload"
289
+ };
290
+ var ROLE_PATTERN = {
291
+ tab: "tab",
292
+ switch: "switch",
293
+ slider: "slider",
294
+ checkbox: "checkbox",
295
+ radio: "radio",
296
+ combobox: "combobox",
297
+ listbox: "select",
298
+ menu: "menu",
299
+ menubar: "menu",
300
+ menuitem: "menu",
301
+ link: "link",
302
+ searchbox: "text-input",
303
+ textbox: "text-input",
304
+ spinbutton: "number-input",
305
+ grid: "table",
306
+ table: "table",
307
+ navigation: "navigation"
308
+ };
309
+ var RULES = [
310
+ {
311
+ pattern: "tab",
312
+ evidence: () => 'role="tab"',
313
+ when: (element) => element.role === "tab"
314
+ },
315
+ {
316
+ pattern: "dialog-opener",
317
+ evidence: (element) => element.hasPopup === "dialog" ? 'aria-haspopup="dialog"' : `data-toggle="${element.hasPopup ?? "modal"}"`,
318
+ when: (element) => element.hasPopup === "dialog" || element.hasPopup === "modal" || element.hasPopup === "drawer"
319
+ },
320
+ {
321
+ pattern: "menu",
322
+ evidence: (element) => element.role?.startsWith("menuitem") || element.role === "menu" || element.role === "menubar" ? `role="${element.role}"` : `aria-haspopup="${element.hasPopup}"`,
323
+ when: (element) => Boolean(element.role?.startsWith("menuitem")) || element.role === "menu" || element.role === "menubar" || element.hasPopup === "menu" || element.hasPopup === "listbox" || element.hasPopup === "dropdown"
324
+ },
325
+ {
326
+ pattern: "accordion",
327
+ evidence: (element) => element.tagName === "summary" ? "<summary>" : "aria-expanded",
328
+ when: (element) => element.tagName === "summary" || element.expanded !== void 0
329
+ },
330
+ {
331
+ pattern: "file-upload",
332
+ evidence: () => 'input type="file"',
333
+ when: (element) => element.inputType === "file"
334
+ },
335
+ {
336
+ pattern: "switch",
337
+ evidence: () => 'role="switch"',
338
+ when: (element) => element.role === "switch"
339
+ },
340
+ {
341
+ pattern: "select",
342
+ evidence: () => "<select>",
343
+ when: (element) => element.tagName === "select"
344
+ },
345
+ {
346
+ pattern: "combobox",
347
+ evidence: () => 'role="combobox"',
348
+ when: (element) => element.role === "combobox"
349
+ },
350
+ {
351
+ pattern: "submit",
352
+ evidence: (element) => `type="${element.inputType ?? "submit"}"`,
353
+ when: (element) => element.inputType === "submit" || (element.tagName === "button" || element.role === "button") && element.context?.container === "form"
354
+ },
355
+ {
356
+ pattern: "pagination",
357
+ evidence: () => 'rel="next"/"prev"',
358
+ when: (element) => element.kind === "link" && /^(next|prev|previous|\d{1,3}|»|«|›|‹)$/i.test(element.accessibleName.trim())
359
+ },
360
+ {
361
+ pattern: "link",
362
+ evidence: () => "<a href>",
363
+ when: (element) => element.kind === "link" || element.role === "link"
364
+ },
365
+ {
366
+ pattern: "table",
367
+ evidence: () => 'role="grid"',
368
+ when: (element) => element.role === "grid" || element.role === "table"
369
+ }
370
+ ];
371
+ function matchPattern(element) {
372
+ for (const rule of RULES) {
373
+ if (rule.when(element))
374
+ return { pattern: rule.pattern, evidence: rule.evidence(element) };
375
+ }
376
+ if (element.inputType && INPUT_TYPE_PATTERN[element.inputType]) {
377
+ return { pattern: INPUT_TYPE_PATTERN[element.inputType], evidence: `input type="${element.inputType}"` };
378
+ }
379
+ if (element.kind === "textarea")
380
+ return { pattern: "text-input", evidence: "<textarea>" };
381
+ if (element.role && ROLE_PATTERN[element.role]) {
382
+ return { pattern: ROLE_PATTERN[element.role], evidence: `role="${element.role}"` };
383
+ }
384
+ if (element.tagName === "button")
385
+ return { pattern: "button", evidence: "<button>" };
386
+ if (element.role === "button")
387
+ return { pattern: "button", evidence: 'role="button"' };
388
+ if (element.inputType === "button" || element.inputType === "reset") {
389
+ return { pattern: "button", evidence: `input type="${element.inputType}"` };
390
+ }
391
+ return { pattern: "unknown", evidence: `tag="${element.tagName}" role="${element.role || "none"}"` };
392
+ }
393
+ function classifyRisk(element, blockedKeywords = []) {
394
+ const labels = [element.accessibleName, element.text, element.name, element.id, element.ariaLabel];
395
+ if (isUnsafeAutoClick(...labels))
396
+ return "session-ending";
397
+ if (element.destructive || isBlockedLabel(blockedKeywords, ...labels))
398
+ return "destructive";
399
+ if (matchPattern(element).pattern === "unknown")
400
+ return "needs-review";
401
+ return "safe";
402
+ }
403
+ function elementIdentity(element, pattern) {
404
+ const locator3 = element.testId && `${element.testIdAttribute ?? "data-testid"}=${element.testId}` || element.id && `#${element.id}` || element.role && element.accessibleName && `${element.role}:${element.accessibleName}` || element.name && `[name=${element.name}]` || element.cssSelector || element.accessibleName;
405
+ return `${pattern}|${element.context?.containerSelector ?? ""}|${locator3}`;
406
+ }
407
+
408
+ // ../../packages/core/dist/patterns/coverage.js
409
+ var CoverageTracker = class {
410
+ entries = /* @__PURE__ */ new Map();
411
+ modalStates = 0;
412
+ casesGenerated = 0;
413
+ casesDeduplicated = 0;
414
+ /** Register an element as discovered. Safe to call repeatedly. */
415
+ discover(element, stateId2) {
416
+ const pattern = element.uiPattern ?? matchPattern(element).pattern;
417
+ const id2 = element.elementId ?? elementIdentity(element, pattern);
418
+ if (!this.entries.has(id2)) {
419
+ this.entries.set(id2, {
420
+ elementId: id2,
421
+ pattern,
422
+ reason: element.disabled ? "disabled" : pattern === "unknown" ? "unknown-pattern" : "skipped-limit",
423
+ stateId: stateId2,
424
+ locator: element.cssSelector,
425
+ name: element.accessibleName || element.name || element.id
426
+ });
427
+ }
428
+ return id2;
429
+ }
430
+ /**
431
+ * Record the outcome for an element. `tested` is terminal — a later skip for
432
+ * the same element cannot downgrade it.
433
+ */
434
+ record(elementId, reason, detail) {
435
+ const entry = this.entries.get(elementId);
436
+ if (!entry)
437
+ return;
438
+ if (entry.reason === "tested" && reason !== "tested")
439
+ return;
440
+ entry.reason = reason;
441
+ if (detail)
442
+ entry.detail = detail;
443
+ }
444
+ countModalState() {
445
+ this.modalStates += 1;
446
+ }
447
+ countCase(deduplicated = false) {
448
+ if (deduplicated)
449
+ this.casesDeduplicated += 1;
450
+ else
451
+ this.casesGenerated += 1;
452
+ }
453
+ report() {
454
+ return buildCoverageReport([...this.entries.values()], {
455
+ modalStates: this.modalStates,
456
+ casesGenerated: this.casesGenerated,
457
+ casesDeduplicated: this.casesDeduplicated
458
+ });
459
+ }
460
+ };
461
+ var BLOCKED = ["blocked-destructive", "blocked-session-ending", "blocked-filter"];
462
+ var SKIPPED = ["skipped-limit", "skipped-duplicate", "not-visible", "disabled", "failed"];
463
+ function buildCoverageReport(entries, totals = {}) {
464
+ const byPattern = /* @__PURE__ */ new Map();
465
+ for (const entry of entries) {
466
+ const bucket = byPattern.get(entry.pattern) ?? { discovered: 0, tested: 0 };
467
+ bucket.discovered += 1;
468
+ if (entry.reason === "tested")
469
+ bucket.tested += 1;
470
+ byPattern.set(entry.pattern, bucket);
471
+ }
472
+ return {
473
+ elementsDiscovered: entries.length,
474
+ knownPatterns: entries.filter((entry) => entry.pattern !== "unknown").length,
475
+ tested: entries.filter((entry) => entry.reason === "tested").length,
476
+ skipped: entries.filter((entry) => SKIPPED.includes(entry.reason)).length,
477
+ blocked: entries.filter((entry) => BLOCKED.includes(entry.reason)).length,
478
+ unknown: entries.filter((entry) => entry.reason === "unknown-pattern").length,
479
+ modalStates: totals.modalStates ?? 0,
480
+ casesGenerated: totals.casesGenerated ?? 0,
481
+ casesDeduplicated: totals.casesDeduplicated ?? 0,
482
+ byPattern: [...byPattern.entries()].map(([pattern, bucket]) => ({ pattern, ...bucket })).sort((left, right) => right.discovered - left.discovered),
483
+ entries
484
+ };
485
+ }
486
+
271
487
  // ../../packages/core/dist/testcase/describeStep.js
272
488
  function describeTarget(target) {
273
489
  const name = target.name || target.label || target.text || target.placeholder;
@@ -337,7 +553,7 @@ function collectPageData() {
337
553
  return ariaLabel;
338
554
  const labelledBy = el.getAttribute("aria-labelledby");
339
555
  if (labelledBy) {
340
- const text = labelledBy.split(/\s+/).map((id) => cleanText(document.getElementById(id)?.textContent)).filter(Boolean).join(" ");
556
+ const text = labelledBy.split(/\s+/).map((id2) => cleanText(document.getElementById(id2)?.textContent)).filter(Boolean).join(" ");
341
557
  if (text)
342
558
  return text;
343
559
  }
@@ -398,6 +614,50 @@ function collectPageData() {
398
614
  }
399
615
  return parts.join(" > ");
400
616
  }
617
+ const TEST_ID_ATTRIBUTES = ["data-testid", "data-test-id", "data-test", "data-qa", "data-cy"];
618
+ function testIdOf(el) {
619
+ for (const attribute2 of TEST_ID_ATTRIBUTES) {
620
+ const value = attr(el, attribute2);
621
+ if (value)
622
+ return { attribute: attribute2, value };
623
+ }
624
+ return void 0;
625
+ }
626
+ function ariaFlag(el, name) {
627
+ const value = el.getAttribute(name);
628
+ return value === null ? void 0 : value === "true";
629
+ }
630
+ function relationOf(el) {
631
+ const relation = {
632
+ controls: attr(el, "aria-controls"),
633
+ labelledBy: attr(el, "aria-labelledby"),
634
+ describedBy: attr(el, "aria-describedby"),
635
+ owns: attr(el, "aria-owns"),
636
+ target: attr(el, "data-target") || attr(el, "data-bs-target") || attr(el, "data-modal") || attr(el, "data-drawer")
637
+ };
638
+ return Object.values(relation).some(Boolean) ? relation : void 0;
639
+ }
640
+ const CONTAINERS = [
641
+ ["dialog", '[role="dialog"], [role="alertdialog"], dialog, [aria-modal="true"]'],
642
+ ["tab-panel", '[role="tabpanel"]'],
643
+ ["menu", '[role="menu"], [role="listbox"]'],
644
+ ["table-row", 'tr, [role="row"]'],
645
+ ["form", "form"],
646
+ ["card", '[class*="card" i], article']
647
+ ];
648
+ function contextOf(el) {
649
+ for (const [container, selector] of CONTAINERS) {
650
+ const found = el.closest(selector);
651
+ if (!found)
652
+ continue;
653
+ return {
654
+ container,
655
+ containerSelector: cssSelector(found),
656
+ containerName: accessibleName(found) || cleanText(found.querySelector("h1, h2, h3, legend, caption")?.textContent) || void 0
657
+ };
658
+ }
659
+ return { container: "page" };
660
+ }
401
661
  function inputRole(input) {
402
662
  switch (input.type) {
403
663
  case "checkbox":
@@ -450,8 +710,23 @@ function collectPageData() {
450
710
  inputType,
451
711
  placeholder: attr(el, "placeholder"),
452
712
  name: attr(el, "name"),
453
- testId: attr(el, "data-testid"),
713
+ testId: testIdOf(el)?.value,
714
+ // Kept so the generator matches the attribute the page really uses
715
+ // instead of rewriting it to Playwright's default `data-testid`.
716
+ testIdAttribute: testIdOf(el)?.attribute,
454
717
  id: el.id || void 0,
718
+ ariaLabel: attr(el, "aria-label"),
719
+ describedBy: attr(el, "aria-describedby"),
720
+ visible: true,
721
+ readOnly: el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement ? el.readOnly : void 0,
722
+ checked: el instanceof HTMLInputElement && (el.type === "checkbox" || el.type === "radio") ? el.checked : ariaFlag(el, "aria-checked"),
723
+ expanded: ariaFlag(el, "aria-expanded"),
724
+ selected: ariaFlag(el, "aria-selected"),
725
+ multiple: el instanceof HTMLSelectElement || el instanceof HTMLInputElement ? el.multiple : void 0,
726
+ accept: el instanceof HTMLInputElement && el.type === "file" ? attr(el, "accept") : void 0,
727
+ hasPopup: attr(el, "aria-haspopup") || attr(el, "data-toggle") || attr(el, "data-bs-toggle"),
728
+ relation: relationOf(el),
729
+ context: contextOf(el),
455
730
  href: el instanceof HTMLAnchorElement ? el.href : void 0,
456
731
  options,
457
732
  required,
@@ -522,6 +797,33 @@ function collectPageData() {
522
797
  }
523
798
  const BUTTON_SELECTOR = 'button, input[type="submit"], input[type="button"], input[type="reset"], [role="button"]';
524
799
  const INPUT_SELECTOR = 'input:not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="image"])';
800
+ const WIDGET_SELECTOR = [
801
+ '[role="tab"]',
802
+ '[role="switch"]',
803
+ '[role="slider"]',
804
+ '[role="menuitem"]',
805
+ '[role="menuitemcheckbox"]',
806
+ '[role="menuitemradio"]',
807
+ '[role="option"]',
808
+ '[role="combobox"]',
809
+ '[role="checkbox"]',
810
+ '[role="radio"]',
811
+ '[role="link"]',
812
+ '[role="treeitem"]',
813
+ "summary",
814
+ "[aria-expanded]",
815
+ "[aria-haspopup]",
816
+ "[aria-controls]",
817
+ "[data-toggle]",
818
+ "[data-bs-toggle]",
819
+ "[data-target]",
820
+ "[data-bs-target]",
821
+ "[data-modal]",
822
+ "[data-drawer]",
823
+ "[data-tab]",
824
+ "[onclick]",
825
+ '[tabindex]:not([tabindex="-1"])'
826
+ ].join(", ");
525
827
  const forms = Array.from(document.querySelectorAll("form")).slice(0, 20).map((form) => {
526
828
  const fields = Array.from(form.querySelectorAll(INPUT_SELECTOR + ", textarea, select")).filter(isCollectable).slice(0, 40).map((el) => {
527
829
  const kind = el.tagName === "TEXTAREA" ? "textarea" : el.tagName === "SELECT" ? "select" : "input";
@@ -547,6 +849,8 @@ function collectPageData() {
547
849
  inputs: collect(INPUT_SELECTOR, "input", "textbox"),
548
850
  textareas: collect("textarea", "textarea", "textbox"),
549
851
  selects: collect("select", "select", "combobox"),
852
+ // Everything interactive that the native groups above do not already cover.
853
+ widgets: Array.from(document.querySelectorAll(WIDGET_SELECTOR)).filter(isCollectable).filter((el) => !el.matches(`a[href], ${BUTTON_SELECTOR}, ${INPUT_SELECTOR}, textarea, select`)).slice(0, MAX_PER_GROUP).map((el) => toRawElement(el, "button", attr(el, "role") || "generic")),
550
854
  forms,
551
855
  visibleDialogs: Array.from(document.querySelectorAll('[role="dialog"], dialog[open], [aria-modal="true"], .modal-backdrop:not(.hidden), .modal:not(.hidden), .drawer:not(.hidden)')).filter(isCollectable).map((element) => accessibleName(element) || cleanText(element.querySelector("h1, h2, h3")?.textContent) || cleanText(element.textContent).slice(0, 120)).filter(Boolean).slice(0, 20),
552
856
  interactions: Array.from(document.querySelectorAll('[role="tab"], [role="tablist"] [aria-controls], [aria-expanded], [aria-haspopup], [data-toggle], [data-bs-toggle], [data-modal], [data-drawer], [data-tab], details[data-accordion], select')).filter(isCollectable).map((element) => {
@@ -559,13 +863,17 @@ function collectPageData() {
559
863
  const dataTab = element.hasAttribute("data-tab");
560
864
  const accordion = element.matches("details[data-accordion]");
561
865
  const kind = role === "tab" || dataTab ? "tab" : dataDrawer ? "drawer" : popup === "dialog" || toggle === "modal" || dataModal ? "dialog" : popup === "menu" || popup === "listbox" || toggle === "dropdown" ? "dropdown" : accordion ? "accordion" : element instanceof HTMLSelectElement ? "dropdown" : element.matches("[aria-expanded]") ? "accordion" : "dialog";
866
+ const controls = element.getAttribute("aria-controls");
867
+ const targetSelector = element.getAttribute("data-target") || element.getAttribute("data-bs-target") || element.getAttribute("data-modal") || element.getAttribute("data-drawer");
562
868
  return {
563
869
  kind,
564
870
  name: accessibleName(element),
565
871
  role,
566
872
  cssSelector: cssSelector(element),
567
873
  expanded: expanded === null ? void 0 : expanded === "true",
568
- visible: true
874
+ visible: true,
875
+ controlsSelector: controls ? `#${CSS.escape(controls)}` : targetSelector || void 0,
876
+ evidence: role === "tab" ? 'role="tab"' : popup ? `aria-haspopup="${popup}"` : toggle ? `data-toggle="${toggle}"` : dataModal ? "data-modal" : dataDrawer ? "data-drawer" : accordion ? "details[data-accordion]" : expanded !== null ? "aria-expanded" : "<select>"
569
877
  };
570
878
  }).filter((item) => item.name).slice(0, 40),
571
879
  stateContent: Array.from(document.querySelectorAll('[aria-live], [data-state], [data-testid*="state" i]')).filter(isCollectable).map((element) => cleanText(element.textContent)).filter(Boolean).slice(0, 30),
@@ -578,10 +886,18 @@ function collectPageData() {
578
886
 
579
887
  // ../../packages/explorer/dist/mapToPageModel.js
580
888
  function toUIElement(raw, keywords) {
581
- return {
889
+ const base2 = {
582
890
  ...raw,
583
891
  destructive: isBlockedLabel(keywords, raw.accessibleName, raw.text, raw.name, raw.id)
584
892
  };
893
+ const { pattern, evidence } = matchPattern(base2);
894
+ return {
895
+ ...base2,
896
+ uiPattern: pattern,
897
+ patternEvidence: evidence,
898
+ risk: classifyRisk(base2, keywords),
899
+ elementId: elementIdentity(base2, pattern)
900
+ };
585
901
  }
586
902
  function toFormInfo(raw, keywords) {
587
903
  return {
@@ -601,7 +917,8 @@ function mapToPageModel(raw, meta, blockedKeywords = []) {
601
917
  const inputs = raw.inputs.map(toElement);
602
918
  const textareas = raw.textareas.map(toElement);
603
919
  const selects = raw.selects.map(toElement);
604
- const controls = [...links, ...buttons, ...inputs, ...textareas, ...selects];
920
+ const widgets = (raw.widgets ?? []).map(toElement);
921
+ const controls = [...links, ...buttons, ...inputs, ...textareas, ...selects, ...widgets];
605
922
  const state = createPageState(raw, meta.finalUrl, controls);
606
923
  return {
607
924
  url: meta.url,
@@ -745,6 +1062,7 @@ var DEFAULT_CONFIG = {
745
1062
  limits: DEFAULT_LIMITS,
746
1063
  continueAfterLogin: true
747
1064
  };
1065
+ var MAX_MODAL_DEPTH = 3;
748
1066
  async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions = {}) {
749
1067
  const config2 = {
750
1068
  ...DEFAULT_CONFIG,
@@ -801,7 +1119,32 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
801
1119
  let totalActionsFailed = 0;
802
1120
  let totalActionsRetried = 0;
803
1121
  let urlsSkippedByScope = 0;
1122
+ let modalStatesDiscovered = 0;
804
1123
  let endReason = "queue-exhausted";
1124
+ const transitions = [];
1125
+ const coverage = new CoverageTracker();
1126
+ function recordTransition(from, action, before, after, result, durationMs) {
1127
+ const beforeText = new Set(from.stateContent);
1128
+ const afterText = after.state?.stateContent ?? [];
1129
+ transitions.push({
1130
+ sourceStateId: from.id,
1131
+ destinationStateId: after.state?.id,
1132
+ actionId: action.id,
1133
+ actionType: action.type,
1134
+ targetLocator: action.selector,
1135
+ urlBefore: before.url,
1136
+ urlAfter: after.url,
1137
+ fingerprintBefore: before.fingerprint,
1138
+ fingerprintAfter: after.state?.fingerprint ?? before.fingerprint,
1139
+ result,
1140
+ visibleDialogsAfter: after.state?.visibleDialogs,
1141
+ headingsAfter: after.state?.headings,
1142
+ addedText: afterText.filter((text) => !beforeText.has(text)).slice(0, 10),
1143
+ removedText: from.stateContent.filter((text) => !afterText.includes(text)).slice(0, 10),
1144
+ validationMessagesAfter: after.state?.validationMessages,
1145
+ durationMs
1146
+ });
1147
+ }
805
1148
  function isWithinScope(url) {
806
1149
  if (!config2.scopePath)
807
1150
  return true;
@@ -1173,23 +1516,48 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
1173
1516
  }
1174
1517
  return { success: false };
1175
1518
  }
1176
- async function exploreModal(page, parentState, _sourceUrl, entryFlow) {
1519
+ async function exploreModal(page, parentState, _sourceUrl, entryFlow, depth = 1) {
1520
+ if (depth > MAX_MODAL_DEPTH) {
1521
+ debug(`Modal depth limit reached (${MAX_MODAL_DEPTH})`, { stateId: parentState.id });
1522
+ return { candidates: [] };
1523
+ }
1177
1524
  try {
1178
- const hasDialog = await page.evaluate(() => {
1179
- return !!(document.querySelector('[role="dialog"]') || document.querySelector("dialog[open]") || document.querySelector('[aria-modal="true"]'));
1525
+ const containerSelector = await page.evaluate(() => {
1526
+ const open = Array.from(document.querySelectorAll('dialog[open], [role="dialog"], [role="alertdialog"], [aria-modal="true"]')).filter((element) => {
1527
+ const style = window.getComputedStyle(element);
1528
+ return style.display !== "none" && style.visibility !== "hidden";
1529
+ });
1530
+ const container = open.at(-1);
1531
+ if (!container)
1532
+ return void 0;
1533
+ if (container.id)
1534
+ return `#${CSS.escape(container.id)}`;
1535
+ container.setAttribute("data-lazyscout-modal", "true");
1536
+ return '[data-lazyscout-modal="true"]';
1180
1537
  });
1181
- if (!hasDialog)
1538
+ if (!containerSelector)
1182
1539
  return { candidates: [] };
1183
1540
  const raw = await page.evaluate(collectPageData);
1184
- const pageModel = mapToPageModel(raw, { url: page.url(), finalUrl: page.url(), depth: parentState.depth ?? 0, statusCode: 200 }, legacyOptions.blockedKeywords);
1185
- const modalState = pageModel.state;
1186
- if (!modalState)
1541
+ const pageModel = mapToPageModel(raw, { url: page.url(), finalUrl: page.url(), depth, statusCode: 200 }, legacyOptions.blockedKeywords);
1542
+ const collected = pageModel.state;
1543
+ if (!collected)
1187
1544
  return { candidates: [] };
1545
+ const modalState = {
1546
+ ...collected,
1547
+ parentStateId: parentState.id,
1548
+ containerSelector,
1549
+ depth,
1550
+ controls: collected.controls.filter((control) => control.context?.container === "dialog" || control.context?.containerSelector === containerSelector)
1551
+ };
1188
1552
  if (visitedStates.has(modalState.id))
1189
1553
  return { candidates: [] };
1190
1554
  visitedStates.add(modalState.id);
1191
1555
  addState(actionGraph, modalState);
1192
- debug(`State discovered: ${modalState.name} (modal)`, { stateId: modalState.id, url: page.url() });
1556
+ modalStatesDiscovered += 1;
1557
+ debug(`State discovered: ${modalState.name} (modal depth ${depth}, ${modalState.controls.length} controls)`, {
1558
+ stateId: modalState.id,
1559
+ url: page.url()
1560
+ });
1193
1561
  const modalCandidates = await discoverSafeCandidates(page, modalState);
1194
1562
  const safeCandidates = modalCandidates.filter((c) => c.action.safe).slice(0, legacyOptions.maxActionsPerState);
1195
1563
  for (const mc of safeCandidates) {
@@ -1216,13 +1584,16 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
1216
1584
  }
1217
1585
  actionGraph.visitedActionKeys.push(mc.action.id);
1218
1586
  const newRaw = await page.evaluate(collectPageData);
1219
- const newModel = mapToPageModel(newRaw, { url: page.url(), finalUrl: page.url(), depth: parentState.depth ?? 0, statusCode: 200 }, legacyOptions.blockedKeywords);
1587
+ const newModel = mapToPageModel(newRaw, { url: page.url(), finalUrl: page.url(), depth, statusCode: 200 }, legacyOptions.blockedKeywords);
1220
1588
  const newState = newModel.state;
1221
1589
  if (newState && !visitedStates.has(newState.id)) {
1222
1590
  visitedStates.add(newState.id);
1223
- addState(actionGraph, newState);
1591
+ addState(actionGraph, { ...newState, parentStateId: modalState.id, depth });
1224
1592
  addEdge(actionGraph, modalState.id, newState.id, mc.action, "visited");
1225
1593
  debug(`New state in modal: ${newState.name}`, { stateId: newState.id });
1594
+ if (newState.visibleDialogs.length > modalState.visibleDialogs.length) {
1595
+ await exploreModal(page, modalState, page.url(), entryFlow, depth + 1);
1596
+ }
1226
1597
  }
1227
1598
  }
1228
1599
  try {
@@ -1393,6 +1764,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
1393
1764
  break;
1394
1765
  actionGraph.visitedActionKeys.push(candidate.action.id);
1395
1766
  const beforeUrl = page.url();
1767
+ const actionStartedAt = Date.now();
1396
1768
  if (candidate.kind === "navigation-link" || candidate.kind === "sidebar-nav" || candidate.kind === "breadcrumb") {
1397
1769
  const href = candidate.action.target;
1398
1770
  if (href && !isWithinScope(href)) {
@@ -1410,6 +1782,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
1410
1782
  totalActionsFailed++;
1411
1783
  addEdge(actionGraph, currentState.id, void 0, candidate.action, "failed");
1412
1784
  actionGraph.failedActionKeys.push(candidate.action.id);
1785
+ recordTransition(currentState, candidate.action, { url: beforeUrl, fingerprint: currentState.fingerprint }, { url: page.url() }, "failed", Date.now() - actionStartedAt);
1413
1786
  debug(`Failed: ${candidate.action.target}`, { actionId: candidate.action.id });
1414
1787
  await restoreState(page, beforeUrl, candidate.restoreStrategy, item.entryFlow);
1415
1788
  continue;
@@ -1433,9 +1806,11 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
1433
1806
  const newRaw = await page.evaluate(collectPageData);
1434
1807
  const newModel = mapToPageModel(newRaw, { url: beforeUrl, finalUrl: afterUrl, depth: item.depth + 1, statusCode: 200 }, legacyOptions.blockedKeywords);
1435
1808
  const newState = newModel.state;
1809
+ const changed = Boolean(newState && (newState.fingerprint !== currentState.fingerprint || afterUrl !== beforeUrl));
1810
+ recordTransition(currentState, candidate.action, { url: beforeUrl, fingerprint: currentState.fingerprint }, { url: afterUrl, state: newState }, changed ? "changed" : "unchanged", Date.now() - actionStartedAt);
1436
1811
  if (newState && !visitedStates.has(newState.id)) {
1437
1812
  visitedStates.add(newState.id);
1438
- addState(actionGraph, newState);
1813
+ addState(actionGraph, { ...newState, parentStateId: currentState.id, depth: item.depth + 1 });
1439
1814
  addEdge(actionGraph, currentState.id, newState.id, candidate.action, "visited");
1440
1815
  debug(`New state: ${newState.name}`, { stateId: newState.id, url: redactUrl(afterUrl) });
1441
1816
  if (!visitedUrls.has(normalizedAfter)) {
@@ -1492,13 +1867,42 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
1492
1867
  summary,
1493
1868
  discoveryLogs: logs
1494
1869
  };
1870
+ for (const state of actionGraph.states) {
1871
+ for (const control of state.controls) {
1872
+ const elementId = coverage.discover(control, state.id);
1873
+ if (control.disabled)
1874
+ coverage.record(elementId, "disabled");
1875
+ else if (control.risk === "session-ending")
1876
+ coverage.record(elementId, "blocked-session-ending");
1877
+ else if (control.risk === "destructive")
1878
+ coverage.record(elementId, "blocked-destructive");
1879
+ else if (control.uiPattern === "unknown")
1880
+ coverage.record(elementId, "unknown-pattern");
1881
+ }
1882
+ }
1883
+ for (const edge of actionGraph.edges) {
1884
+ const state = actionGraph.states.find((candidate) => candidate.id === edge.fromStateId);
1885
+ const control = state?.controls.find((candidate) => candidate.cssSelector === edge.action.selector);
1886
+ if (!control?.elementId)
1887
+ continue;
1888
+ if (edge.status === "visited")
1889
+ coverage.record(control.elementId, "tested");
1890
+ else if (edge.status === "failed")
1891
+ coverage.record(control.elementId, "failed");
1892
+ else if (edge.status === "blocked")
1893
+ coverage.record(control.elementId, "blocked-filter", edge.action.reason);
1894
+ }
1895
+ for (let index = 0; index < modalStatesDiscovered; index++)
1896
+ coverage.countModalState();
1495
1897
  return {
1496
1898
  startUrl: entryUrl,
1497
1899
  origin,
1498
1900
  pages,
1499
1901
  issues,
1500
1902
  stats,
1501
- actionGraph
1903
+ actionGraph,
1904
+ transitions,
1905
+ coverage: coverage.report()
1502
1906
  };
1503
1907
  }
1504
1908
  function addState(graph, state) {
@@ -1508,10 +1912,10 @@ function addState(graph, state) {
1508
1912
  graph.visitedStateIds.push(state.id);
1509
1913
  }
1510
1914
  function addEdge(graph, fromStateId, toStateId, action, status) {
1511
- const id = `${fromStateId}|${action.id}|${toStateId ?? status}`;
1512
- if (graph.edges.some((edge) => edge.id === id))
1915
+ const id2 = `${fromStateId}|${action.id}|${toStateId ?? status}`;
1916
+ if (graph.edges.some((edge) => edge.id === id2))
1513
1917
  return;
1514
- graph.edges.push({ id, fromStateId, toStateId, action, status });
1918
+ graph.edges.push({ id: id2, fromStateId, toStateId, action, status });
1515
1919
  }
1516
1920
  function getEndReasonDetail(reason, config2) {
1517
1921
  switch (reason) {
@@ -1591,9 +1995,9 @@ function recorderInitScript() {
1591
1995
  return "textbox";
1592
1996
  };
1593
1997
  const labelOf2 = (element) => {
1594
- const id = element.getAttribute("id");
1595
- if (id) {
1596
- const explicit = document.querySelector(`label[for="${CSS.escape(id)}"]`);
1998
+ const id2 = element.getAttribute("id");
1999
+ if (id2) {
2000
+ const explicit = document.querySelector(`label[for="${CSS.escape(id2)}"]`);
1597
2001
  const value = clean(explicit?.textContent);
1598
2002
  if (value)
1599
2003
  return value;
@@ -1632,16 +2036,26 @@ function recorderInitScript() {
1632
2036
  }
1633
2037
  return clean(element.textContent) || void 0;
1634
2038
  };
2039
+ const TEST_ID_ATTRIBUTES = ["data-testid", "data-test-id", "data-test", "data-qa", "data-cy"];
2040
+ const testIdOf = (element) => {
2041
+ for (const attribute2 of TEST_ID_ATTRIBUTES) {
2042
+ const value = element.getAttribute(attribute2);
2043
+ if (value && value.trim())
2044
+ return { attribute: attribute2, value: value.trim() };
2045
+ }
2046
+ return void 0;
2047
+ };
2048
+ const attributeSelector2 = (name, value, tagName = "") => `${tagName}[${name}="${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"]`;
1635
2049
  const cssPath = (element) => {
1636
- const testId = element.getAttribute("data-testid") ?? element.getAttribute("data-test-id") ?? element.getAttribute("data-test");
2050
+ const testId = testIdOf(element);
1637
2051
  if (testId)
1638
- return `[data-testid="${testId}"]`;
1639
- const id = element.getAttribute("id");
1640
- if (id && !/\d{4,}/.test(id))
1641
- return `#${CSS.escape(id)}`;
2052
+ return attributeSelector2(testId.attribute, testId.value);
2053
+ const id2 = element.getAttribute("id");
2054
+ if (id2 && !/\d{4,}/.test(id2))
2055
+ return `#${CSS.escape(id2)}`;
1642
2056
  const name = element.getAttribute("name");
1643
2057
  if (name)
1644
- return `${element.tagName.toLowerCase()}[name="${CSS.escape(name)}"]`;
2058
+ return attributeSelector2("name", name, element.tagName.toLowerCase());
1645
2059
  const parts = [];
1646
2060
  let node = element;
1647
2061
  let depth = 0;
@@ -1664,6 +2078,8 @@ function recorderInitScript() {
1664
2078
  const role = roleOf(element);
1665
2079
  const name = accessibleName(element);
1666
2080
  const matches = role && name ? Array.from(document.querySelectorAll(CLICKABLE)).filter((candidate) => roleOf(candidate) === role && accessibleName(candidate)?.localeCompare(name, void 0, { sensitivity: "accent" }) === 0) : [];
2081
+ const testId = testIdOf(element);
2082
+ const elementId = element.getAttribute("id") || void 0;
1667
2083
  const target = {
1668
2084
  role,
1669
2085
  name,
@@ -1671,6 +2087,13 @@ function recorderInitScript() {
1671
2087
  text: role ? void 0 : clean(element.textContent) || void 0,
1672
2088
  label: labelOf2(element),
1673
2089
  placeholder: clean(element.getAttribute("placeholder")) || void 0,
2090
+ // Recorded verbatim so the generator can rank them without re-deriving
2091
+ // anything from the DOM it can no longer see.
2092
+ testId: testId?.value,
2093
+ testIdAttribute: testId?.attribute,
2094
+ elementId: elementId && !/\d{4,}/.test(elementId) ? elementId : void 0,
2095
+ attributeName: element.getAttribute("name") || void 0,
2096
+ tagName: element.tagName.toLowerCase(),
1674
2097
  cssSelector: cssPath(element)
1675
2098
  };
1676
2099
  return matches.length > 1 ? { ...target, matchCount: matches.length } : target;
@@ -1964,10 +2387,10 @@ function assignModules(pages) {
1964
2387
  const result = /* @__PURE__ */ new Map();
1965
2388
  const used = /* @__PURE__ */ new Map();
1966
2389
  for (const page of pages) {
1967
- const base = moduleNameFromUrl(page.finalUrl);
1968
- const count = used.get(base) ?? 0;
1969
- used.set(base, count + 1);
1970
- result.set(page.url, count === 0 ? base : `${base}-${count + 1}`);
2390
+ const base2 = moduleNameFromUrl(page.finalUrl);
2391
+ const count = used.get(base2) ?? 0;
2392
+ used.set(base2, count + 1);
2393
+ result.set(page.url, count === 0 ? base2 : `${base2}-${count + 1}`);
1971
2394
  }
1972
2395
  return result;
1973
2396
  }
@@ -1982,15 +2405,24 @@ function toTargetRef(element) {
1982
2405
  contextSelector: element.contextSelector,
1983
2406
  contextTestId: element.contextTestId
1984
2407
  } : void 0;
2408
+ const identity = defined({
2409
+ testId: element.testId,
2410
+ testIdAttribute: element.testIdAttribute,
2411
+ elementId: element.id,
2412
+ attributeName: element.name,
2413
+ tagName: element.tagName,
2414
+ cssSelector: element.cssSelector
2415
+ });
1985
2416
  if (element.accessibleName) {
1986
- return { role: element.role, name: element.accessibleName, cssSelector: element.cssSelector, ...disambiguation };
2417
+ return { role: element.role, name: element.accessibleName, ...identity, ...disambiguation };
1987
2418
  }
1988
2419
  if (element.placeholder) {
1989
- return { role: element.role, placeholder: element.placeholder, cssSelector: element.cssSelector, ...disambiguation };
2420
+ return { role: element.role, placeholder: element.placeholder, ...identity, ...disambiguation };
1990
2421
  }
1991
- if (element.testId)
1992
- return { testId: element.testId, ...disambiguation };
1993
- return { role: element.role, cssSelector: element.cssSelector, ...disambiguation };
2422
+ return { role: element.role, ...identity, ...disambiguation };
2423
+ }
2424
+ function defined(value) {
2425
+ return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0));
1994
2426
  }
1995
2427
  function labelOf(element) {
1996
2428
  return element.accessibleName || element.placeholder || element.name || element.id || element.tagName;
@@ -2095,40 +2527,6 @@ function pageStructureRule(ctx) {
2095
2527
  })
2096
2528
  ];
2097
2529
  }
2098
- function interactionRule(ctx) {
2099
- const interactions = ctx.page.state?.interactions ?? [];
2100
- return interactions.slice(0, 12).map((interaction) => {
2101
- const target = interactionTarget(interaction);
2102
- return build(ctx, {
2103
- title: (interaction.name || interaction.kind) + " interaction works",
2104
- preconditions: precondition(ctx.page),
2105
- steps: [
2106
- navigateStep(ctx.page),
2107
- { type: "click", target, description: interactionAction(interaction) },
2108
- { type: "assertVisible", target }
2109
- ],
2110
- expectedResult: interaction.kind + ' "' + (interaction.name || "control") + '" opens and is usable.',
2111
- type: "positive",
2112
- priority: "medium",
2113
- automationStatus: "needs-review",
2114
- notes: "Generated from the observed " + interaction.kind + " interaction."
2115
- });
2116
- });
2117
- }
2118
- function interactionTarget(interaction) {
2119
- return { role: interaction.role, name: interaction.name || void 0, cssSelector: interaction.cssSelector };
2120
- }
2121
- function interactionAction(interaction) {
2122
- const labels = {
2123
- dialog: "Open modal or dialog",
2124
- tab: "Select tab",
2125
- accordion: "Expand accordion",
2126
- dropdown: "Open dropdown",
2127
- drawer: "Open drawer",
2128
- popover: "Open popover"
2129
- };
2130
- return labels[interaction.kind];
2131
- }
2132
2530
  function requiredFieldRule(ctx, form) {
2133
2531
  const submit = form.submitButtons.find((button) => !button.disabled);
2134
2532
  const fields = form.fields.filter(isUsable);
@@ -2528,6 +2926,273 @@ function destructiveActionRule(ctx) {
2528
2926
  return cases;
2529
2927
  }
2530
2928
 
2929
+ // ../../packages/generators/dist/testcases/patternRules.js
2930
+ var REVIEW_EXPECTED = "Behavior requires tester review";
2931
+ function base(ctx, draft) {
2932
+ return { module: ctx.module, sourceUrl: ctx.page.finalUrl, ...draft };
2933
+ }
2934
+ function precondition2(page) {
2935
+ try {
2936
+ return [`The application is available at ${new URL(page.finalUrl).origin}`];
2937
+ } catch {
2938
+ return ["The application is available"];
2939
+ }
2940
+ }
2941
+ function navigate(page) {
2942
+ return { type: "navigate", url: page.finalUrl };
2943
+ }
2944
+ function evidenceOf(element) {
2945
+ const found = [element.patternEvidence ?? matchPattern(element).evidence];
2946
+ if (element.relation?.controls)
2947
+ found.push(`aria-controls="${element.relation.controls}"`);
2948
+ if (element.context?.containerSelector)
2949
+ found.push(`container=${element.context.containerSelector}`);
2950
+ return found;
2951
+ }
2952
+ function reviewCase(ctx, element, pattern, reason, action = []) {
2953
+ return base(ctx, {
2954
+ title: `Review ${labelOf(element)} behaviour`,
2955
+ preconditions: precondition2(ctx.page),
2956
+ steps: [navigate(ctx.page), ...action],
2957
+ expectedResult: REVIEW_EXPECTED,
2958
+ type: "manual",
2959
+ priority: "medium",
2960
+ automationStatus: "needs-review",
2961
+ tags: ["pattern:" + pattern, "needs-review"],
2962
+ pattern,
2963
+ evidence: evidenceOf(element),
2964
+ reviewReason: reason,
2965
+ notes: `Detected as ${pattern}. ${reason}`
2966
+ });
2967
+ }
2968
+ function tabRule(ctx, element) {
2969
+ const target = toTargetRef(element);
2970
+ const panel = element.relation?.controls;
2971
+ const steps = [
2972
+ navigate(ctx.page),
2973
+ { type: "click", target, description: `Select tab "${labelOf(element)}"` }
2974
+ ];
2975
+ steps.push({ type: "assertVisible", target });
2976
+ if (panel) {
2977
+ steps.push({
2978
+ type: "assertVisible",
2979
+ target: { cssSelector: `#${panel}` },
2980
+ description: `Verify the panel controlled by this tab is visible`
2981
+ });
2982
+ }
2983
+ return [
2984
+ base(ctx, {
2985
+ title: `Tab "${labelOf(element)}" selects its panel`,
2986
+ preconditions: precondition2(ctx.page),
2987
+ steps,
2988
+ expectedResult: panel ? `Tab "${labelOf(element)}" becomes selected and the panel it controls is visible.` : `Tab "${labelOf(element)}" becomes selected.`,
2989
+ type: "interaction",
2990
+ priority: "medium",
2991
+ automationStatus: panel ? "ready" : "needs-review",
2992
+ tags: ["pattern:tab"],
2993
+ pattern: "tab",
2994
+ evidence: evidenceOf(element),
2995
+ ...panel ? {} : { reviewReason: "No aria-controls, so the panel to assert is unknown." },
2996
+ notes: 'Generated from role="tab". Assertion uses the tab contract, not the label text.'
2997
+ })
2998
+ ];
2999
+ }
3000
+ function accordionRule(ctx, element) {
3001
+ const target = toTargetRef(element);
3002
+ const region = element.relation?.controls;
3003
+ return [
3004
+ base(ctx, {
3005
+ title: `${labelOf(element)} expands and collapses`,
3006
+ preconditions: precondition2(ctx.page),
3007
+ steps: [
3008
+ navigate(ctx.page),
3009
+ { type: "click", target, description: `Expand "${labelOf(element)}"` },
3010
+ ...region ? [
3011
+ {
3012
+ type: "assertVisible",
3013
+ target: { cssSelector: `#${region}` },
3014
+ description: "Verify the controlled region is visible"
3015
+ }
3016
+ ] : [],
3017
+ { type: "click", target, description: `Collapse "${labelOf(element)}"` }
3018
+ ],
3019
+ expectedResult: region ? `The region controlled by "${labelOf(element)}" becomes visible when expanded and hidden when collapsed.` : `"${labelOf(element)}" toggles between expanded and collapsed.`,
3020
+ type: "interaction",
3021
+ priority: "medium",
3022
+ automationStatus: region ? "ready" : "needs-review",
3023
+ tags: ["pattern:accordion"],
3024
+ pattern: "accordion",
3025
+ evidence: evidenceOf(element),
3026
+ ...region ? {} : { reviewReason: "No aria-controls, so the region to assert is unknown." },
3027
+ notes: "Generated from the aria-expanded / <summary> contract."
3028
+ })
3029
+ ];
3030
+ }
3031
+ function toggleRule(ctx, element, pattern) {
3032
+ const target = toTargetRef(element);
3033
+ const isRadio = pattern === "radio";
3034
+ return [
3035
+ base(ctx, {
3036
+ title: isRadio ? `${labelOf(element)} can be selected` : `${labelOf(element)} can be checked and unchecked`,
3037
+ preconditions: precondition2(ctx.page),
3038
+ steps: [
3039
+ navigate(ctx.page),
3040
+ { type: "check", target, checked: true, description: `Select "${labelOf(element)}"` },
3041
+ ...isRadio ? [] : [{ type: "check", target, checked: false }]
3042
+ ],
3043
+ expectedResult: isRadio ? `"${labelOf(element)}" becomes the selected option.` : `"${labelOf(element)}" reports checked after selecting and unchecked after clearing.`,
3044
+ type: "interaction",
3045
+ priority: "medium",
3046
+ automationStatus: "ready",
3047
+ tags: ["pattern:" + pattern],
3048
+ pattern,
3049
+ evidence: evidenceOf(element),
3050
+ notes: "Assertion uses the native checked state, not the surrounding text."
3051
+ })
3052
+ ];
3053
+ }
3054
+ function selectRule(ctx, element) {
3055
+ const options = (element.options ?? []).filter(Boolean).slice(0, 2);
3056
+ if (options.length === 0) {
3057
+ return [reviewCase(ctx, element, "select", "No options were present when the page was collected.")];
3058
+ }
3059
+ const target = toTargetRef(element);
3060
+ return options.map((option) => base(ctx, {
3061
+ title: `${labelOf(element)} accepts option "${option}"`,
3062
+ preconditions: precondition2(ctx.page),
3063
+ steps: [navigate(ctx.page), { type: "select", target, option }],
3064
+ expectedResult: `"${labelOf(element)}" holds the selected option "${option}".`,
3065
+ type: "interaction",
3066
+ priority: "medium",
3067
+ automationStatus: "ready",
3068
+ tags: ["pattern:select"],
3069
+ pattern: "select",
3070
+ evidence: [...evidenceOf(element), `option="${option}"`],
3071
+ notes: "Options were read from the page; none were invented."
3072
+ }));
3073
+ }
3074
+ function openerRule(ctx, element, pattern) {
3075
+ const container = element.relation?.controls ?? element.relation?.target;
3076
+ const target = toTargetRef(element);
3077
+ if (!container) {
3078
+ return [
3079
+ reviewCase(ctx, element, pattern, "The container it opens is not declared through aria-controls or data-target.", [{ type: "click", target, description: `Open "${labelOf(element)}"` }])
3080
+ ];
3081
+ }
3082
+ const containerSelector = container.startsWith("#") || container.startsWith(".") ? container : `#${container}`;
3083
+ return [
3084
+ base(ctx, {
3085
+ title: `${labelOf(element)} opens its ${pattern === "dialog-opener" ? "dialog" : "menu"}`,
3086
+ preconditions: precondition2(ctx.page),
3087
+ steps: [
3088
+ navigate(ctx.page),
3089
+ { type: "click", target, description: `Open "${labelOf(element)}"` },
3090
+ { type: "assertVisible", target: { cssSelector: containerSelector } }
3091
+ ],
3092
+ expectedResult: `The container ${containerSelector} becomes visible.`,
3093
+ type: "interaction",
3094
+ priority: "medium",
3095
+ automationStatus: "ready",
3096
+ tags: ["pattern:" + pattern],
3097
+ pattern,
3098
+ evidence: evidenceOf(element),
3099
+ notes: "The opener is bound to its container through a declared relationship."
3100
+ })
3101
+ ];
3102
+ }
3103
+ function reviewOnlyRule(ctx, element, pattern) {
3104
+ const reasons = {
3105
+ combobox: "Custom combobox keyboard and filtering behaviour cannot be derived from markup.",
3106
+ slider: "The value range and step semantics need a tester to confirm.",
3107
+ "file-upload": "Uploading a file needs a fixture chosen by a tester.",
3108
+ table: "Sort, filter and row semantics need a tester to confirm.",
3109
+ menu: "Menu contents are only known once the menu has been opened.",
3110
+ button: "No observable state change was recorded for this control.",
3111
+ unknown: "The element declares no catalogued role, type or ARIA relationship."
3112
+ };
3113
+ return [
3114
+ reviewCase(ctx, element, pattern, reasons[pattern] ?? "This pattern has no provable contract in the DOM.", [
3115
+ { type: "click", target: toTargetRef(element), description: `Interact with "${labelOf(element)}"` }
3116
+ ])
3117
+ ];
3118
+ }
3119
+ function blockedActionRule(ctx, element, pattern) {
3120
+ const risk = element.risk === "session-ending" ? "session-ending" : "destructive";
3121
+ return [
3122
+ base(ctx, {
3123
+ title: `Manually verify ${labelOf(element)}`,
3124
+ preconditions: [...precondition2(ctx.page), "Use a disposable test account and data"],
3125
+ steps: [
3126
+ navigate(ctx.page),
3127
+ {
3128
+ type: "manual",
3129
+ description: `Manually trigger "${labelOf(element)}" in a safe test environment and record the result`
3130
+ }
3131
+ ],
3132
+ expectedResult: REVIEW_EXPECTED,
3133
+ type: "manual",
3134
+ priority: "high",
3135
+ automationStatus: "manual",
3136
+ tags: ["pattern:" + pattern, risk],
3137
+ pattern,
3138
+ evidence: evidenceOf(element),
3139
+ reviewReason: `Classified as ${risk}, so LazyScout did not execute it.`,
3140
+ notes: `LazyScout detected a ${risk} action and skipped it deliberately.`
3141
+ })
3142
+ ];
3143
+ }
3144
+ function elementPatternCases(ctx, element) {
3145
+ const pattern = element.uiPattern ?? matchPattern(element).pattern;
3146
+ if (element.disabled)
3147
+ return [];
3148
+ if (element.risk === "destructive" || element.risk === "session-ending") {
3149
+ return blockedActionRule(ctx, element, pattern);
3150
+ }
3151
+ switch (pattern) {
3152
+ case "tab":
3153
+ return tabRule(ctx, element);
3154
+ case "accordion":
3155
+ return accordionRule(ctx, element);
3156
+ case "checkbox":
3157
+ case "radio":
3158
+ case "switch":
3159
+ return toggleRule(ctx, element, pattern);
3160
+ case "select":
3161
+ return selectRule(ctx, element);
3162
+ case "dialog-opener":
3163
+ return openerRule(ctx, element, pattern);
3164
+ case "menu":
3165
+ return element.relation?.controls ? openerRule(ctx, element, pattern) : reviewOnlyRule(ctx, element, pattern);
3166
+ case "combobox":
3167
+ case "slider":
3168
+ case "file-upload":
3169
+ case "table":
3170
+ case "button":
3171
+ case "unknown":
3172
+ return reviewOnlyRule(ctx, element, pattern);
3173
+ default:
3174
+ return [];
3175
+ }
3176
+ }
3177
+ function interactionPatternCases(ctx, interaction) {
3178
+ const pattern = interaction.kind === "tab" ? "tab" : interaction.kind === "accordion" ? "accordion" : interaction.kind === "dropdown" ? "menu" : "dialog-opener";
3179
+ const element = {
3180
+ kind: "button",
3181
+ role: interaction.role,
3182
+ accessibleName: interaction.name,
3183
+ tagName: "button",
3184
+ cssSelector: interaction.cssSelector,
3185
+ required: false,
3186
+ disabled: false,
3187
+ destructive: false,
3188
+ uiPattern: pattern,
3189
+ patternEvidence: interaction.evidence,
3190
+ expanded: interaction.expanded,
3191
+ relation: interaction.controlsSelector ? { controls: interaction.controlsSelector.replace(/^#/, "") } : void 0
3192
+ };
3193
+ return elementPatternCases(ctx, element);
3194
+ }
3195
+
2531
3196
  // ../../packages/generators/dist/testcases/generateTestCases.js
2532
3197
  var DEFAULT_GENERATE_OPTIONS = {
2533
3198
  maxTestCasesPerPage: 120,
@@ -2546,16 +3211,16 @@ function generateTestCases(pages, options = {}) {
2546
3211
  for (const page of pages) {
2547
3212
  const module = moduleByUrl.get(page.url) ?? "PAGE";
2548
3213
  const context = { page, module, visitedTitles };
2549
- const fromPage = [
3214
+ const fromPage = dedupe([
2550
3215
  ...pageStructureRule(context),
2551
3216
  ...page.forms.flatMap((form) => requiredFieldRule(context, form)),
2552
3217
  ...page.forms.flatMap((form) => validationMatrixRule(context, form)),
2553
3218
  ...page.forms.flatMap((form) => loginFailureRule(context, form)),
2554
3219
  ...page.forms.flatMap((form) => formSubmitRule(context, form)),
2555
- ...interactionRule(context),
3220
+ ...patternCases(context),
2556
3221
  ...navigationRule(context),
2557
3222
  ...destructiveActionRule(context)
2558
- ].slice(0, config2.maxTestCasesPerPage);
3223
+ ], counters).slice(0, config2.maxTestCasesPerPage);
2559
3224
  for (const generated of fromPage) {
2560
3225
  const sequence = (counters.get(module) ?? 0) + 1;
2561
3226
  counters.set(module, sequence);
@@ -2564,6 +3229,30 @@ function generateTestCases(pages, options = {}) {
2564
3229
  }
2565
3230
  return config2.language === "en" ? testCases : localizeThai(testCases);
2566
3231
  }
3232
+ function patternCases(context) {
3233
+ const ctx = { page: context.page, module: context.module };
3234
+ const controls = context.page.state?.controls ?? [];
3235
+ const cases = controls.flatMap((control) => elementPatternCases(ctx, control));
3236
+ const covered = new Set(controls.map((control) => control.cssSelector));
3237
+ const fromInteractions = (context.page.state?.interactions ?? []).filter((interaction) => !covered.has(interaction.cssSelector)).flatMap((interaction) => interactionPatternCases(ctx, interaction));
3238
+ return [...cases, ...fromInteractions];
3239
+ }
3240
+ function dedupe(cases, counters) {
3241
+ const seen = /* @__PURE__ */ new Set();
3242
+ const unique = [];
3243
+ let dropped = 0;
3244
+ for (const testCase of cases) {
3245
+ const key = `${testCase.pattern ?? testCase.type}|${testCase.title}|${JSON.stringify(testCase.steps)}`;
3246
+ if (seen.has(key)) {
3247
+ dropped += 1;
3248
+ continue;
3249
+ }
3250
+ seen.add(key);
3251
+ unique.push(testCase);
3252
+ }
3253
+ counters.set("__deduplicated", (counters.get("__deduplicated") ?? 0) + dropped);
3254
+ return unique;
3255
+ }
2567
3256
  function localizeThai(testCases) {
2568
3257
  return testCases.map((testCase) => ({
2569
3258
  ...testCase,
@@ -2762,6 +3451,63 @@ function exportTestCasesToCsv(testCases, testData = []) {
2762
3451
  return UTF8_BOM + lines.join("\r\n") + "\r\n";
2763
3452
  }
2764
3453
 
3454
+ // ../../packages/generators/dist/locators/candidates.js
3455
+ var GENERATED_ATTRIBUTE = /\bdata-v-[0-9a-f]{6,}\b/i;
3456
+ var GENERATED_ID = /\d{4,}/;
3457
+ var DEFAULT_TEST_ID_ATTRIBUTE = "data-testid";
3458
+ function buildLocatorCandidates(target) {
3459
+ const candidates = [];
3460
+ const push = (kind, expression) => {
3461
+ if (!expression || GENERATED_ATTRIBUTE.test(expression))
3462
+ return;
3463
+ if (candidates.some(([, existing]) => existing === expression))
3464
+ return;
3465
+ candidates.push([kind, expression]);
3466
+ };
3467
+ push(...testIdCandidate(target));
3468
+ push("id", target.elementId && !GENERATED_ID.test(target.elementId) ? cssLocator(id(target.elementId)) : void 0);
3469
+ push("semantic locator", semanticCandidate(target));
3470
+ push("name", target.attributeName ? cssLocator(attribute("name", target.attributeName, target.tagName)) : void 0);
3471
+ push("recorded CSS", target.cssSelector ? cssLocator(normalizeCssSelector(target.cssSelector)) : void 0);
3472
+ if (candidates.length === 0)
3473
+ push("recorded CSS", cssLocator(normalizeCssSelector(target.cssSelector ?? "")));
3474
+ return candidates;
3475
+ }
3476
+ function testIdCandidate(target) {
3477
+ if (!target.testId)
3478
+ return ["test id", void 0];
3479
+ const attributeName = target.testIdAttribute ?? DEFAULT_TEST_ID_ATTRIBUTE;
3480
+ return attributeName === DEFAULT_TEST_ID_ATTRIBUTE ? ["test id", `page.getByTestId(${quote(target.testId)})`] : [attributeName, cssLocator(attribute(attributeName, target.testId))];
3481
+ }
3482
+ function semanticCandidate(target) {
3483
+ const base2 = target.role && target.name ? `page.getByRole(${quote(target.role)}, { name: ${quote(target.name)}, exact: true })` : target.label ? `page.getByLabel(${quote(target.label)}, { exact: true })` : target.placeholder ? `page.getByPlaceholder(${quote(target.placeholder)})` : target.text ? `page.getByText(${quote(target.text)})` : void 0;
3484
+ if (!base2)
3485
+ return void 0;
3486
+ const context = target.contextTestId ? `page.getByTestId(${quote(target.contextTestId)})` : target.contextSelector ? `page.locator(${quote(target.contextSelector)})` : void 0;
3487
+ const scoped = context ? target.contextText ? `${context}.filter({ hasText: ${quote(target.contextText)} }).${base2.slice(5)}` : `${context}.${base2.slice(5)}` : base2;
3488
+ return target.nth === void 0 ? scoped : `${scoped}.nth(${target.nth})`;
3489
+ }
3490
+ function describeTarget2(target) {
3491
+ return target.name ?? target.label ?? target.placeholder ?? target.text ?? target.testId ?? target.elementId ?? target.attributeName ?? target.cssSelector ?? "target";
3492
+ }
3493
+ function attribute(name, value, tagName) {
3494
+ const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
3495
+ return `${tagName ? tagName.toLowerCase() : ""}[${name}="${escaped}"]`;
3496
+ }
3497
+ function id(value) {
3498
+ return `#${value.replace(/[^\w-]/g, (character) => `\\${character}`)}`;
3499
+ }
3500
+ function cssLocator(selector) {
3501
+ return `page.locator(${quoteCssSelector(selector)})`;
3502
+ }
3503
+ function normalizeCssSelector(value) {
3504
+ return value.replace(/\\(["'])/g, "$1");
3505
+ }
3506
+ function quoteCssSelector(value) {
3507
+ return `'${value.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
3508
+ }
3509
+ var quote = (value) => JSON.stringify(value);
3510
+
2765
3511
  // ../../packages/generators/dist/playwright/generatePlaywrightTest.js
2766
3512
  function generatePlaywrightTest(testCase) {
2767
3513
  const lines = [
@@ -2769,75 +3515,87 @@ function generatePlaywrightTest(testCase) {
2769
3515
  "",
2770
3516
  ...locatorResolverSource(),
2771
3517
  "",
2772
- `test(${quote(testCase.title)}, async ({ page }) => {`
3518
+ `test(${quote2(testCase.title)}, async ({ page }) => {`
2773
3519
  ];
2774
3520
  for (const step of testCase.steps)
2775
3521
  lines.push(` ${playwrightStep(step)}`);
2776
3522
  lines.push("})", "");
2777
3523
  return lines.join("\n");
2778
3524
  }
3525
+ var RESOLVE_TIMEOUT_MS = 5e3;
3526
+ var RESOLVE_POLL_MS = 100;
2779
3527
  function locatorResolverSource() {
2780
3528
  return [
2781
- `async function resolveTarget(candidates, description) {`,
2782
- ` const attempts = []`,
2783
- ` for (const [kind, candidate] of candidates) {`,
2784
- ` const count = await candidate.count()`,
2785
- ` if (count !== 1) {`,
2786
- ` attempts.push(kind + ': ' + count + ' matches')`,
2787
- ` continue`,
2788
- ` }`,
2789
- ` if (!(await candidate.isVisible().catch(() => false))) {`,
2790
- ` attempts.push(kind + ': not visible')`,
2791
- ` continue`,
3529
+ `async function resolveTarget(page, candidates, description, timeout = ${RESOLVE_TIMEOUT_MS}) {`,
3530
+ ` const startedAt = Date.now()`,
3531
+ ` let attempts = []`,
3532
+ ` do {`,
3533
+ ` attempts = []`,
3534
+ ` for (const [kind, candidate] of candidates) {`,
3535
+ ` try {`,
3536
+ ` const count = await candidate.count()`,
3537
+ ` if (count !== 1) {`,
3538
+ ` attempts.push('- ' + kind + ': ' + count + ' matches')`,
3539
+ ` continue`,
3540
+ ` }`,
3541
+ ` if (!(await candidate.isVisible())) {`,
3542
+ ` attempts.push('- ' + kind + ': matched but not visible')`,
3543
+ ` continue`,
3544
+ ` }`,
3545
+ ` console.log('[Locator] ' + description + ' -> ' + kind + ' (' + (Date.now() - startedAt) + 'ms)')`,
3546
+ ` return candidate`,
3547
+ ` } catch (error) {`,
3548
+ ` attempts.push('- ' + kind + ': ' + (error instanceof Error ? error.message : String(error)))`,
3549
+ ` }`,
2792
3550
  ` }`,
2793
- ` console.log('[Locator] ' + description + ' -> ' + kind)`,
2794
- ` return candidate`,
2795
- ` }`,
2796
- ` throw new Error('Could not continue at "' + description + '" because the element was not found as one visible, unique target. The page may have changed or an earlier step may have opened a different page. Technical details: ' + attempts.join('; '))`,
3551
+ ` await page.waitForTimeout(${RESOLVE_POLL_MS})`,
3552
+ ` } while (Date.now() - startedAt < timeout)`,
3553
+ ``,
3554
+ ` const diagnostics = await page`,
3555
+ ` .evaluate(() => ({ readyState: document.readyState, title: document.title }))`,
3556
+ ` .catch(() => ({ readyState: 'unknown', title: 'unknown' }))`,
3557
+ ` throw new Error(`,
3558
+ ` 'Could not resolve "' + description + '" after ' + (Date.now() - startedAt) + 'ms.\\n' +`,
3559
+ ` 'URL: ' + page.url() + '\\n' +`,
3560
+ ` 'Page title: ' + diagnostics.title + '\\n' +`,
3561
+ ` 'document.readyState: ' + diagnostics.readyState + '\\n' +`,
3562
+ ` 'Candidates:\\n' + attempts.join('\\n')`,
3563
+ ` )`,
2797
3564
  `}`
2798
3565
  ];
2799
3566
  }
2800
3567
  function locator(target) {
2801
- const semantic = target.role && target.name ? `page.getByRole(${quote(target.role)}, { name: ${quote(target.name)}, exact: true })` : target.label ? `page.getByLabel(${quote(target.label)}, { exact: true })` : target.testId ? `page.getByTestId(${quote(target.testId)})` : target.placeholder ? `page.getByPlaceholder(${quote(target.placeholder)})` : target.text ? `page.getByText(${quote(target.text)})` : `page.locator(${quoteCssSelector(normalizeCssSelector(target.cssSelector ?? ""))})`;
2802
- const context = target.contextTestId ? `page.getByTestId(${quote(target.contextTestId)})` : target.contextSelector ? `page.locator(${quote(target.contextSelector)})` : void 0;
2803
- const scopedSemantic = context ? target.contextText ? `${context}.filter({ hasText: ${quote(target.contextText)} }).${semantic.slice(5)}` : `${context}.${semantic.slice(5)}` : semantic;
2804
- const primary = target.nth === void 0 ? scopedSemantic : `${scopedSemantic}.nth(${target.nth})`;
2805
- const css = target.cssSelector ? `page.locator(${quoteCssSelector(normalizeCssSelector(target.cssSelector))})` : void 0;
2806
- const candidates = [];
2807
- if (target.strategy === "css" && css)
2808
- candidates.push(["recorded CSS", css]);
2809
- candidates.push(["semantic locator", primary]);
2810
- if (css && !candidates.some(([, value]) => value === css))
2811
- candidates.push(["recorded CSS", css]);
2812
- const description = target.name ?? target.label ?? target.placeholder ?? target.text ?? target.cssSelector ?? "target";
2813
- return `resolveTarget([${candidates.map(([kind, value]) => `[${quote(kind)}, ${value}]`).join(", ")}], ${quote(description)})`;
3568
+ const candidates = buildLocatorCandidates(target);
3569
+ const ordered = target.strategy === "css" ? [...candidates].sort(([left], [right]) => left === "recorded CSS" ? -1 : right === "recorded CSS" ? 1 : 0) : candidates;
3570
+ const list = ordered.map(([kind, value]) => `[${quote2(kind)}, ${value}]`).join(", ");
3571
+ return `resolveTarget(page, [${list}], ${quote2(describeTarget2(target))})`;
2814
3572
  }
2815
3573
  function playwrightStep(step) {
2816
3574
  switch (step.type) {
2817
3575
  case "navigate":
2818
- return `await page.goto(${quote(step.url)})`;
3576
+ return `await page.goto(${quote2(plainUrl(step.url))})`;
2819
3577
  case "click":
2820
3578
  return `await (await ${locator(step.target)}).click()`;
2821
3579
  case "fill":
2822
- return `await (await ${locator(step.target)}).fill(${quote(step.value)})`;
3580
+ return `await (await ${locator(step.target)}).fill(${quote2(step.value)})`;
2823
3581
  case "select":
2824
- return `await (await ${locator(step.target)}).selectOption(${quote(step.option)})`;
3582
+ return `await (await ${locator(step.target)}).selectOption(${quote2(step.option)})`;
2825
3583
  case "check":
2826
3584
  return `await (await ${locator(step.target)}).${step.checked ? "check" : "uncheck"}()`;
2827
3585
  case "wait":
2828
3586
  if (step.mode === "timeout")
2829
3587
  return `await page.waitForTimeout(${Math.min(5e3, Math.max(0, Number(step.value) || 0))})`;
2830
3588
  if (step.mode === "url")
2831
- return `await page.waitForURL(new RegExp(${quote(step.value)}))`;
3589
+ return `await page.waitForURL(new RegExp(${quote2(step.value)}))`;
2832
3590
  if (step.mode === "text")
2833
- return `await expect(page).toContainText(${quote(step.value)})`;
3591
+ return `await expect(page).toContainText(${quote2(step.value)})`;
2834
3592
  return `await expect(await ${locator(step.target)}).toBeVisible()`;
2835
3593
  case "assertVisible":
2836
3594
  return `await expect(await ${locator(step.target)}).toBeVisible()`;
2837
3595
  case "assertText":
2838
- return step.target ? `await expect(await ${locator(step.target)}).toContainText(${quote(step.text)})` : `await expect(page.locator('body')).toContainText(${quote(step.text)})`;
3596
+ return step.target ? `await expect(await ${locator(step.target)}).toContainText(${quote2(step.text)})` : `await expect(page.locator('body')).toContainText(${quote2(step.text)})`;
2839
3597
  case "assertUrl":
2840
- return `await expect(page).toHaveURL(new RegExp(${quote(step.urlContains)}))`;
3598
+ return `await expect(page).toHaveURL(new RegExp(${quote2(step.urlContains)}))`;
2841
3599
  case "assertInvalid":
2842
3600
  return `expect(await (await ${locator(step.target)}).evaluate((element) => element.matches(':invalid'))).toBe(true)`;
2843
3601
  case "assertValidation":
@@ -2846,12 +3604,10 @@ function playwrightStep(step) {
2846
3604
  return `// TODO: ${step.description}`;
2847
3605
  }
2848
3606
  }
2849
- var quote = (value) => JSON.stringify(value);
2850
- function normalizeCssSelector(value) {
2851
- return value.replace(/\\(["'])/g, "$1");
2852
- }
2853
- function quoteCssSelector(value) {
2854
- return `'${value.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
3607
+ var quote2 = (value) => JSON.stringify(value);
3608
+ function plainUrl(value) {
3609
+ const markdownLink = /^\s*\[([^\]]+)\]\(\s*([^)\s]+)\s*\)\s*$/.exec(value);
3610
+ return markdownLink ? markdownLink[2] : value.trim();
2855
3611
  }
2856
3612
 
2857
3613
  // ../../packages/generators/dist/guidedflow/flowToTestCase.js
@@ -2951,8 +3707,10 @@ function locator2(target) {
2951
3707
  return `page.getByLabel(${JSON.stringify(target.label ?? target.value ?? "")}, { exact: true })`;
2952
3708
  if (target.strategy === "placeholder" || target.placeholder)
2953
3709
  return `page.getByPlaceholder(${JSON.stringify(target.placeholder ?? target.value ?? "")})`;
2954
- if (target.strategy === "testid" || target.testId)
2955
- return `page.getByTestId(${JSON.stringify(target.testId ?? target.value ?? "")})`;
3710
+ if (target.strategy === "testid" || target.testId) {
3711
+ const testId = target.testId ?? target.value ?? "";
3712
+ return target.testIdAttribute && target.testIdAttribute !== "data-testid" ? `page.locator(${quoteCssSelector2(attributeSelector(target.testIdAttribute, testId))})` : `page.getByTestId(${JSON.stringify(testId)})`;
3713
+ }
2956
3714
  if (target.strategy === "text" || target.text)
2957
3715
  return `page.getByText(${JSON.stringify(target.text ?? target.value ?? "")})`;
2958
3716
  return `page.locator(${quoteCssSelector2(normalizeCssSelector2(target.cssSelector ?? target.value ?? ""))})`;
@@ -2960,6 +3718,9 @@ function locator2(target) {
2960
3718
  function preferStableCss(target) {
2961
3719
  return Boolean(target.cssSelector && (target.strategy === "css" || target.matchCount !== void 0 && target.matchCount > 1 && !target.contextSelector && !target.contextText));
2962
3720
  }
3721
+ function attributeSelector(name, value) {
3722
+ return `[${name}="${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"]`;
3723
+ }
2963
3724
  function normalizeCssSelector2(value) {
2964
3725
  return value.replace(/\\(["'])/g, "$1");
2965
3726
  }
@@ -3395,7 +4156,10 @@ function normalizeResult(value) {
3395
4156
  blockedActionKeys: Array.isArray(actionGraph?.blockedActionKeys) ? actionGraph.blockedActionKeys : []
3396
4157
  },
3397
4158
  runEvents: Array.isArray(value?.runEvents) ? value.runEvents : [],
3398
- apiChecks: Array.isArray(value?.apiChecks) ? value.apiChecks : []
4159
+ apiChecks: Array.isArray(value?.apiChecks) ? value.apiChecks : [],
4160
+ // Optional, so a Project saved before pattern coverage existed still loads.
4161
+ ...value?.coverage ? { coverage: value.coverage } : {},
4162
+ ...Array.isArray(value?.transitions) ? { transitions: value.transitions } : {}
3399
4163
  };
3400
4164
  }
3401
4165
  function enqueueMutation(key, action) {
@@ -3525,7 +4289,9 @@ function registerAnalyzeRoute(app, workspaceRoot) {
3525
4289
  stats: result.stats,
3526
4290
  actionGraph: result.actionGraph,
3527
4291
  runEvents,
3528
- apiChecks: body.includeApiChecks ? buildApiChecks(result.pages) : []
4292
+ apiChecks: body.includeApiChecks ? buildApiChecks(result.pages) : [],
4293
+ ...result.coverage ? { coverage: { ...result.coverage, casesGenerated: testCases.length } } : {},
4294
+ ...result.transitions ? { transitions: result.transitions } : {}
3529
4295
  };
3530
4296
  completed = true;
3531
4297
  return reply.send(response);
@@ -3547,11 +4313,11 @@ function generateStateFlowTestCases(graph) {
3547
4313
  if (!target || !source)
3548
4314
  return [];
3549
4315
  const observation = expectedObservation(target);
3550
- const id = `TC-FLOW-${String(sequence).padStart(3, "0")}`;
4316
+ const id2 = `TC-FLOW-${String(sequence).padStart(3, "0")}`;
3551
4317
  sequence += 1;
3552
4318
  return [
3553
4319
  {
3554
- id,
4320
+ id: id2,
3555
4321
  module: "FLOW",
3556
4322
  tags: ["state-flow"],
3557
4323
  title: `${edge.action.description} reaches ${target.name}`,
@@ -4033,7 +4799,7 @@ function registerLoadTestRoute(app) {
4033
4799
  const started = Date.now();
4034
4800
  async function worker(virtualUser) {
4035
4801
  for (let count = 0; count < requestsPerUser; count++) {
4036
- const id = ++requestSequence;
4802
+ const id2 = ++requestSequence;
4037
4803
  const requestStarted = Date.now();
4038
4804
  try {
4039
4805
  const response2 = await fetch(url, { signal: AbortSignal.timeout(15e3), redirect: "follow" });
@@ -4043,7 +4809,7 @@ function registerLoadTestRoute(app) {
4043
4809
  if (!response2.ok)
4044
4810
  errors.push(`HTTP ${response2.status} ${response2.statusText}`.trim());
4045
4811
  requests.push({
4046
- id,
4812
+ id: id2,
4047
4813
  virtualUser,
4048
4814
  iteration: count + 1,
4049
4815
  method: "GET",
@@ -4061,7 +4827,7 @@ function registerLoadTestRoute(app) {
4061
4827
  timings.push(durationMs);
4062
4828
  errors.push(message);
4063
4829
  requests.push({
4064
- id,
4830
+ id: id2,
4065
4831
  virtualUser,
4066
4832
  iteration: count + 1,
4067
4833
  method: "GET",
@@ -4753,7 +5519,7 @@ async function openInBrowser(url) {
4753
5519
  }
4754
5520
 
4755
5521
  // src/version.ts
4756
- var VERSION = true ? "0.4.1" : "0.0.0-dev";
5522
+ var VERSION = true ? "0.4.2" : "0.0.0-dev";
4757
5523
 
4758
5524
  // src/commands/serve.ts
4759
5525
  var DEFAULT_PORT = 4321;