lazyscout 0.3.11 → 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/README.md +4 -2
- package/dist/index.js +1470 -155
- package/dist/web/assets/index-DMf3DZ4t.js +58 -0
- package/dist/web/assets/index-Dj24yU11.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-BlO66Lgr.css +0 -1
- package/dist/web/assets/index-CqjtbfVm.js +0 -58
package/dist/index.js
CHANGED
|
@@ -244,21 +244,9 @@ function redactUrl(value) {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
// ../../packages/core/dist/safety/blocklist.js
|
|
247
|
-
var SESSION_ENDING_KEYWORDS = [
|
|
248
|
-
"log out",
|
|
249
|
-
"logout",
|
|
250
|
-
"log out",
|
|
251
|
-
"sign out",
|
|
252
|
-
"signout",
|
|
253
|
-
"sign out",
|
|
254
|
-
"\u0E2D\u0E2D\u0E01\u0E08\u0E32\u0E01\u0E23\u0E30\u0E1A\u0E1A",
|
|
255
|
-
"\u0E2D\u0E2D\u0E01\u0E08\u0E32\u0E01\u0E23\u0E30\u0E1A\u0E1A"
|
|
256
|
-
];
|
|
257
247
|
function isSessionEndingLabel(...labels) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return false;
|
|
261
|
-
return SESSION_ENDING_KEYWORDS.some((keyword) => haystack.includes(keyword.toLowerCase()));
|
|
248
|
+
void labels;
|
|
249
|
+
return false;
|
|
262
250
|
}
|
|
263
251
|
function isUnsafeAutoClick(...labels) {
|
|
264
252
|
return isSessionEndingLabel(...labels);
|
|
@@ -280,6 +268,222 @@ function isBlockedLabel(keywords, ...labels) {
|
|
|
280
268
|
return keywords.some((keyword) => keyword && haystack.includes(keyword.toLowerCase()));
|
|
281
269
|
}
|
|
282
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
|
+
|
|
283
487
|
// ../../packages/core/dist/testcase/describeStep.js
|
|
284
488
|
function describeTarget(target) {
|
|
285
489
|
const name = target.name || target.label || target.text || target.placeholder;
|
|
@@ -313,6 +517,10 @@ function describeStep(step) {
|
|
|
313
517
|
return step.target ? `Verify that ${describeTarget(step.target)} shows "${step.text}"` : `Verify that the page shows "${step.text}"`;
|
|
314
518
|
case "assertUrl":
|
|
315
519
|
return `Verify that the URL contains "${step.urlContains}"`;
|
|
520
|
+
case "assertInvalid":
|
|
521
|
+
return `Verify that ${describeTarget(step.target)} is invalid and the form remains open`;
|
|
522
|
+
case "assertValidation":
|
|
523
|
+
return "Wait for a visible validation or error message";
|
|
316
524
|
case "manual":
|
|
317
525
|
return step.description;
|
|
318
526
|
}
|
|
@@ -345,7 +553,7 @@ function collectPageData() {
|
|
|
345
553
|
return ariaLabel;
|
|
346
554
|
const labelledBy = el.getAttribute("aria-labelledby");
|
|
347
555
|
if (labelledBy) {
|
|
348
|
-
const text = labelledBy.split(/\s+/).map((
|
|
556
|
+
const text = labelledBy.split(/\s+/).map((id2) => cleanText(document.getElementById(id2)?.textContent)).filter(Boolean).join(" ");
|
|
349
557
|
if (text)
|
|
350
558
|
return text;
|
|
351
559
|
}
|
|
@@ -406,6 +614,50 @@ function collectPageData() {
|
|
|
406
614
|
}
|
|
407
615
|
return parts.join(" > ");
|
|
408
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
|
+
}
|
|
409
661
|
function inputRole(input) {
|
|
410
662
|
switch (input.type) {
|
|
411
663
|
case "checkbox":
|
|
@@ -458,12 +710,34 @@ function collectPageData() {
|
|
|
458
710
|
inputType,
|
|
459
711
|
placeholder: attr(el, "placeholder"),
|
|
460
712
|
name: attr(el, "name"),
|
|
461
|
-
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,
|
|
462
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),
|
|
463
730
|
href: el instanceof HTMLAnchorElement ? el.href : void 0,
|
|
464
731
|
options,
|
|
465
732
|
required,
|
|
466
733
|
disabled,
|
|
734
|
+
minLength: el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement ? el.minLength >= 0 ? el.minLength : void 0 : void 0,
|
|
735
|
+
maxLength: el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement ? el.maxLength >= 0 ? el.maxLength : void 0 : void 0,
|
|
736
|
+
min: el instanceof HTMLInputElement ? attr(el, "min") : void 0,
|
|
737
|
+
max: el instanceof HTMLInputElement ? attr(el, "max") : void 0,
|
|
738
|
+
step: el instanceof HTMLInputElement ? attr(el, "step") : void 0,
|
|
739
|
+
pattern: el instanceof HTMLInputElement ? attr(el, "pattern") : void 0,
|
|
740
|
+
autocomplete: attr(el, "autocomplete"),
|
|
467
741
|
cssSelector: cssSelector(el),
|
|
468
742
|
contextText: contextText || void 0,
|
|
469
743
|
contextSelector: context ? cssSelector(context) : void 0,
|
|
@@ -523,6 +797,33 @@ function collectPageData() {
|
|
|
523
797
|
}
|
|
524
798
|
const BUTTON_SELECTOR = 'button, input[type="submit"], input[type="button"], input[type="reset"], [role="button"]';
|
|
525
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(", ");
|
|
526
827
|
const forms = Array.from(document.querySelectorAll("form")).slice(0, 20).map((form) => {
|
|
527
828
|
const fields = Array.from(form.querySelectorAll(INPUT_SELECTOR + ", textarea, select")).filter(isCollectable).slice(0, 40).map((el) => {
|
|
528
829
|
const kind = el.tagName === "TEXTAREA" ? "textarea" : el.tagName === "SELECT" ? "select" : "input";
|
|
@@ -548,6 +849,8 @@ function collectPageData() {
|
|
|
548
849
|
inputs: collect(INPUT_SELECTOR, "input", "textbox"),
|
|
549
850
|
textareas: collect("textarea", "textarea", "textbox"),
|
|
550
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")),
|
|
551
854
|
forms,
|
|
552
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),
|
|
553
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) => {
|
|
@@ -560,13 +863,17 @@ function collectPageData() {
|
|
|
560
863
|
const dataTab = element.hasAttribute("data-tab");
|
|
561
864
|
const accordion = element.matches("details[data-accordion]");
|
|
562
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");
|
|
563
868
|
return {
|
|
564
869
|
kind,
|
|
565
870
|
name: accessibleName(element),
|
|
566
871
|
role,
|
|
567
872
|
cssSelector: cssSelector(element),
|
|
568
873
|
expanded: expanded === null ? void 0 : expanded === "true",
|
|
569
|
-
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>"
|
|
570
877
|
};
|
|
571
878
|
}).filter((item) => item.name).slice(0, 40),
|
|
572
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),
|
|
@@ -579,10 +886,18 @@ function collectPageData() {
|
|
|
579
886
|
|
|
580
887
|
// ../../packages/explorer/dist/mapToPageModel.js
|
|
581
888
|
function toUIElement(raw, keywords) {
|
|
582
|
-
|
|
889
|
+
const base2 = {
|
|
583
890
|
...raw,
|
|
584
891
|
destructive: isBlockedLabel(keywords, raw.accessibleName, raw.text, raw.name, raw.id)
|
|
585
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
|
+
};
|
|
586
901
|
}
|
|
587
902
|
function toFormInfo(raw, keywords) {
|
|
588
903
|
return {
|
|
@@ -602,7 +917,8 @@ function mapToPageModel(raw, meta, blockedKeywords = []) {
|
|
|
602
917
|
const inputs = raw.inputs.map(toElement);
|
|
603
918
|
const textareas = raw.textareas.map(toElement);
|
|
604
919
|
const selects = raw.selects.map(toElement);
|
|
605
|
-
const
|
|
920
|
+
const widgets = (raw.widgets ?? []).map(toElement);
|
|
921
|
+
const controls = [...links, ...buttons, ...inputs, ...textareas, ...selects, ...widgets];
|
|
606
922
|
const state = createPageState(raw, meta.finalUrl, controls);
|
|
607
923
|
return {
|
|
608
924
|
url: meta.url,
|
|
@@ -746,6 +1062,7 @@ var DEFAULT_CONFIG = {
|
|
|
746
1062
|
limits: DEFAULT_LIMITS,
|
|
747
1063
|
continueAfterLogin: true
|
|
748
1064
|
};
|
|
1065
|
+
var MAX_MODAL_DEPTH = 3;
|
|
749
1066
|
async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions = {}) {
|
|
750
1067
|
const config2 = {
|
|
751
1068
|
...DEFAULT_CONFIG,
|
|
@@ -802,7 +1119,32 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
802
1119
|
let totalActionsFailed = 0;
|
|
803
1120
|
let totalActionsRetried = 0;
|
|
804
1121
|
let urlsSkippedByScope = 0;
|
|
1122
|
+
let modalStatesDiscovered = 0;
|
|
805
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
|
+
}
|
|
806
1148
|
function isWithinScope(url) {
|
|
807
1149
|
if (!config2.scopePath)
|
|
808
1150
|
return true;
|
|
@@ -1174,23 +1516,48 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1174
1516
|
}
|
|
1175
1517
|
return { success: false };
|
|
1176
1518
|
}
|
|
1177
|
-
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
|
+
}
|
|
1178
1524
|
try {
|
|
1179
|
-
const
|
|
1180
|
-
|
|
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"]';
|
|
1181
1537
|
});
|
|
1182
|
-
if (!
|
|
1538
|
+
if (!containerSelector)
|
|
1183
1539
|
return { candidates: [] };
|
|
1184
1540
|
const raw = await page.evaluate(collectPageData);
|
|
1185
|
-
const pageModel = mapToPageModel(raw, { url: page.url(), finalUrl: page.url(), depth
|
|
1186
|
-
const
|
|
1187
|
-
if (!
|
|
1541
|
+
const pageModel = mapToPageModel(raw, { url: page.url(), finalUrl: page.url(), depth, statusCode: 200 }, legacyOptions.blockedKeywords);
|
|
1542
|
+
const collected = pageModel.state;
|
|
1543
|
+
if (!collected)
|
|
1188
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
|
+
};
|
|
1189
1552
|
if (visitedStates.has(modalState.id))
|
|
1190
1553
|
return { candidates: [] };
|
|
1191
1554
|
visitedStates.add(modalState.id);
|
|
1192
1555
|
addState(actionGraph, modalState);
|
|
1193
|
-
|
|
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
|
+
});
|
|
1194
1561
|
const modalCandidates = await discoverSafeCandidates(page, modalState);
|
|
1195
1562
|
const safeCandidates = modalCandidates.filter((c) => c.action.safe).slice(0, legacyOptions.maxActionsPerState);
|
|
1196
1563
|
for (const mc of safeCandidates) {
|
|
@@ -1217,13 +1584,16 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1217
1584
|
}
|
|
1218
1585
|
actionGraph.visitedActionKeys.push(mc.action.id);
|
|
1219
1586
|
const newRaw = await page.evaluate(collectPageData);
|
|
1220
|
-
const newModel = mapToPageModel(newRaw, { url: page.url(), finalUrl: page.url(), depth
|
|
1587
|
+
const newModel = mapToPageModel(newRaw, { url: page.url(), finalUrl: page.url(), depth, statusCode: 200 }, legacyOptions.blockedKeywords);
|
|
1221
1588
|
const newState = newModel.state;
|
|
1222
1589
|
if (newState && !visitedStates.has(newState.id)) {
|
|
1223
1590
|
visitedStates.add(newState.id);
|
|
1224
|
-
addState(actionGraph, newState);
|
|
1591
|
+
addState(actionGraph, { ...newState, parentStateId: modalState.id, depth });
|
|
1225
1592
|
addEdge(actionGraph, modalState.id, newState.id, mc.action, "visited");
|
|
1226
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
|
+
}
|
|
1227
1597
|
}
|
|
1228
1598
|
}
|
|
1229
1599
|
try {
|
|
@@ -1394,6 +1764,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1394
1764
|
break;
|
|
1395
1765
|
actionGraph.visitedActionKeys.push(candidate.action.id);
|
|
1396
1766
|
const beforeUrl = page.url();
|
|
1767
|
+
const actionStartedAt = Date.now();
|
|
1397
1768
|
if (candidate.kind === "navigation-link" || candidate.kind === "sidebar-nav" || candidate.kind === "breadcrumb") {
|
|
1398
1769
|
const href = candidate.action.target;
|
|
1399
1770
|
if (href && !isWithinScope(href)) {
|
|
@@ -1411,6 +1782,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1411
1782
|
totalActionsFailed++;
|
|
1412
1783
|
addEdge(actionGraph, currentState.id, void 0, candidate.action, "failed");
|
|
1413
1784
|
actionGraph.failedActionKeys.push(candidate.action.id);
|
|
1785
|
+
recordTransition(currentState, candidate.action, { url: beforeUrl, fingerprint: currentState.fingerprint }, { url: page.url() }, "failed", Date.now() - actionStartedAt);
|
|
1414
1786
|
debug(`Failed: ${candidate.action.target}`, { actionId: candidate.action.id });
|
|
1415
1787
|
await restoreState(page, beforeUrl, candidate.restoreStrategy, item.entryFlow);
|
|
1416
1788
|
continue;
|
|
@@ -1434,9 +1806,11 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1434
1806
|
const newRaw = await page.evaluate(collectPageData);
|
|
1435
1807
|
const newModel = mapToPageModel(newRaw, { url: beforeUrl, finalUrl: afterUrl, depth: item.depth + 1, statusCode: 200 }, legacyOptions.blockedKeywords);
|
|
1436
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);
|
|
1437
1811
|
if (newState && !visitedStates.has(newState.id)) {
|
|
1438
1812
|
visitedStates.add(newState.id);
|
|
1439
|
-
addState(actionGraph, newState);
|
|
1813
|
+
addState(actionGraph, { ...newState, parentStateId: currentState.id, depth: item.depth + 1 });
|
|
1440
1814
|
addEdge(actionGraph, currentState.id, newState.id, candidate.action, "visited");
|
|
1441
1815
|
debug(`New state: ${newState.name}`, { stateId: newState.id, url: redactUrl(afterUrl) });
|
|
1442
1816
|
if (!visitedUrls.has(normalizedAfter)) {
|
|
@@ -1493,13 +1867,42 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1493
1867
|
summary,
|
|
1494
1868
|
discoveryLogs: logs
|
|
1495
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();
|
|
1496
1897
|
return {
|
|
1497
1898
|
startUrl: entryUrl,
|
|
1498
1899
|
origin,
|
|
1499
1900
|
pages,
|
|
1500
1901
|
issues,
|
|
1501
1902
|
stats,
|
|
1502
|
-
actionGraph
|
|
1903
|
+
actionGraph,
|
|
1904
|
+
transitions,
|
|
1905
|
+
coverage: coverage.report()
|
|
1503
1906
|
};
|
|
1504
1907
|
}
|
|
1505
1908
|
function addState(graph, state) {
|
|
@@ -1509,10 +1912,10 @@ function addState(graph, state) {
|
|
|
1509
1912
|
graph.visitedStateIds.push(state.id);
|
|
1510
1913
|
}
|
|
1511
1914
|
function addEdge(graph, fromStateId, toStateId, action, status) {
|
|
1512
|
-
const
|
|
1513
|
-
if (graph.edges.some((edge) => edge.id ===
|
|
1915
|
+
const id2 = `${fromStateId}|${action.id}|${toStateId ?? status}`;
|
|
1916
|
+
if (graph.edges.some((edge) => edge.id === id2))
|
|
1514
1917
|
return;
|
|
1515
|
-
graph.edges.push({ id, fromStateId, toStateId, action, status });
|
|
1918
|
+
graph.edges.push({ id: id2, fromStateId, toStateId, action, status });
|
|
1516
1919
|
}
|
|
1517
1920
|
function getEndReasonDetail(reason, config2) {
|
|
1518
1921
|
switch (reason) {
|
|
@@ -1548,6 +1951,7 @@ function recorderInitScript() {
|
|
|
1548
1951
|
marker.__lazyscoutRecorderReady = true;
|
|
1549
1952
|
const CLICKABLE = 'a,button,input,select,textarea,[role="button"],[role="link"],[role="tab"],[role="menuitem"],[role="checkbox"],[role="radio"],[role="option"]';
|
|
1550
1953
|
const NON_TEXT_INPUTS = ["button", "submit", "reset", "checkbox", "radio", "file", "image"];
|
|
1954
|
+
const inspectState = window;
|
|
1551
1955
|
const send = (event) => {
|
|
1552
1956
|
try {
|
|
1553
1957
|
void scope.__lazyscoutRecord?.(event);
|
|
@@ -1591,9 +1995,9 @@ function recorderInitScript() {
|
|
|
1591
1995
|
return "textbox";
|
|
1592
1996
|
};
|
|
1593
1997
|
const labelOf2 = (element) => {
|
|
1594
|
-
const
|
|
1595
|
-
if (
|
|
1596
|
-
const explicit = document.querySelector(`label[for="${CSS.escape(
|
|
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 =
|
|
2050
|
+
const testId = testIdOf(element);
|
|
1637
2051
|
if (testId)
|
|
1638
|
-
return
|
|
1639
|
-
const
|
|
1640
|
-
if (
|
|
1641
|
-
return `#${CSS.escape(
|
|
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
|
|
2058
|
+
return attributeSelector2("name", name, element.tagName.toLowerCase());
|
|
1645
2059
|
const parts = [];
|
|
1646
2060
|
let node = element;
|
|
1647
2061
|
let depth = 0;
|
|
@@ -1662,16 +2076,95 @@ function recorderInitScript() {
|
|
|
1662
2076
|
};
|
|
1663
2077
|
const targetOf = (element) => {
|
|
1664
2078
|
const role = roleOf(element);
|
|
1665
|
-
|
|
2079
|
+
const name = accessibleName(element);
|
|
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;
|
|
2083
|
+
const target = {
|
|
1666
2084
|
role,
|
|
1667
|
-
name
|
|
2085
|
+
name,
|
|
1668
2086
|
// Only offer text matching where there is no role to match on.
|
|
1669
2087
|
text: role ? void 0 : clean(element.textContent) || void 0,
|
|
1670
2088
|
label: labelOf2(element),
|
|
1671
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(),
|
|
1672
2097
|
cssSelector: cssPath(element)
|
|
1673
2098
|
};
|
|
2099
|
+
return matches.length > 1 ? { ...target, matchCount: matches.length } : target;
|
|
2100
|
+
};
|
|
2101
|
+
const inspectionOf = (element, locked) => {
|
|
2102
|
+
const target = targetOf(element);
|
|
2103
|
+
const playwrightLocator = target.role && target.name ? `page.getByRole(${JSON.stringify(target.role)}, { name: ${JSON.stringify(target.name)}, exact: true })` : `page.locator(${JSON.stringify(target.cssSelector)})`;
|
|
2104
|
+
return {
|
|
2105
|
+
locked,
|
|
2106
|
+
tagName: element.tagName.toLowerCase(),
|
|
2107
|
+
role: target.role,
|
|
2108
|
+
accessibleName: target.name,
|
|
2109
|
+
text: clean(element.textContent) || void 0,
|
|
2110
|
+
id: element.getAttribute("id") || void 0,
|
|
2111
|
+
name: element.getAttribute("name") || void 0,
|
|
2112
|
+
cssSelector: target.cssSelector,
|
|
2113
|
+
playwrightLocator
|
|
2114
|
+
};
|
|
1674
2115
|
};
|
|
2116
|
+
const clearInspectHighlight = () => {
|
|
2117
|
+
const previous = inspectState.__lazyscoutInspectTarget;
|
|
2118
|
+
if (previous)
|
|
2119
|
+
previous.removeAttribute("data-lazyscout-inspect");
|
|
2120
|
+
inspectState.__lazyscoutInspectTarget = void 0;
|
|
2121
|
+
};
|
|
2122
|
+
const inspectCandidate = (origin) => {
|
|
2123
|
+
const interactive = origin.closest(CLICKABLE);
|
|
2124
|
+
if (interactive)
|
|
2125
|
+
return interactive;
|
|
2126
|
+
const directText = clean(Array.from(origin.childNodes).filter((node) => node.nodeType === Node.TEXT_NODE).map((node) => node.textContent ?? "").join(" "));
|
|
2127
|
+
const hasStableIdentity = Boolean(origin.id || origin.getAttribute("name") || origin.getAttribute("data-testid") || origin.getAttribute("aria-label") || origin.getAttribute("title"));
|
|
2128
|
+
return directText || hasStableIdentity || getComputedStyle(origin).cursor === "pointer" ? origin : void 0;
|
|
2129
|
+
};
|
|
2130
|
+
const inspect = (element, locked) => {
|
|
2131
|
+
if (!document.querySelector("[data-lazyscout-inspect-style]")) {
|
|
2132
|
+
const style = document.createElement("style");
|
|
2133
|
+
style.setAttribute("data-lazyscout-inspect-style", "true");
|
|
2134
|
+
style.textContent = '[data-lazyscout-inspect="true"]{outline:3px solid #7c3aed !important;outline-offset:3px !important;cursor:crosshair !important;}';
|
|
2135
|
+
document.documentElement.appendChild(style);
|
|
2136
|
+
}
|
|
2137
|
+
clearInspectHighlight();
|
|
2138
|
+
element.setAttribute("data-lazyscout-inspect", "true");
|
|
2139
|
+
inspectState.__lazyscoutInspectTarget = element;
|
|
2140
|
+
inspectState.__lazyscoutInspectLocked = locked;
|
|
2141
|
+
send({ kind: "inspect", inspection: inspectionOf(element, locked) });
|
|
2142
|
+
};
|
|
2143
|
+
document.addEventListener("pointerover", (event) => {
|
|
2144
|
+
if (!inspectState.__lazyscoutInspectMode)
|
|
2145
|
+
return;
|
|
2146
|
+
if (inspectState.__lazyscoutInspectLocked)
|
|
2147
|
+
return;
|
|
2148
|
+
const origin = event.target instanceof Element ? event.target : null;
|
|
2149
|
+
const element = origin ? inspectCandidate(origin) : void 0;
|
|
2150
|
+
if (element)
|
|
2151
|
+
inspect(element, false);
|
|
2152
|
+
}, true);
|
|
2153
|
+
document.addEventListener("click", (event) => {
|
|
2154
|
+
if (!inspectState.__lazyscoutInspectMode)
|
|
2155
|
+
return;
|
|
2156
|
+
const origin = event.target instanceof Element ? event.target : null;
|
|
2157
|
+
event.preventDefault();
|
|
2158
|
+
event.stopImmediatePropagation();
|
|
2159
|
+
const element = origin ? inspectCandidate(origin) : void 0;
|
|
2160
|
+
if (element) {
|
|
2161
|
+
inspect(element, true);
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
clearInspectHighlight();
|
|
2165
|
+
inspectState.__lazyscoutInspectLocked = false;
|
|
2166
|
+
send({ kind: "inspect" });
|
|
2167
|
+
}, true);
|
|
1675
2168
|
document.addEventListener("click", (event) => {
|
|
1676
2169
|
const origin = event.target instanceof Element ? event.target : null;
|
|
1677
2170
|
const element = origin?.closest(CLICKABLE);
|
|
@@ -1774,6 +2267,8 @@ function compactTarget(target) {
|
|
|
1774
2267
|
return Object.fromEntries(entries);
|
|
1775
2268
|
}
|
|
1776
2269
|
function buildStep(event) {
|
|
2270
|
+
if (event.kind === "inspect")
|
|
2271
|
+
return void 0;
|
|
1777
2272
|
const target = compactTarget(event.target);
|
|
1778
2273
|
if (event.kind === "click")
|
|
1779
2274
|
return { type: "click", target };
|
|
@@ -1793,14 +2288,18 @@ async function attachRecorder(context, startUrl, options = {}) {
|
|
|
1793
2288
|
ended = true;
|
|
1794
2289
|
options.onEnded?.();
|
|
1795
2290
|
};
|
|
1796
|
-
const pushNavigate = (url) => {
|
|
1797
|
-
if (!url || url === "about:blank" || url
|
|
2291
|
+
const pushNavigate = (url, force = false) => {
|
|
2292
|
+
if (!url || url === "about:blank" || !force && sameNavigationUrl(url, lastUrl))
|
|
1798
2293
|
return;
|
|
1799
2294
|
lastUrl = url;
|
|
1800
2295
|
if (steps.length < MAX_RECORDED_STEPS)
|
|
1801
2296
|
steps.push({ type: "navigate", url });
|
|
1802
2297
|
};
|
|
1803
2298
|
const record = (event) => {
|
|
2299
|
+
if (event.kind === "inspect") {
|
|
2300
|
+
options.onInspection?.(event.inspection);
|
|
2301
|
+
return;
|
|
2302
|
+
}
|
|
1804
2303
|
if (steps.length >= MAX_RECORDED_STEPS)
|
|
1805
2304
|
return;
|
|
1806
2305
|
pushNavigate(event.url);
|
|
@@ -1808,7 +2307,7 @@ async function attachRecorder(context, startUrl, options = {}) {
|
|
|
1808
2307
|
if (!step)
|
|
1809
2308
|
return;
|
|
1810
2309
|
const previous = steps[steps.length - 1];
|
|
1811
|
-
if (step.type === "fill" && previous && previous.type === "fill" && sameTarget(previous.target, step.target)
|
|
2310
|
+
if (step.type === "fill" && previous && previous.type === "fill" && sameTarget(previous.target, step.target)) {
|
|
1812
2311
|
steps[steps.length - 1] = step;
|
|
1813
2312
|
return;
|
|
1814
2313
|
}
|
|
@@ -1820,6 +2319,26 @@ async function attachRecorder(context, startUrl, options = {}) {
|
|
|
1820
2319
|
} catch {
|
|
1821
2320
|
}
|
|
1822
2321
|
});
|
|
2322
|
+
const setInspectMode = async (enabled) => {
|
|
2323
|
+
await context.addInitScript((value) => {
|
|
2324
|
+
const state = window;
|
|
2325
|
+
state.__lazyscoutInspectMode = value;
|
|
2326
|
+
if (!value) {
|
|
2327
|
+
state.__lazyscoutInspectLocked = false;
|
|
2328
|
+
state.__lazyscoutInspectTarget = void 0;
|
|
2329
|
+
document.querySelectorAll("[data-lazyscout-inspect]").forEach((element) => element.removeAttribute("data-lazyscout-inspect"));
|
|
2330
|
+
}
|
|
2331
|
+
}, enabled);
|
|
2332
|
+
await Promise.all(context.pages().map((page) => page.evaluate((value) => {
|
|
2333
|
+
const state = window;
|
|
2334
|
+
state.__lazyscoutInspectMode = value;
|
|
2335
|
+
if (!value) {
|
|
2336
|
+
state.__lazyscoutInspectLocked = false;
|
|
2337
|
+
state.__lazyscoutInspectTarget = void 0;
|
|
2338
|
+
document.querySelectorAll("[data-lazyscout-inspect]").forEach((element) => element.removeAttribute("data-lazyscout-inspect"));
|
|
2339
|
+
}
|
|
2340
|
+
}, enabled)));
|
|
2341
|
+
};
|
|
1823
2342
|
await context.addInitScript(recorderInitScript);
|
|
1824
2343
|
const inject = (page) => {
|
|
1825
2344
|
void page.evaluate(recorderInitScript).catch(() => void 0);
|
|
@@ -1850,19 +2369,28 @@ async function attachRecorder(context, startUrl, options = {}) {
|
|
|
1850
2369
|
const closing = closingAssertion(lastUrl, finalUrl);
|
|
1851
2370
|
return closing ? [...steps, closing] : steps.slice();
|
|
1852
2371
|
},
|
|
1853
|
-
currentUrl: () => lastUrl
|
|
2372
|
+
currentUrl: () => lastUrl,
|
|
2373
|
+
recordNavigation: pushNavigate,
|
|
2374
|
+
setInspectMode
|
|
1854
2375
|
};
|
|
1855
2376
|
}
|
|
2377
|
+
function sameNavigationUrl(left, right) {
|
|
2378
|
+
try {
|
|
2379
|
+
return new URL(left).href === new URL(right).href;
|
|
2380
|
+
} catch {
|
|
2381
|
+
return left === right;
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
1856
2384
|
|
|
1857
2385
|
// ../../packages/generators/dist/moduleNames.js
|
|
1858
2386
|
function assignModules(pages) {
|
|
1859
2387
|
const result = /* @__PURE__ */ new Map();
|
|
1860
2388
|
const used = /* @__PURE__ */ new Map();
|
|
1861
2389
|
for (const page of pages) {
|
|
1862
|
-
const
|
|
1863
|
-
const count = used.get(
|
|
1864
|
-
used.set(
|
|
1865
|
-
result.set(page.url, count === 0 ?
|
|
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}`);
|
|
1866
2394
|
}
|
|
1867
2395
|
return result;
|
|
1868
2396
|
}
|
|
@@ -1877,15 +2405,24 @@ function toTargetRef(element) {
|
|
|
1877
2405
|
contextSelector: element.contextSelector,
|
|
1878
2406
|
contextTestId: element.contextTestId
|
|
1879
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
|
+
});
|
|
1880
2416
|
if (element.accessibleName) {
|
|
1881
|
-
return { role: element.role, name: element.accessibleName,
|
|
2417
|
+
return { role: element.role, name: element.accessibleName, ...identity, ...disambiguation };
|
|
1882
2418
|
}
|
|
1883
2419
|
if (element.placeholder) {
|
|
1884
|
-
return { role: element.role, placeholder: element.placeholder,
|
|
2420
|
+
return { role: element.role, placeholder: element.placeholder, ...identity, ...disambiguation };
|
|
1885
2421
|
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
2422
|
+
return { role: element.role, ...identity, ...disambiguation };
|
|
2423
|
+
}
|
|
2424
|
+
function defined(value) {
|
|
2425
|
+
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0));
|
|
1889
2426
|
}
|
|
1890
2427
|
function labelOf(element) {
|
|
1891
2428
|
return element.accessibleName || element.placeholder || element.name || element.id || element.tagName;
|
|
@@ -1990,44 +2527,10 @@ function pageStructureRule(ctx) {
|
|
|
1990
2527
|
})
|
|
1991
2528
|
];
|
|
1992
2529
|
}
|
|
1993
|
-
function interactionRule(ctx) {
|
|
1994
|
-
const interactions = ctx.page.state?.interactions ?? [];
|
|
1995
|
-
return interactions.slice(0, 12).map((interaction) => {
|
|
1996
|
-
const target = interactionTarget(interaction);
|
|
1997
|
-
return build(ctx, {
|
|
1998
|
-
title: (interaction.name || interaction.kind) + " interaction works",
|
|
1999
|
-
preconditions: precondition(ctx.page),
|
|
2000
|
-
steps: [
|
|
2001
|
-
navigateStep(ctx.page),
|
|
2002
|
-
{ type: "click", target, description: interactionAction(interaction) },
|
|
2003
|
-
{ type: "assertVisible", target }
|
|
2004
|
-
],
|
|
2005
|
-
expectedResult: interaction.kind + ' "' + (interaction.name || "control") + '" opens and is usable.',
|
|
2006
|
-
type: "positive",
|
|
2007
|
-
priority: "medium",
|
|
2008
|
-
automationStatus: "needs-review",
|
|
2009
|
-
notes: "Generated from the observed " + interaction.kind + " interaction."
|
|
2010
|
-
});
|
|
2011
|
-
});
|
|
2012
|
-
}
|
|
2013
|
-
function interactionTarget(interaction) {
|
|
2014
|
-
return { role: interaction.role, name: interaction.name || void 0, cssSelector: interaction.cssSelector };
|
|
2015
|
-
}
|
|
2016
|
-
function interactionAction(interaction) {
|
|
2017
|
-
const labels = {
|
|
2018
|
-
dialog: "Open modal or dialog",
|
|
2019
|
-
tab: "Select tab",
|
|
2020
|
-
accordion: "Expand accordion",
|
|
2021
|
-
dropdown: "Open dropdown",
|
|
2022
|
-
drawer: "Open drawer",
|
|
2023
|
-
popover: "Open popover"
|
|
2024
|
-
};
|
|
2025
|
-
return labels[interaction.kind];
|
|
2026
|
-
}
|
|
2027
2530
|
function requiredFieldRule(ctx, form) {
|
|
2028
2531
|
const submit = form.submitButtons.find((button) => !button.disabled);
|
|
2029
2532
|
const fields = form.fields.filter(isUsable);
|
|
2030
|
-
const testableFields = fields.filter((field) => !isToggleField(field)).slice(0,
|
|
2533
|
+
const testableFields = fields.filter((field) => !isToggleField(field)).slice(0, 12);
|
|
2031
2534
|
if (!submit || testableFields.length === 0)
|
|
2032
2535
|
return [];
|
|
2033
2536
|
return testableFields.map((field) => {
|
|
@@ -2037,23 +2540,282 @@ function requiredFieldRule(ctx, form) {
|
|
|
2037
2540
|
continue;
|
|
2038
2541
|
steps.push(fillFieldStep(other));
|
|
2039
2542
|
}
|
|
2040
|
-
|
|
2041
|
-
type: "
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2543
|
+
if (field.required) {
|
|
2544
|
+
steps.push({ type: "click", target: toTargetRef(submit) });
|
|
2545
|
+
steps.push({
|
|
2546
|
+
type: "assertInvalid",
|
|
2547
|
+
target: toTargetRef(field),
|
|
2548
|
+
description: `Verify that "${labelOf(field)}" is invalid and the form is not submitted`
|
|
2549
|
+
});
|
|
2550
|
+
} else {
|
|
2551
|
+
steps.push({
|
|
2552
|
+
type: "manual",
|
|
2553
|
+
description: `Verify whether "${labelOf(field)}" may be empty according to the product requirement`
|
|
2554
|
+
});
|
|
2555
|
+
}
|
|
2045
2556
|
return build(ctx, {
|
|
2046
|
-
title: `${labelOf(field)} is required`,
|
|
2557
|
+
title: field.required ? `${labelOf(field)} is required` : `${labelOf(field)} handles empty input`,
|
|
2047
2558
|
preconditions: precondition(ctx.page),
|
|
2048
2559
|
steps,
|
|
2049
|
-
expectedResult: field.required ? "
|
|
2560
|
+
expectedResult: field.required ? "A required-field validation is displayed and the form is not submitted." : `${labelOf(field)} accepts or rejects empty input according to the product requirement.`,
|
|
2050
2561
|
type: "validation",
|
|
2051
2562
|
priority: field.required ? "high" : "medium",
|
|
2563
|
+
automationStatus: field.required ? "ready" : "needs-review",
|
|
2564
|
+
tags: ["validation", field.required ? "required" : "empty-input"],
|
|
2565
|
+
notes: field.required ? 'Evidence: the field has the HTML "required" attribute. Playwright waits for the field to become invalid.' : "No required attribute was detected. Confirm whether an empty value is allowed before automating submission."
|
|
2566
|
+
});
|
|
2567
|
+
});
|
|
2568
|
+
}
|
|
2569
|
+
function validationMatrixRule(ctx, form) {
|
|
2570
|
+
const submit = form.submitButtons.find((button) => !button.disabled && !button.destructive);
|
|
2571
|
+
const fields = form.fields.filter(isUsable);
|
|
2572
|
+
if (!submit)
|
|
2573
|
+
return [];
|
|
2574
|
+
const cases = [];
|
|
2575
|
+
for (const field of fields.slice(0, 12)) {
|
|
2576
|
+
for (const scenario of validationScenarios(field).slice(0, 8)) {
|
|
2577
|
+
const steps = [navigateStep(ctx.page)];
|
|
2578
|
+
for (const other of fields) {
|
|
2579
|
+
if (other === field)
|
|
2580
|
+
continue;
|
|
2581
|
+
steps.push(fillFieldStep(other));
|
|
2582
|
+
}
|
|
2583
|
+
steps.push({ type: "fill", target: toTargetRef(field), value: scenario.value });
|
|
2584
|
+
steps.push({ type: "click", target: toTargetRef(submit) });
|
|
2585
|
+
if (scenario.manualCheck) {
|
|
2586
|
+
steps.push({ type: "wait", mode: "timeout", value: "750" });
|
|
2587
|
+
steps.push({ type: "manual", description: scenario.manualCheck });
|
|
2588
|
+
} else {
|
|
2589
|
+
steps.push({ type: "assertInvalid", target: toTargetRef(field) });
|
|
2590
|
+
}
|
|
2591
|
+
cases.push(build(ctx, {
|
|
2592
|
+
title: `${labelOf(field)} ${scenario.title}`,
|
|
2593
|
+
preconditions: precondition(ctx.page),
|
|
2594
|
+
steps,
|
|
2595
|
+
expectedResult: scenario.expectedResult,
|
|
2596
|
+
type: "validation",
|
|
2597
|
+
priority: "high",
|
|
2598
|
+
automationStatus: scenario.automationStatus ?? "ready",
|
|
2599
|
+
tags: ["validation", "generated-matrix"],
|
|
2600
|
+
notes: scenario.notes
|
|
2601
|
+
}));
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
return cases;
|
|
2605
|
+
}
|
|
2606
|
+
function loginFailureRule(ctx, form) {
|
|
2607
|
+
const submit = form.submitButtons.find((button) => !button.disabled && !button.destructive);
|
|
2608
|
+
const fields = form.fields.filter(isUsable);
|
|
2609
|
+
if (!submit || !isLoginForm(ctx.page, form, fields, submit))
|
|
2610
|
+
return [];
|
|
2611
|
+
const username = fields.find((field) => {
|
|
2612
|
+
const hint = `${field.name ?? ""} ${field.accessibleName} ${field.autocomplete ?? ""}`.toLowerCase();
|
|
2613
|
+
return /username|user name|email|อีเมล|ชื่อผู้ใช้/.test(hint) && field.inputType !== "password";
|
|
2614
|
+
});
|
|
2615
|
+
const password = fields.find((field) => field.inputType === "password");
|
|
2616
|
+
const scenarios = [
|
|
2617
|
+
username && !username.required && {
|
|
2618
|
+
field: username,
|
|
2619
|
+
value: "",
|
|
2620
|
+
title: "Reject empty username",
|
|
2621
|
+
expected: "The application keeps the user signed out and displays a username validation error."
|
|
2622
|
+
},
|
|
2623
|
+
password && !password.required && {
|
|
2624
|
+
field: password,
|
|
2625
|
+
value: "",
|
|
2626
|
+
title: "Reject empty password",
|
|
2627
|
+
expected: "The application keeps the user signed out and displays a password validation error."
|
|
2628
|
+
},
|
|
2629
|
+
username && {
|
|
2630
|
+
field: username,
|
|
2631
|
+
value: username.inputType === "email" ? "lazyscout.invalid@example.com" : "lazyscout-invalid-user",
|
|
2632
|
+
title: "Reject invalid username",
|
|
2633
|
+
expected: "The application keeps the user signed out and displays an authentication error."
|
|
2634
|
+
},
|
|
2635
|
+
password && {
|
|
2636
|
+
field: password,
|
|
2637
|
+
value: "LazyScout-Wrong-Password-123!",
|
|
2638
|
+
title: "Reject invalid password",
|
|
2639
|
+
expected: "The application keeps the user signed out and displays an authentication error."
|
|
2640
|
+
}
|
|
2641
|
+
].filter(Boolean);
|
|
2642
|
+
return scenarios.map((scenario) => {
|
|
2643
|
+
const steps = [navigateStep(ctx.page)];
|
|
2644
|
+
for (const field of fields) {
|
|
2645
|
+
steps.push(field === scenario.field ? { type: "fill", target: toTargetRef(field), value: scenario.value } : fillFieldStep(field));
|
|
2646
|
+
}
|
|
2647
|
+
steps.push({ type: "click", target: toTargetRef(submit) });
|
|
2648
|
+
steps.push({ type: "assertValidation" });
|
|
2649
|
+
return build(ctx, {
|
|
2650
|
+
title: scenario.title,
|
|
2651
|
+
preconditions: [
|
|
2652
|
+
...precondition(ctx.page),
|
|
2653
|
+
"Use a test environment where failed logins cannot lock a real account"
|
|
2654
|
+
],
|
|
2655
|
+
steps,
|
|
2656
|
+
expectedResult: scenario.expected,
|
|
2657
|
+
type: "negative",
|
|
2658
|
+
priority: "high",
|
|
2052
2659
|
automationStatus: "needs-review",
|
|
2053
|
-
|
|
2660
|
+
tags: ["login", "negative", "server-validation"],
|
|
2661
|
+
notes: "Runs one failed login attempt only. Review the observed server message before marking this case ready."
|
|
2054
2662
|
});
|
|
2055
2663
|
});
|
|
2056
2664
|
}
|
|
2665
|
+
function validationScenarios(field) {
|
|
2666
|
+
if (field.kind === "select" || isToggleField(field))
|
|
2667
|
+
return [];
|
|
2668
|
+
const label = labelOf(field);
|
|
2669
|
+
const scenarios = [];
|
|
2670
|
+
if (field.inputType === "email")
|
|
2671
|
+
scenarios.push({
|
|
2672
|
+
title: "rejects an invalid email format",
|
|
2673
|
+
value: "invalid-email",
|
|
2674
|
+
expectedResult: `${label} is marked invalid and the form is not submitted.`,
|
|
2675
|
+
notes: 'Generated from input type="email".'
|
|
2676
|
+
});
|
|
2677
|
+
if (field.inputType === "url")
|
|
2678
|
+
scenarios.push({
|
|
2679
|
+
title: "rejects an invalid URL format",
|
|
2680
|
+
value: "not-a-url",
|
|
2681
|
+
expectedResult: `${label} is marked invalid and the form is not submitted.`,
|
|
2682
|
+
notes: 'Generated from input type="url".'
|
|
2683
|
+
});
|
|
2684
|
+
if (field.required && isTextLikeField(field))
|
|
2685
|
+
scenarios.push({
|
|
2686
|
+
title: "handles whitespace-only input",
|
|
2687
|
+
value: " ",
|
|
2688
|
+
expectedResult: `${label} rejects whitespace-only input when meaningful text is required.`,
|
|
2689
|
+
notes: "HTML required accepts whitespace. Review this case against the product rule and the displayed message.",
|
|
2690
|
+
automationStatus: "needs-review",
|
|
2691
|
+
manualCheck: `Verify whether ${label} rejects whitespace-only input and shows the correct validation message`
|
|
2692
|
+
});
|
|
2693
|
+
if (isUsernameField(field)) {
|
|
2694
|
+
scenarios.push({
|
|
2695
|
+
title: "handles characters from another writing system",
|
|
2696
|
+
value: "\u0E1C\u0E39\u0E49\u0E43\u0E0A\u0E49\u0E17\u0E14\u0E2A\u0E2D\u0E1A",
|
|
2697
|
+
expectedResult: `${label} accepts or rejects characters from another writing system according to the username policy.`,
|
|
2698
|
+
notes: "No username character policy is inferred unless the HTML exposes a pattern. Review the result against requirements.",
|
|
2699
|
+
automationStatus: "needs-review",
|
|
2700
|
+
manualCheck: `Verify the username character policy and the validation message shown for ${label}`
|
|
2701
|
+
}, {
|
|
2702
|
+
title: "handles special characters",
|
|
2703
|
+
value: "user!@#$",
|
|
2704
|
+
expectedResult: `${label} accepts or rejects special characters according to the username policy.`,
|
|
2705
|
+
notes: "Generated as a business-rule review because HTML may not expose the server username policy.",
|
|
2706
|
+
automationStatus: "needs-review",
|
|
2707
|
+
manualCheck: `Verify whether ${label} permits special characters and shows the correct validation message`
|
|
2708
|
+
});
|
|
2709
|
+
}
|
|
2710
|
+
if (field.minLength && field.minLength > 0)
|
|
2711
|
+
scenarios.push({
|
|
2712
|
+
title: `rejects fewer than ${field.minLength} characters`,
|
|
2713
|
+
value: "a".repeat(Math.max(0, field.minLength - 1)),
|
|
2714
|
+
expectedResult: `${label} remains invalid below the minimum length of ${field.minLength}.`,
|
|
2715
|
+
notes: `Generated from minlength="${field.minLength}".`
|
|
2716
|
+
});
|
|
2717
|
+
if (field.pattern) {
|
|
2718
|
+
const mismatch = patternMismatch(field.pattern);
|
|
2719
|
+
if (mismatch)
|
|
2720
|
+
scenarios.push({
|
|
2721
|
+
title: "rejects a value outside the required pattern",
|
|
2722
|
+
value: mismatch,
|
|
2723
|
+
expectedResult: `${label} remains invalid when its pattern is not satisfied.`,
|
|
2724
|
+
notes: `Generated from pattern="${field.pattern}".`
|
|
2725
|
+
});
|
|
2726
|
+
}
|
|
2727
|
+
if (field.inputType === "number" && field.min !== void 0) {
|
|
2728
|
+
const min = Number(field.min);
|
|
2729
|
+
if (Number.isFinite(min))
|
|
2730
|
+
scenarios.push({
|
|
2731
|
+
title: `rejects a value below ${field.min}`,
|
|
2732
|
+
value: String(min - 1),
|
|
2733
|
+
expectedResult: `${label} remains invalid below the minimum value ${field.min}.`,
|
|
2734
|
+
notes: `Generated from min="${field.min}".`
|
|
2735
|
+
});
|
|
2736
|
+
}
|
|
2737
|
+
if (field.inputType === "number" && field.max !== void 0) {
|
|
2738
|
+
const max = Number(field.max);
|
|
2739
|
+
if (Number.isFinite(max))
|
|
2740
|
+
scenarios.push({
|
|
2741
|
+
title: `rejects a value above ${field.max}`,
|
|
2742
|
+
value: String(max + 1),
|
|
2743
|
+
expectedResult: `${label} remains invalid above the maximum value ${field.max}.`,
|
|
2744
|
+
notes: `Generated from max="${field.max}".`
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
if (field.maxLength && field.maxLength > 0)
|
|
2748
|
+
scenarios.push({
|
|
2749
|
+
title: `handles more than ${field.maxLength} characters`,
|
|
2750
|
+
value: "A".repeat(Math.min(field.maxLength + 1, 256)),
|
|
2751
|
+
expectedResult: `${label} prevents or rejects input above ${field.maxLength} characters.`,
|
|
2752
|
+
notes: `Generated from maxlength="${field.maxLength}". Browser behavior can truncate typed input, so review the result.`,
|
|
2753
|
+
automationStatus: "needs-review",
|
|
2754
|
+
manualCheck: `Verify that ${label} does not accept more than ${field.maxLength} characters`
|
|
2755
|
+
});
|
|
2756
|
+
if (field.inputType === "password")
|
|
2757
|
+
scenarios.push(...passwordPolicyScenarios(field));
|
|
2758
|
+
return uniqueScenarios(scenarios);
|
|
2759
|
+
}
|
|
2760
|
+
function passwordPolicyScenarios(field) {
|
|
2761
|
+
const pattern = field.pattern ?? "";
|
|
2762
|
+
const requirements = [
|
|
2763
|
+
[(value) => /\[A-Z\]|\\p\{Lu\}/.test(value), "rejects a password without an uppercase letter", "lowercase123!"],
|
|
2764
|
+
[(value) => /\[a-z\]|\\p\{Ll\}/.test(value), "rejects a password without a lowercase letter", "UPPERCASE123!"],
|
|
2765
|
+
[(value) => /\\d|\[0-9\]/.test(value), "rejects a password without a number", "NoNumbersHere!"],
|
|
2766
|
+
[
|
|
2767
|
+
(value) => /\\W|special|symbol|\[[^\]]*[!@#$%^&][^\]]*\]/i.test(value),
|
|
2768
|
+
"rejects a password without a special character",
|
|
2769
|
+
"NoSpecial123"
|
|
2770
|
+
]
|
|
2771
|
+
];
|
|
2772
|
+
const scenarios = [];
|
|
2773
|
+
for (const [hasRequirement, title, value] of requirements) {
|
|
2774
|
+
if (!hasRequirement(pattern))
|
|
2775
|
+
continue;
|
|
2776
|
+
scenarios.push({
|
|
2777
|
+
title,
|
|
2778
|
+
value,
|
|
2779
|
+
expectedResult: `${labelOf(field)} remains invalid until the password policy is satisfied.`,
|
|
2780
|
+
notes: `Generated from the password pattern="${pattern}".`
|
|
2781
|
+
});
|
|
2782
|
+
}
|
|
2783
|
+
if (!field.minLength && !field.maxLength && !field.pattern)
|
|
2784
|
+
scenarios.push({
|
|
2785
|
+
title: "policy requires specification review",
|
|
2786
|
+
value: "password",
|
|
2787
|
+
expectedResult: "Confirm whether uppercase, lowercase, number, special-character, and length rules are required.",
|
|
2788
|
+
notes: "No minlength, maxlength, or pattern was found in the HTML. LazyScout does not invent a password policy.",
|
|
2789
|
+
automationStatus: "needs-review",
|
|
2790
|
+
manualCheck: "Review the password policy with the product requirement and verify the displayed validation message"
|
|
2791
|
+
});
|
|
2792
|
+
return scenarios;
|
|
2793
|
+
}
|
|
2794
|
+
function isTextLikeField(field) {
|
|
2795
|
+
return !field.inputType || ["text", "search", "email", "url", "tel", "password"].includes(field.inputType);
|
|
2796
|
+
}
|
|
2797
|
+
function isUsernameField(field) {
|
|
2798
|
+
const hint = `${field.name ?? ""} ${field.accessibleName ?? ""} ${field.placeholder ?? ""} ${field.autocomplete ?? ""}`.toLowerCase();
|
|
2799
|
+
return /username|user name|ชื่อผู้ใช้/.test(hint);
|
|
2800
|
+
}
|
|
2801
|
+
function patternMismatch(pattern) {
|
|
2802
|
+
try {
|
|
2803
|
+
const expression = new RegExp(`^(?:${pattern})$`, "u");
|
|
2804
|
+
return ["!", "invalid", "abc", "123", "lowercase", "UPPERCASE"].find((candidate) => !expression.test(candidate));
|
|
2805
|
+
} catch {
|
|
2806
|
+
return void 0;
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
function uniqueScenarios(scenarios) {
|
|
2810
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2811
|
+
return scenarios.filter((scenario) => {
|
|
2812
|
+
const key = `${scenario.title}|${scenario.value}`;
|
|
2813
|
+
if (seen.has(key))
|
|
2814
|
+
return false;
|
|
2815
|
+
seen.add(key);
|
|
2816
|
+
return true;
|
|
2817
|
+
});
|
|
2818
|
+
}
|
|
2057
2819
|
function formSubmitRule(ctx, form) {
|
|
2058
2820
|
const submit = form.submitButtons.find((button) => !button.disabled && !button.destructive);
|
|
2059
2821
|
const fields = form.fields.filter(isUsable);
|
|
@@ -2164,9 +2926,276 @@ function destructiveActionRule(ctx) {
|
|
|
2164
2926
|
return cases;
|
|
2165
2927
|
}
|
|
2166
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
|
+
|
|
2167
3196
|
// ../../packages/generators/dist/testcases/generateTestCases.js
|
|
2168
3197
|
var DEFAULT_GENERATE_OPTIONS = {
|
|
2169
|
-
maxTestCasesPerPage:
|
|
3198
|
+
maxTestCasesPerPage: 120,
|
|
2170
3199
|
language: "en"
|
|
2171
3200
|
};
|
|
2172
3201
|
function generateTestCases(pages, options = {}) {
|
|
@@ -2182,14 +3211,16 @@ function generateTestCases(pages, options = {}) {
|
|
|
2182
3211
|
for (const page of pages) {
|
|
2183
3212
|
const module = moduleByUrl.get(page.url) ?? "PAGE";
|
|
2184
3213
|
const context = { page, module, visitedTitles };
|
|
2185
|
-
const fromPage = [
|
|
3214
|
+
const fromPage = dedupe([
|
|
2186
3215
|
...pageStructureRule(context),
|
|
2187
3216
|
...page.forms.flatMap((form) => requiredFieldRule(context, form)),
|
|
3217
|
+
...page.forms.flatMap((form) => validationMatrixRule(context, form)),
|
|
3218
|
+
...page.forms.flatMap((form) => loginFailureRule(context, form)),
|
|
2188
3219
|
...page.forms.flatMap((form) => formSubmitRule(context, form)),
|
|
2189
|
-
...
|
|
3220
|
+
...patternCases(context),
|
|
2190
3221
|
...navigationRule(context),
|
|
2191
3222
|
...destructiveActionRule(context)
|
|
2192
|
-
].slice(0, config2.maxTestCasesPerPage);
|
|
3223
|
+
], counters).slice(0, config2.maxTestCasesPerPage);
|
|
2193
3224
|
for (const generated of fromPage) {
|
|
2194
3225
|
const sequence = (counters.get(module) ?? 0) + 1;
|
|
2195
3226
|
counters.set(module, sequence);
|
|
@@ -2198,6 +3229,30 @@ function generateTestCases(pages, options = {}) {
|
|
|
2198
3229
|
}
|
|
2199
3230
|
return config2.language === "en" ? testCases : localizeThai(testCases);
|
|
2200
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
|
+
}
|
|
2201
3256
|
function localizeThai(testCases) {
|
|
2202
3257
|
return testCases.map((testCase) => ({
|
|
2203
3258
|
...testCase,
|
|
@@ -2221,19 +3276,23 @@ function translateStep(step) {
|
|
|
2221
3276
|
case "check":
|
|
2222
3277
|
return `${step.checked ? "Check" : "Uncheck"} ${step.target.name ?? step.target.label ?? "element"}`;
|
|
2223
3278
|
case "wait":
|
|
2224
|
-
return
|
|
3279
|
+
return `\u0E23\u0E2D ${step.mode}: ${step.value}`;
|
|
2225
3280
|
case "assertVisible":
|
|
2226
3281
|
return `\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32 ${step.target.name ?? step.target.label ?? "element"} \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48`;
|
|
2227
3282
|
case "assertText":
|
|
2228
3283
|
return step.target ? `\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32 ${step.target.name ?? step.target.label ?? "element"} \u0E41\u0E2A\u0E14\u0E07\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21 "${step.text}"` : `\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A\u0E41\u0E2A\u0E14\u0E07\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21 "${step.text}"`;
|
|
2229
3284
|
case "assertUrl":
|
|
2230
3285
|
return `\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32 URL \u0E21\u0E35\u0E04\u0E33\u0E27\u0E48\u0E32 "${step.urlContains}"`;
|
|
3286
|
+
case "assertInvalid":
|
|
3287
|
+
return `\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32 ${step.target.name ?? step.target.label ?? "\u0E0A\u0E48\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25"} \u0E44\u0E21\u0E48\u0E1C\u0E48\u0E32\u0E19 validation \u0E41\u0E25\u0E30\u0E1F\u0E2D\u0E23\u0E4C\u0E21\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E2A\u0E48\u0E07`;
|
|
3288
|
+
case "assertValidation":
|
|
3289
|
+
return "\u0E23\u0E2D\u0E08\u0E19\u0E01\u0E27\u0E48\u0E32\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21 validation \u0E2B\u0E23\u0E37\u0E2D error \u0E08\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E02\u0E36\u0E49\u0E19\u0E21\u0E32";
|
|
2231
3290
|
case "manual":
|
|
2232
3291
|
return step.description;
|
|
2233
3292
|
}
|
|
2234
3293
|
}
|
|
2235
3294
|
function translate(value) {
|
|
2236
|
-
return value.replace(/^Login with valid credentials via (.+)$/, "\u0E40\u0E02\u0E49\u0E32\u0E2A\u0E39\u0E48\u0E23\u0E30\u0E1A\u0E1A\u0E14\u0E49\u0E27\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E1C\u0E48\u0E32\u0E19 $1").replace(/^The form is submitted and the browser navigates to (.+?)[.]?$/, "\u0E1F\u0E2D\u0E23\u0E4C\u0E21\u0E16\u0E39\u0E01\u0E2A\u0E48\u0E07\u0E41\u0E25\u0E30\u0E40\u0E1A\u0E23\u0E32\u0E27\u0E4C\u0E40\u0E0B\u0E2D\u0E23\u0E4C\u0E44\u0E1B\u0E22\u0E31\u0E07 $1").replace(/^(.+) interaction works$/, "\u0E01\u0E32\u0E23\u0E17\u0E33\u0E07\u0E32\u0E19\u0E02\u0E2D\u0E07 $1 \u0E17\u0E33\u0E07\u0E32\u0E19\u0E44\u0E14\u0E49\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^(.+) "(.+)" opens and is usable\.$/, '$1 "$2" \u0E40\u0E1B\u0E34\u0E14\u0E41\u0E25\u0E30\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19\u0E44\u0E14\u0E49').replace(/^Generated from the observed (.+) interaction\.$/, "\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E1E\u0E1A interaction \u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17 $1").replace(/^Login with valid credentials via (.+)$/, "\u0E40\u0E02\u0E49\u0E32\u0E2A\u0E39\u0E48\u0E23\u0E30\u0E1A\u0E1A\u0E14\u0E49\u0E27\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E1C\u0E48\u0E32\u0E19 $1").replace(/^(.+) page displays required controls$/, "$1 \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19").replace(/^All (\d+) controls detected on the page are visible\.$/, "\u0E1E\u0E1A\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E1A\u0E19\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14 $1 \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25\u0E2D\u0E22\u0E39\u0E48").replace(/^(.+) is required$/, "$1 \u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19").replace(/^Submit (.+) with valid data$/, "\u0E2A\u0E48\u0E07 $1 \u0E14\u0E49\u0E27\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^Navigate to (.+)$/, "\u0E44\u0E1B\u0E22\u0E31\u0E07 $1").replace(/^The application is available at (.+)$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E1E\u0E23\u0E49\u0E2D\u0E21\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19\u0E17\u0E35\u0E48 $1").replace(/^The application is available$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E1E\u0E23\u0E49\u0E2D\u0E21\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19").replace(/^Valid test data is prepared$/, "\u0E40\u0E15\u0E23\u0E35\u0E22\u0E21\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E41\u0E25\u0E49\u0E27").replace(/^Disposable test data is prepared$/, "\u0E40\u0E15\u0E23\u0E35\u0E22\u0E21\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E25\u0E1A\u0E44\u0E14\u0E49\u0E41\u0E25\u0E49\u0E27").replace(/^Leave "(.+)" empty$/, '\u0E40\u0E27\u0E49\u0E19\u0E0A\u0E48\u0E2D\u0E07 "$1" \u0E27\u0E48\u0E32\u0E07\u0E44\u0E27\u0E49').replace(/^Select "(.+)"$/, '\u0E40\u0E25\u0E37\u0E2D\u0E01 "$1"').replace(/^Verify that a validation message is displayed for the empty required field, and the form is not submitted\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E0A\u0E48\u0E2D\u0E07\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19\u0E0B\u0E36\u0E48\u0E07\u0E40\u0E27\u0E49\u0E19\u0E27\u0E48\u0E32\u0E07 \u0E41\u0E25\u0E30\u0E1F\u0E2D\u0E23\u0E4C\u0E21\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E2A\u0E48\u0E07").replace(/^The browser navigates to (.+) and the page "(.+)" is displayed\.$/, '\u0E40\u0E1A\u0E23\u0E32\u0E27\u0E4C\u0E40\u0E0B\u0E2D\u0E23\u0E4C\u0E44\u0E1B\u0E22\u0E31\u0E07 $1 \u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E2B\u0E19\u0E49\u0E32 "$2"').replace(/^The browser navigates to (.+)\.$/, "\u0E40\u0E1A\u0E23\u0E32\u0E27\u0E4C\u0E40\u0E0B\u0E2D\u0E23\u0E4C\u0E44\u0E1B\u0E22\u0E31\u0E07 $1").replace(/^Dialog "(.+)" is visible\.$/, '\u0E01\u0E25\u0E48\u0E2D\u0E07\u0E42\u0E15\u0E49\u0E15\u0E2D\u0E1A "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Validation message "(.+)" is visible\.$/, '\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19 "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Heading "(.+)" is visible\.$/, '\u0E2B\u0E31\u0E27\u0E02\u0E49\u0E2D "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Observed state requires tester review before automation\.$/, "\u0E2A\u0E16\u0E32\u0E19\u0E30\u0E17\u0E35\u0E48\u0E1E\u0E1A\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E01\u0E48\u0E2D\u0E19\u0E17\u0E33 Automation").replace(/^Verify "(.+)" action \(manual\)$/, '\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A action "$1" \u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07').replace(/^Open (.+)$/, "\u0E40\u0E1B\u0E34\u0E14 $1").replace(/^The page is reachable and rendered$/, "\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E1B\u0E34\u0E14\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25\u0E44\u0E14\u0E49").replace(/^Expected behavior is not known from static exploration; review manually\.$/, "\u0E44\u0E21\u0E48\u0E17\u0E23\u0E32\u0E1A\u0E1E\u0E24\u0E15\u0E34\u0E01\u0E23\u0E23\u0E21\u0E08\u0E32\u0E01\u0E01\u0E32\u0E23\u0E2A\u0E33\u0E23\u0E27\u0E08\u0E41\u0E1A\u0E1A static \u0E01\u0E23\u0E38\u0E13\u0E32\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07").replace(/^Verify that the result is displayed according to application requirements \(needs review by tester\)\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E41\u0E2A\u0E14\u0E07\u0E15\u0E32\u0E21\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E02\u0E2D\u0E07\u0E23\u0E30\u0E1A\u0E1A (\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A)").replace(/^Generated from elements detected on the page\.$/, "\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E15\u0E23\u0E27\u0E08\u0E1E\u0E1A\u0E1A\u0E19\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A").replace(/^Evidence: the field has the HTML "required" attribute\.$/, '\u0E2B\u0E25\u0E31\u0E01\u0E10\u0E32\u0E19: \u0E0A\u0E48\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E21\u0E35\u0E41\u0E2D\u0E15\u0E17\u0E23\u0E34\u0E1A\u0E34\u0E27\u0E15\u0E4C HTML "required"').replace(/^No "required" attribute found — confirm with the specification whether this field is mandatory\.$/, '\u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E41\u0E2D\u0E15\u0E17\u0E23\u0E34\u0E1A\u0E34\u0E27\u0E15\u0E4C "required" \u2014 \u0E42\u0E1B\u0E23\u0E14\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E01\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E27\u0E48\u0E32\u0E0A\u0E48\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E19\u0E35\u0E49\u0E1A\u0E31\u0E07\u0E04\u0E31\u0E1A\u0E01\u0E23\u0E2D\u0E01\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48').replace(/^Sample values are placeholders — replace them with real test data before running\.$/, "\u0E04\u0E48\u0E32\u0E15\u0E31\u0E27\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E1E\u0E35\u0E22\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E41\u0E17\u0E19\u0E17\u0E35\u0E48 \u2014 \u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E08\u0E23\u0E34\u0E07\u0E01\u0E48\u0E2D\u0E19\u0E40\u0E23\u0E34\u0E48\u0E21\u0E17\u0E14\u0E2A\u0E2D\u0E1A").replace(/^Explorer did not open this page — expected result needs review\.$/, "Explorer \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E40\u0E1B\u0E34\u0E14\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49 \u2014 \u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E17\u0E35\u0E48\u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07\u0E15\u0E49\u0E2D\u0E07\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A").replace(/^Detected as a potentially destructive action — Explorer did not click it\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E1E\u0E1A\u0E27\u0E48\u0E32\u0E2D\u0E32\u0E08\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E01\u0E23\u0E30\u0E17\u0E33\u0E17\u0E35\u0E48\u0E17\u0E33\u0E25\u0E32\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25 \u2014 Explorer \u0E08\u0E36\u0E07\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E04\u0E25\u0E34\u0E01").replace(/^Manually trigger (.+) "(.+)" in a safe test environment$/, '\u0E2A\u0E31\u0E48\u0E07\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19 $1 "$2" \u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07\u0E43\u0E19\u0E2A\u0E20\u0E32\u0E1E\u0E41\u0E27\u0E14\u0E25\u0E49\u0E2D\u0E21\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E1B\u0E25\u0E2D\u0E14\u0E20\u0E31\u0E22');
|
|
3295
|
+
return value.replace(/^Login with valid credentials via (.+)$/, "\u0E40\u0E02\u0E49\u0E32\u0E2A\u0E39\u0E48\u0E23\u0E30\u0E1A\u0E1A\u0E14\u0E49\u0E27\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E1C\u0E48\u0E32\u0E19 $1").replace(/^The form is submitted and the browser navigates to (.+?)[.]?$/, "\u0E1F\u0E2D\u0E23\u0E4C\u0E21\u0E16\u0E39\u0E01\u0E2A\u0E48\u0E07\u0E41\u0E25\u0E30\u0E40\u0E1A\u0E23\u0E32\u0E27\u0E4C\u0E40\u0E0B\u0E2D\u0E23\u0E4C\u0E44\u0E1B\u0E22\u0E31\u0E07 $1").replace(/^(.+) interaction works$/, "\u0E01\u0E32\u0E23\u0E17\u0E33\u0E07\u0E32\u0E19\u0E02\u0E2D\u0E07 $1 \u0E17\u0E33\u0E07\u0E32\u0E19\u0E44\u0E14\u0E49\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^(.+) "(.+)" opens and is usable\.$/, '$1 "$2" \u0E40\u0E1B\u0E34\u0E14\u0E41\u0E25\u0E30\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19\u0E44\u0E14\u0E49').replace(/^Generated from the observed (.+) interaction\.$/, "\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E1E\u0E1A interaction \u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17 $1").replace(/^Login with valid credentials via (.+)$/, "\u0E40\u0E02\u0E49\u0E32\u0E2A\u0E39\u0E48\u0E23\u0E30\u0E1A\u0E1A\u0E14\u0E49\u0E27\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E1C\u0E48\u0E32\u0E19 $1").replace(/^(.+) page displays required controls$/, "$1 \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19").replace(/^All (\d+) controls detected on the page are visible\.$/, "\u0E1E\u0E1A\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E1A\u0E19\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14 $1 \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25\u0E2D\u0E22\u0E39\u0E48").replace(/^(.+) is required$/, "$1 \u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19").replace(/^(.+) handles empty input$/, "$1 \u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E01\u0E32\u0E23\u0E40\u0E27\u0E49\u0E19\u0E27\u0E48\u0E32\u0E07").replace(/^(.+) rejects an invalid email format$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E2D\u0E35\u0E40\u0E21\u0E25\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^(.+) rejects an invalid URL format$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A URL \u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^(.+) handles whitespace-only input$/, "$1 \u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E21\u0E35\u0E41\u0E15\u0E48\u0E0A\u0E48\u0E2D\u0E07\u0E27\u0E48\u0E32\u0E07").replace(/^(.+) handles characters from another writing system$/, "$1 \u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23\u0E08\u0E32\u0E01\u0E20\u0E32\u0E29\u0E32\u0E2D\u0E37\u0E48\u0E19").replace(/^(.+) handles special characters$/, "$1 \u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30\u0E1E\u0E34\u0E40\u0E28\u0E29").replace(/^(.+) rejects fewer than (\d+) characters$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E2A\u0E31\u0E49\u0E19\u0E01\u0E27\u0E48\u0E32 $2 \u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23").replace(/^(.+) rejects a value outside the required pattern$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E15\u0E23\u0E07 Pattern").replace(/^(.+) rejects a value below (.+)$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E04\u0E48\u0E32\u0E17\u0E35\u0E48\u0E15\u0E48\u0E33\u0E01\u0E27\u0E48\u0E32 $2").replace(/^(.+) rejects a value above (.+)$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E04\u0E48\u0E32\u0E17\u0E35\u0E48\u0E2A\u0E39\u0E07\u0E01\u0E27\u0E48\u0E32 $2").replace(/^(.+) handles more than (\d+) characters$/, "$1 \u0E08\u0E31\u0E14\u0E01\u0E32\u0E23\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E22\u0E32\u0E27\u0E40\u0E01\u0E34\u0E19 $2 \u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23").replace(/^(.+) rejects a password without an uppercase letter$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E21\u0E35\u0E15\u0E31\u0E27\u0E1E\u0E34\u0E21\u0E1E\u0E4C\u0E43\u0E2B\u0E0D\u0E48").replace(/^(.+) rejects a password without a lowercase letter$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E21\u0E35\u0E15\u0E31\u0E27\u0E1E\u0E34\u0E21\u0E1E\u0E4C\u0E40\u0E25\u0E47\u0E01").replace(/^(.+) rejects a password without a number$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E21\u0E35\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02").replace(/^(.+) rejects a password without a special character$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E21\u0E35\u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30\u0E1E\u0E34\u0E40\u0E28\u0E29").replace(/^(.+) policy requires specification review$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E02\u0E2D\u0E07 $1").replace(/^Reject invalid username$/, "\u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A Username \u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^Reject invalid password$/, "\u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A Password \u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^Reject empty username$/, "\u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A Username \u0E17\u0E35\u0E48\u0E40\u0E27\u0E49\u0E19\u0E27\u0E48\u0E32\u0E07").replace(/^Reject empty password$/, "\u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A Password \u0E17\u0E35\u0E48\u0E40\u0E27\u0E49\u0E19\u0E27\u0E48\u0E32\u0E07").replace(/^Submit (.+) with valid data$/, "\u0E2A\u0E48\u0E07 $1 \u0E14\u0E49\u0E27\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^Navigate to (.+)$/, "\u0E44\u0E1B\u0E22\u0E31\u0E07 $1").replace(/^The application is available at (.+)$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E1E\u0E23\u0E49\u0E2D\u0E21\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19\u0E17\u0E35\u0E48 $1").replace(/^The application is available$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E1E\u0E23\u0E49\u0E2D\u0E21\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19").replace(/^Valid test data is prepared$/, "\u0E40\u0E15\u0E23\u0E35\u0E22\u0E21\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E41\u0E25\u0E49\u0E27").replace(/^Use a test environment where failed logins cannot lock a real account$/, "\u0E43\u0E0A\u0E49 Test environment \u0E17\u0E35\u0E48\u0E01\u0E32\u0E23 Login \u0E1C\u0E34\u0E14\u0E08\u0E30\u0E44\u0E21\u0E48\u0E25\u0E47\u0E2D\u0E01\u0E1A\u0E31\u0E0D\u0E0A\u0E35\u0E08\u0E23\u0E34\u0E07").replace(/^Disposable test data is prepared$/, "\u0E40\u0E15\u0E23\u0E35\u0E22\u0E21\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E25\u0E1A\u0E44\u0E14\u0E49\u0E41\u0E25\u0E49\u0E27").replace(/^Leave "(.+)" empty$/, '\u0E40\u0E27\u0E49\u0E19\u0E0A\u0E48\u0E2D\u0E07 "$1" \u0E27\u0E48\u0E32\u0E07\u0E44\u0E27\u0E49').replace(/^Select "(.+)"$/, '\u0E40\u0E25\u0E37\u0E2D\u0E01 "$1"').replace(/^Verify whether "(.+)" may be empty according to the product requirement$/, '\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32 "$1" \u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E27\u0E49\u0E19\u0E27\u0E48\u0E32\u0E07\u0E44\u0E14\u0E49\u0E15\u0E32\u0E21\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E02\u0E2D\u0E07\u0E1C\u0E25\u0E34\u0E15\u0E20\u0E31\u0E13\u0E11\u0E4C\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48').replace(/^Verify whether (.+) rejects whitespace-only input and shows the correct validation message$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32 $1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E21\u0E35\u0E41\u0E15\u0E48\u0E0A\u0E48\u0E2D\u0E07\u0E27\u0E48\u0E32\u0E07\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21 Validation \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^Verify the username character policy and the validation message shown for (.+)$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E19\u0E42\u0E22\u0E1A\u0E32\u0E22\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23 Username \u0E41\u0E25\u0E30\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21 Validation \u0E17\u0E35\u0E48\u0E41\u0E2A\u0E14\u0E07\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A $1").replace(/^Verify whether (.+) permits special characters and shows the correct validation message$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32 $1 \u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30\u0E1E\u0E34\u0E40\u0E28\u0E29\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21 Validation \u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^Verify that a validation message is displayed for the empty required field, and the form is not submitted\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E0A\u0E48\u0E2D\u0E07\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19\u0E0B\u0E36\u0E48\u0E07\u0E40\u0E27\u0E49\u0E19\u0E27\u0E48\u0E32\u0E07 \u0E41\u0E25\u0E30\u0E1F\u0E2D\u0E23\u0E4C\u0E21\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E2A\u0E48\u0E07").replace(/^A required-field validation is displayed and the form is not submitted\.$/, "\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21 validation \u0E02\u0E2D\u0E07\u0E0A\u0E48\u0E2D\u0E07\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19\u0E41\u0E2A\u0E14\u0E07\u0E02\u0E36\u0E49\u0E19 \u0E41\u0E25\u0E30\u0E1F\u0E2D\u0E23\u0E4C\u0E21\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E2A\u0E48\u0E07").replace(/^(.+) accepts or rejects empty input according to the product requirement\.$/, "$1 \u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E40\u0E27\u0E49\u0E19\u0E27\u0E48\u0E32\u0E07\u0E15\u0E32\u0E21\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E02\u0E2D\u0E07\u0E1C\u0E25\u0E34\u0E15\u0E20\u0E31\u0E13\u0E11\u0E4C").replace(/^(.+) is marked invalid and the form is not submitted\.$/, "$1 \u0E16\u0E39\u0E01\u0E23\u0E30\u0E1A\u0E38\u0E27\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 \u0E41\u0E25\u0E30\u0E1F\u0E2D\u0E23\u0E4C\u0E21\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E2A\u0E48\u0E07").replace(/^(.+) rejects whitespace-only input when meaningful text is required\.$/, "$1 \u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E21\u0E35\u0E41\u0E15\u0E48\u0E0A\u0E48\u0E2D\u0E07\u0E27\u0E48\u0E32\u0E07\u0E40\u0E21\u0E37\u0E48\u0E2D\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E0A\u0E49\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E17\u0E35\u0E48\u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E2B\u0E21\u0E32\u0E22").replace(/^(.+) accepts or rejects characters from another writing system according to the username policy\.$/, "$1 \u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23\u0E08\u0E32\u0E01\u0E20\u0E32\u0E29\u0E32\u0E2D\u0E37\u0E48\u0E19\u0E15\u0E32\u0E21\u0E19\u0E42\u0E22\u0E1A\u0E32\u0E22 Username").replace(/^(.+) accepts or rejects special characters according to the username policy\.$/, "$1 \u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30\u0E1E\u0E34\u0E40\u0E28\u0E29\u0E15\u0E32\u0E21\u0E19\u0E42\u0E22\u0E1A\u0E32\u0E22 Username").replace(/^(.+) remains invalid below the minimum length of (\d+)\.$/, "$1 \u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E21\u0E37\u0E48\u0E2D\u0E2A\u0E31\u0E49\u0E19\u0E01\u0E27\u0E48\u0E32\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E02\u0E31\u0E49\u0E19\u0E15\u0E48\u0E33 $2").replace(/^(.+) remains invalid when its pattern is not satisfied\.$/, "$1 \u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E21\u0E37\u0E48\u0E2D\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E15\u0E23\u0E07 Pattern").replace(/^(.+) remains invalid below the minimum value (.+)\.$/, "$1 \u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E21\u0E37\u0E48\u0E2D\u0E04\u0E48\u0E32\u0E15\u0E48\u0E33\u0E01\u0E27\u0E48\u0E32\u0E04\u0E48\u0E32\u0E02\u0E31\u0E49\u0E19\u0E15\u0E48\u0E33 $2").replace(/^(.+) remains invalid above the maximum value (.+)\.$/, "$1 \u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E40\u0E21\u0E37\u0E48\u0E2D\u0E04\u0E48\u0E32\u0E2A\u0E39\u0E07\u0E01\u0E27\u0E48\u0E32\u0E04\u0E48\u0E32\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14 $2").replace(/^(.+) prevents or rejects input above (\d+) characters\.$/, "$1 \u0E1B\u0E49\u0E2D\u0E07\u0E01\u0E31\u0E19\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48\u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E22\u0E32\u0E27\u0E40\u0E01\u0E34\u0E19 $2 \u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23").replace(/^(.+) remains invalid until the password policy is satisfied\.$/, "$1 \u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E08\u0E19\u0E01\u0E27\u0E48\u0E32\u0E08\u0E30\u0E1C\u0E48\u0E32\u0E19\u0E19\u0E42\u0E22\u0E1A\u0E32\u0E22\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19").replace(/^The application keeps the user signed out and displays an authentication error\.$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E43\u0E0A\u0E49\u0E40\u0E02\u0E49\u0E32\u0E2A\u0E39\u0E48\u0E23\u0E30\u0E1A\u0E1A\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E15\u0E31\u0E27\u0E15\u0E19").replace(/^The application keeps the user signed out and displays a username validation error\.$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E43\u0E0A\u0E49\u0E40\u0E02\u0E49\u0E32\u0E2A\u0E39\u0E48\u0E23\u0E30\u0E1A\u0E1A\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E02\u0E2D\u0E07 Username").replace(/^The application keeps the user signed out and displays a password validation error\.$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E43\u0E0A\u0E49\u0E40\u0E02\u0E49\u0E32\u0E2A\u0E39\u0E48\u0E23\u0E30\u0E1A\u0E1A\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E02\u0E2D\u0E07 Password").replace(/^Confirm whether uppercase, lowercase, number, special-character, and length rules are required\.$/, "\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E27\u0E48\u0E32\u0E23\u0E30\u0E1A\u0E1A\u0E15\u0E49\u0E2D\u0E07\u0E1A\u0E31\u0E07\u0E04\u0E31\u0E1A\u0E15\u0E31\u0E27\u0E1E\u0E34\u0E21\u0E1E\u0E4C\u0E43\u0E2B\u0E0D\u0E48 \u0E15\u0E31\u0E27\u0E1E\u0E34\u0E21\u0E1E\u0E4C\u0E40\u0E25\u0E47\u0E01 \u0E15\u0E31\u0E27\u0E40\u0E25\u0E02 \u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30\u0E1E\u0E34\u0E40\u0E28\u0E29 \u0E41\u0E25\u0E30\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48").replace(/^The browser navigates to (.+) and the page "(.+)" is displayed\.$/, '\u0E40\u0E1A\u0E23\u0E32\u0E27\u0E4C\u0E40\u0E0B\u0E2D\u0E23\u0E4C\u0E44\u0E1B\u0E22\u0E31\u0E07 $1 \u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E2B\u0E19\u0E49\u0E32 "$2"').replace(/^The browser navigates to (.+)\.$/, "\u0E40\u0E1A\u0E23\u0E32\u0E27\u0E4C\u0E40\u0E0B\u0E2D\u0E23\u0E4C\u0E44\u0E1B\u0E22\u0E31\u0E07 $1").replace(/^Dialog "(.+)" is visible\.$/, '\u0E01\u0E25\u0E48\u0E2D\u0E07\u0E42\u0E15\u0E49\u0E15\u0E2D\u0E1A "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Validation message "(.+)" is visible\.$/, '\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19 "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Heading "(.+)" is visible\.$/, '\u0E2B\u0E31\u0E27\u0E02\u0E49\u0E2D "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Observed state requires tester review before automation\.$/, "\u0E2A\u0E16\u0E32\u0E19\u0E30\u0E17\u0E35\u0E48\u0E1E\u0E1A\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E01\u0E48\u0E2D\u0E19\u0E17\u0E33 Automation").replace(/^Verify "(.+)" action \(manual\)$/, '\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A action "$1" \u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07').replace(/^Open (.+)$/, "\u0E40\u0E1B\u0E34\u0E14 $1").replace(/^The page is reachable and rendered$/, "\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E1B\u0E34\u0E14\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25\u0E44\u0E14\u0E49").replace(/^Expected behavior is not known from static exploration; review manually\.$/, "\u0E44\u0E21\u0E48\u0E17\u0E23\u0E32\u0E1A\u0E1E\u0E24\u0E15\u0E34\u0E01\u0E23\u0E23\u0E21\u0E08\u0E32\u0E01\u0E01\u0E32\u0E23\u0E2A\u0E33\u0E23\u0E27\u0E08\u0E41\u0E1A\u0E1A static \u0E01\u0E23\u0E38\u0E13\u0E32\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07").replace(/^Verify that the result is displayed according to application requirements \(needs review by tester\)\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E41\u0E2A\u0E14\u0E07\u0E15\u0E32\u0E21\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E02\u0E2D\u0E07\u0E23\u0E30\u0E1A\u0E1A (\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A)").replace(/^Generated from elements detected on the page\.$/, "\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E15\u0E23\u0E27\u0E08\u0E1E\u0E1A\u0E1A\u0E19\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A").replace(/^Evidence: the field has the HTML "required" attribute\.$/, '\u0E2B\u0E25\u0E31\u0E01\u0E10\u0E32\u0E19: \u0E0A\u0E48\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E21\u0E35\u0E41\u0E2D\u0E15\u0E17\u0E23\u0E34\u0E1A\u0E34\u0E27\u0E15\u0E4C HTML "required"').replace(/^Evidence: the field has the HTML "required" attribute\. Playwright waits for the field to become invalid\.$/, '\u0E2B\u0E25\u0E31\u0E01\u0E10\u0E32\u0E19: \u0E0A\u0E48\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E21\u0E35\u0E41\u0E2D\u0E15\u0E17\u0E23\u0E34\u0E1A\u0E34\u0E27\u0E15\u0E4C HTML "required" \u0E41\u0E25\u0E30 Playwright \u0E08\u0E30\u0E23\u0E2D\u0E08\u0E19\u0E01\u0E27\u0E48\u0E32\u0E0A\u0E48\u0E2D\u0E07\u0E08\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E2A\u0E16\u0E32\u0E19\u0E30\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07').replace(/^Generated from input type="(.+)"\.$/, '\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01 input type="$1"').replace(/^HTML required accepts whitespace\. Review this case against the product rule and the displayed message\.$/, "HTML required \u0E22\u0E2D\u0E21\u0E23\u0E31\u0E1A\u0E0A\u0E48\u0E2D\u0E07\u0E27\u0E48\u0E32\u0E07 \u0E08\u0E36\u0E07\u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E27\u0E08\u0E01\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E41\u0E25\u0E30\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E17\u0E35\u0E48\u0E41\u0E2A\u0E14\u0E07").replace(/^No username character policy is inferred unless the HTML exposes a pattern\. Review the result against requirements\.$/, "\u0E08\u0E30\u0E44\u0E21\u0E48\u0E40\u0E14\u0E32\u0E19\u0E42\u0E22\u0E1A\u0E32\u0E22\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23\u0E02\u0E2D\u0E07 Username \u0E16\u0E49\u0E32 HTML \u0E44\u0E21\u0E48\u0E21\u0E35 pattern \u0E01\u0E23\u0E38\u0E13\u0E32\u0E15\u0E23\u0E27\u0E08\u0E01\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14").replace(/^Generated as a business-rule review because HTML may not expose the server username policy\.$/, "\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E04\u0E2A\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A Business rule \u0E40\u0E1E\u0E23\u0E32\u0E30 HTML \u0E2D\u0E32\u0E08\u0E44\u0E21\u0E48\u0E40\u0E1B\u0E34\u0E14\u0E40\u0E1C\u0E22\u0E19\u0E42\u0E22\u0E1A\u0E32\u0E22 Username \u0E02\u0E2D\u0E07 Server").replace(/^Generated from minlength="(.+)"\.$/, '\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01 minlength="$1"').replace(/^Generated from min="(.+)"\.$/, '\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01 min="$1"').replace(/^Generated from max="(.+)"\.$/, '\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01 max="$1"').replace(/^Generated from pattern="(.+)"\.$/, '\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01 pattern="$1"').replace(/^Generated from the password pattern="(.+)"\.$/, '\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01 Password pattern="$1"').replace(/^Runs one failed login attempt only\. Review the observed server message before marking this case ready\.$/, "\u0E22\u0E34\u0E07 Login \u0E1C\u0E34\u0E14\u0E40\u0E1E\u0E35\u0E22\u0E07\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E04\u0E23\u0E31\u0E49\u0E07 \u0E41\u0E25\u0E30\u0E15\u0E23\u0E27\u0E08\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E08\u0E32\u0E01 Server \u0E01\u0E48\u0E2D\u0E19\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E04\u0E2A\u0E40\u0E1B\u0E47\u0E19 Ready").replace(/^No minlength, maxlength, or pattern was found in the HTML\. LazyScout does not invent a password policy\.$/, "\u0E44\u0E21\u0E48\u0E1E\u0E1A minlength, maxlength \u0E2B\u0E23\u0E37\u0E2D pattern \u0E43\u0E19 HTML \u0E42\u0E14\u0E22 LazyScout \u0E08\u0E30\u0E44\u0E21\u0E48\u0E40\u0E14\u0E32\u0E19\u0E42\u0E22\u0E1A\u0E32\u0E22\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19\u0E02\u0E36\u0E49\u0E19\u0E40\u0E2D\u0E07").replace(/^No required attribute was detected\. Confirm whether an empty value is allowed before automating submission\.$/, "\u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E41\u0E2D\u0E15\u0E17\u0E23\u0E34\u0E1A\u0E34\u0E27\u0E15\u0E4C required \u0E01\u0E23\u0E38\u0E13\u0E32\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E27\u0E48\u0E32\u0E2D\u0E19\u0E38\u0E0D\u0E32\u0E15\u0E43\u0E2B\u0E49\u0E40\u0E27\u0E49\u0E19\u0E27\u0E48\u0E32\u0E07\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48\u0E01\u0E48\u0E2D\u0E19\u0E17\u0E33 Automation \u0E2A\u0E48\u0E07\u0E1F\u0E2D\u0E23\u0E4C\u0E21").replace(/^No "required" attribute found — confirm with the specification whether this field is mandatory\.$/, '\u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E41\u0E2D\u0E15\u0E17\u0E23\u0E34\u0E1A\u0E34\u0E27\u0E15\u0E4C "required" \u2014 \u0E42\u0E1B\u0E23\u0E14\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E01\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E27\u0E48\u0E32\u0E0A\u0E48\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E19\u0E35\u0E49\u0E1A\u0E31\u0E07\u0E04\u0E31\u0E1A\u0E01\u0E23\u0E2D\u0E01\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48').replace(/^Sample values are placeholders — replace them with real test data before running\.$/, "\u0E04\u0E48\u0E32\u0E15\u0E31\u0E27\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E1E\u0E35\u0E22\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E41\u0E17\u0E19\u0E17\u0E35\u0E48 \u2014 \u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E08\u0E23\u0E34\u0E07\u0E01\u0E48\u0E2D\u0E19\u0E40\u0E23\u0E34\u0E48\u0E21\u0E17\u0E14\u0E2A\u0E2D\u0E1A").replace(/^Explorer did not open this page — expected result needs review\.$/, "Explorer \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E40\u0E1B\u0E34\u0E14\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49 \u2014 \u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E17\u0E35\u0E48\u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07\u0E15\u0E49\u0E2D\u0E07\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A").replace(/^Detected as a potentially destructive action — Explorer did not click it\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E1E\u0E1A\u0E27\u0E48\u0E32\u0E2D\u0E32\u0E08\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E01\u0E23\u0E30\u0E17\u0E33\u0E17\u0E35\u0E48\u0E17\u0E33\u0E25\u0E32\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25 \u2014 Explorer \u0E08\u0E36\u0E07\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E04\u0E25\u0E34\u0E01").replace(/^Manually trigger (.+) "(.+)" in a safe test environment$/, '\u0E2A\u0E31\u0E48\u0E07\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19 $1 "$2" \u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07\u0E43\u0E19\u0E2A\u0E20\u0E32\u0E1E\u0E41\u0E27\u0E14\u0E25\u0E49\u0E2D\u0E21\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E1B\u0E25\u0E2D\u0E14\u0E20\u0E31\u0E22');
|
|
2237
3296
|
}
|
|
2238
3297
|
function safeNormalize(url) {
|
|
2239
3298
|
try {
|
|
@@ -2392,70 +3451,163 @@ function exportTestCasesToCsv(testCases, testData = []) {
|
|
|
2392
3451
|
return UTF8_BOM + lines.join("\r\n") + "\r\n";
|
|
2393
3452
|
}
|
|
2394
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
|
+
|
|
2395
3511
|
// ../../packages/generators/dist/playwright/generatePlaywrightTest.js
|
|
2396
3512
|
function generatePlaywrightTest(testCase) {
|
|
2397
3513
|
const lines = [
|
|
2398
3514
|
`import { test, expect } from '@playwright/test'`,
|
|
2399
3515
|
"",
|
|
2400
|
-
|
|
3516
|
+
...locatorResolverSource(),
|
|
3517
|
+
"",
|
|
3518
|
+
`test(${quote2(testCase.title)}, async ({ page }) => {`
|
|
2401
3519
|
];
|
|
2402
3520
|
for (const step of testCase.steps)
|
|
2403
3521
|
lines.push(` ${playwrightStep(step)}`);
|
|
2404
3522
|
lines.push("})", "");
|
|
2405
3523
|
return lines.join("\n");
|
|
2406
3524
|
}
|
|
3525
|
+
var RESOLVE_TIMEOUT_MS = 5e3;
|
|
3526
|
+
var RESOLVE_POLL_MS = 100;
|
|
3527
|
+
function locatorResolverSource() {
|
|
3528
|
+
return [
|
|
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
|
+
` }`,
|
|
3550
|
+
` }`,
|
|
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
|
+
` )`,
|
|
3564
|
+
`}`
|
|
3565
|
+
];
|
|
3566
|
+
}
|
|
2407
3567
|
function locator(target) {
|
|
2408
|
-
const
|
|
2409
|
-
const
|
|
2410
|
-
const
|
|
2411
|
-
return
|
|
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))})`;
|
|
2412
3572
|
}
|
|
2413
3573
|
function playwrightStep(step) {
|
|
2414
3574
|
switch (step.type) {
|
|
2415
3575
|
case "navigate":
|
|
2416
|
-
return `await page.goto(${
|
|
3576
|
+
return `await page.goto(${quote2(plainUrl(step.url))})`;
|
|
2417
3577
|
case "click":
|
|
2418
|
-
return `await ${locator(step.target)}.click()`;
|
|
3578
|
+
return `await (await ${locator(step.target)}).click()`;
|
|
2419
3579
|
case "fill":
|
|
2420
|
-
return `await ${locator(step.target)}.fill(${
|
|
3580
|
+
return `await (await ${locator(step.target)}).fill(${quote2(step.value)})`;
|
|
2421
3581
|
case "select":
|
|
2422
|
-
return `await ${locator(step.target)}.selectOption(${
|
|
3582
|
+
return `await (await ${locator(step.target)}).selectOption(${quote2(step.option)})`;
|
|
2423
3583
|
case "check":
|
|
2424
|
-
return `await ${locator(step.target)}.${step.checked ? "check" : "uncheck"}()`;
|
|
3584
|
+
return `await (await ${locator(step.target)}).${step.checked ? "check" : "uncheck"}()`;
|
|
2425
3585
|
case "wait":
|
|
2426
3586
|
if (step.mode === "timeout")
|
|
2427
3587
|
return `await page.waitForTimeout(${Math.min(5e3, Math.max(0, Number(step.value) || 0))})`;
|
|
2428
3588
|
if (step.mode === "url")
|
|
2429
|
-
return `await page.waitForURL(new RegExp(${
|
|
3589
|
+
return `await page.waitForURL(new RegExp(${quote2(step.value)}))`;
|
|
2430
3590
|
if (step.mode === "text")
|
|
2431
|
-
return `await expect(page).toContainText(${
|
|
2432
|
-
return `await expect(${locator(step.target)}).toBeVisible()`;
|
|
3591
|
+
return `await expect(page).toContainText(${quote2(step.value)})`;
|
|
3592
|
+
return `await expect(await ${locator(step.target)}).toBeVisible()`;
|
|
2433
3593
|
case "assertVisible":
|
|
2434
|
-
return `await expect(${locator(step.target)}).toBeVisible()`;
|
|
3594
|
+
return `await expect(await ${locator(step.target)}).toBeVisible()`;
|
|
2435
3595
|
case "assertText":
|
|
2436
|
-
return step.target ? `await expect(${locator(step.target)}).toContainText(${
|
|
3596
|
+
return step.target ? `await expect(await ${locator(step.target)}).toContainText(${quote2(step.text)})` : `await expect(page.locator('body')).toContainText(${quote2(step.text)})`;
|
|
2437
3597
|
case "assertUrl":
|
|
2438
|
-
return `await expect(page).toHaveURL(new RegExp(${
|
|
3598
|
+
return `await expect(page).toHaveURL(new RegExp(${quote2(step.urlContains)}))`;
|
|
3599
|
+
case "assertInvalid":
|
|
3600
|
+
return `expect(await (await ${locator(step.target)}).evaluate((element) => element.matches(':invalid'))).toBe(true)`;
|
|
3601
|
+
case "assertValidation":
|
|
3602
|
+
return `await expect(page.locator('[role="alert"], [aria-invalid="true"], .error, .errors, .invalid-feedback, #error').filter({ visible: true }).first()).toBeVisible()`;
|
|
2439
3603
|
case "manual":
|
|
2440
3604
|
return `// TODO: ${step.description}`;
|
|
2441
3605
|
}
|
|
2442
3606
|
}
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
if (hint.includes("email") || hint.includes("\u0E2D\u0E35\u0E40\u0E21\u0E25"))
|
|
2448
|
-
return "{{TEST_EMAIL}}";
|
|
2449
|
-
if (hint.includes("username") || hint.includes("user name") || hint.includes("\u0E0A\u0E37\u0E48\u0E2D\u0E1C\u0E39\u0E49\u0E43\u0E0A\u0E49"))
|
|
2450
|
-
return "{{TEST_USERNAME}}";
|
|
2451
|
-
return step.value;
|
|
2452
|
-
}
|
|
2453
|
-
var quote = (value) => JSON.stringify(value);
|
|
2454
|
-
function normalizeCssSelector(value) {
|
|
2455
|
-
return value.replace(/\\(["'])/g, "$1");
|
|
2456
|
-
}
|
|
2457
|
-
function quoteCssSelector(value) {
|
|
2458
|
-
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();
|
|
2459
3611
|
}
|
|
2460
3612
|
|
|
2461
3613
|
// ../../packages/generators/dist/guidedflow/flowToTestCase.js
|
|
@@ -2546,18 +3698,29 @@ function playwrightFlowStep(flow, step) {
|
|
|
2546
3698
|
}
|
|
2547
3699
|
}
|
|
2548
3700
|
function locator2(target) {
|
|
3701
|
+
if (preferStableCss(target)) {
|
|
3702
|
+
return `page.locator(${quoteCssSelector2(normalizeCssSelector2(target.cssSelector ?? target.value ?? ""))})`;
|
|
3703
|
+
}
|
|
2549
3704
|
if (target.strategy === "role" || target.role && target.name)
|
|
2550
|
-
return `page.getByRole(${JSON.stringify(target.role ?? "generic")}, { name: ${JSON.stringify(target.name ?? target.value ?? "")}
|
|
3705
|
+
return `page.getByRole(${JSON.stringify(target.role ?? "generic")}, { name: ${JSON.stringify(target.name ?? target.value ?? "")}, exact: true })`;
|
|
2551
3706
|
if (target.strategy === "label" || target.label)
|
|
2552
3707
|
return `page.getByLabel(${JSON.stringify(target.label ?? target.value ?? "")}, { exact: true })`;
|
|
2553
3708
|
if (target.strategy === "placeholder" || target.placeholder)
|
|
2554
3709
|
return `page.getByPlaceholder(${JSON.stringify(target.placeholder ?? target.value ?? "")})`;
|
|
2555
|
-
if (target.strategy === "testid" || target.testId)
|
|
2556
|
-
|
|
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
|
+
}
|
|
2557
3714
|
if (target.strategy === "text" || target.text)
|
|
2558
3715
|
return `page.getByText(${JSON.stringify(target.text ?? target.value ?? "")})`;
|
|
2559
3716
|
return `page.locator(${quoteCssSelector2(normalizeCssSelector2(target.cssSelector ?? target.value ?? ""))})`;
|
|
2560
3717
|
}
|
|
3718
|
+
function preferStableCss(target) {
|
|
3719
|
+
return Boolean(target.cssSelector && (target.strategy === "css" || target.matchCount !== void 0 && target.matchCount > 1 && !target.contextSelector && !target.contextText));
|
|
3720
|
+
}
|
|
3721
|
+
function attributeSelector(name, value) {
|
|
3722
|
+
return `[${name}="${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"]`;
|
|
3723
|
+
}
|
|
2561
3724
|
function normalizeCssSelector2(value) {
|
|
2562
3725
|
return value.replace(/\\(["'])/g, "$1");
|
|
2563
3726
|
}
|
|
@@ -2993,7 +4156,10 @@ function normalizeResult(value) {
|
|
|
2993
4156
|
blockedActionKeys: Array.isArray(actionGraph?.blockedActionKeys) ? actionGraph.blockedActionKeys : []
|
|
2994
4157
|
},
|
|
2995
4158
|
runEvents: Array.isArray(value?.runEvents) ? value.runEvents : [],
|
|
2996
|
-
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 } : {}
|
|
2997
4163
|
};
|
|
2998
4164
|
}
|
|
2999
4165
|
function enqueueMutation(key, action) {
|
|
@@ -3023,7 +4189,7 @@ function registerAnalyzeRoute(app, workspaceRoot) {
|
|
|
3023
4189
|
try {
|
|
3024
4190
|
const abortController = new AbortController();
|
|
3025
4191
|
let completed = false;
|
|
3026
|
-
|
|
4192
|
+
reply.raw.once("close", () => {
|
|
3027
4193
|
if (!completed)
|
|
3028
4194
|
abortController.abort();
|
|
3029
4195
|
});
|
|
@@ -3123,7 +4289,9 @@ function registerAnalyzeRoute(app, workspaceRoot) {
|
|
|
3123
4289
|
stats: result.stats,
|
|
3124
4290
|
actionGraph: result.actionGraph,
|
|
3125
4291
|
runEvents,
|
|
3126
|
-
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 } : {}
|
|
3127
4295
|
};
|
|
3128
4296
|
completed = true;
|
|
3129
4297
|
return reply.send(response);
|
|
@@ -3145,11 +4313,11 @@ function generateStateFlowTestCases(graph) {
|
|
|
3145
4313
|
if (!target || !source)
|
|
3146
4314
|
return [];
|
|
3147
4315
|
const observation = expectedObservation(target);
|
|
3148
|
-
const
|
|
4316
|
+
const id2 = `TC-FLOW-${String(sequence).padStart(3, "0")}`;
|
|
3149
4317
|
sequence += 1;
|
|
3150
4318
|
return [
|
|
3151
4319
|
{
|
|
3152
|
-
id,
|
|
4320
|
+
id: id2,
|
|
3153
4321
|
module: "FLOW",
|
|
3154
4322
|
tags: ["state-flow"],
|
|
3155
4323
|
title: `${edge.action.description} reaches ${target.name}`,
|
|
@@ -3631,7 +4799,7 @@ function registerLoadTestRoute(app) {
|
|
|
3631
4799
|
const started = Date.now();
|
|
3632
4800
|
async function worker(virtualUser) {
|
|
3633
4801
|
for (let count = 0; count < requestsPerUser; count++) {
|
|
3634
|
-
const
|
|
4802
|
+
const id2 = ++requestSequence;
|
|
3635
4803
|
const requestStarted = Date.now();
|
|
3636
4804
|
try {
|
|
3637
4805
|
const response2 = await fetch(url, { signal: AbortSignal.timeout(15e3), redirect: "follow" });
|
|
@@ -3641,7 +4809,7 @@ function registerLoadTestRoute(app) {
|
|
|
3641
4809
|
if (!response2.ok)
|
|
3642
4810
|
errors.push(`HTTP ${response2.status} ${response2.statusText}`.trim());
|
|
3643
4811
|
requests.push({
|
|
3644
|
-
id,
|
|
4812
|
+
id: id2,
|
|
3645
4813
|
virtualUser,
|
|
3646
4814
|
iteration: count + 1,
|
|
3647
4815
|
method: "GET",
|
|
@@ -3659,7 +4827,7 @@ function registerLoadTestRoute(app) {
|
|
|
3659
4827
|
timings.push(durationMs);
|
|
3660
4828
|
errors.push(message);
|
|
3661
4829
|
requests.push({
|
|
3662
|
-
id,
|
|
4830
|
+
id: id2,
|
|
3663
4831
|
virtualUser,
|
|
3664
4832
|
iteration: count + 1,
|
|
3665
4833
|
method: "GET",
|
|
@@ -3962,26 +5130,38 @@ var RecorderSessions = class {
|
|
|
3962
5130
|
startUrl: session.startUrl,
|
|
3963
5131
|
startedAt: session.startedAt,
|
|
3964
5132
|
browserLabel: session.browserLabel,
|
|
3965
|
-
|
|
5133
|
+
currentUrl: safeDisplayUrl(this.currentPage(session)?.url() ?? session.startUrl),
|
|
5134
|
+
pointerCursor: session.pointerCursor,
|
|
5135
|
+
steps: session.finalSteps ?? session.handle.steps(),
|
|
5136
|
+
inspection: session.inspection
|
|
3966
5137
|
};
|
|
3967
5138
|
}
|
|
3968
5139
|
async start(projectId, startUrl) {
|
|
3969
5140
|
const launched = await this.launch(projectId);
|
|
5141
|
+
let session;
|
|
3970
5142
|
const handle = await attachRecorder(launched.context, startUrl, {
|
|
3971
5143
|
onEnded: () => {
|
|
3972
5144
|
const current = this.sessions.get(projectId);
|
|
3973
5145
|
if (current)
|
|
3974
5146
|
void this.finish(current);
|
|
5147
|
+
},
|
|
5148
|
+
onInspection: (inspection) => {
|
|
5149
|
+
if (session)
|
|
5150
|
+
session.inspection = inspection;
|
|
3975
5151
|
}
|
|
3976
5152
|
});
|
|
3977
|
-
|
|
5153
|
+
session = {
|
|
3978
5154
|
projectId,
|
|
3979
5155
|
startUrl,
|
|
3980
5156
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3981
5157
|
browserLabel: launched.label,
|
|
5158
|
+
context: launched.context,
|
|
3982
5159
|
handle,
|
|
3983
5160
|
close: launched.close,
|
|
3984
|
-
closed: false
|
|
5161
|
+
closed: false,
|
|
5162
|
+
inspectMode: false,
|
|
5163
|
+
pointerCursor: "default",
|
|
5164
|
+
interactionQueue: Promise.resolve()
|
|
3985
5165
|
};
|
|
3986
5166
|
this.sessions.set(projectId, session);
|
|
3987
5167
|
const page = launched.context.pages()[0] ?? await launched.context.newPage();
|
|
@@ -3995,6 +5175,59 @@ var RecorderSessions = class {
|
|
|
3995
5175
|
await this.finish(session);
|
|
3996
5176
|
return this.state(projectId);
|
|
3997
5177
|
}
|
|
5178
|
+
async setInspectMode(projectId, enabled) {
|
|
5179
|
+
const session = this.sessions.get(projectId);
|
|
5180
|
+
if (!session || session.closed)
|
|
5181
|
+
return idleRecorderState(projectId);
|
|
5182
|
+
await session.handle.setInspectMode(enabled);
|
|
5183
|
+
session.inspectMode = enabled;
|
|
5184
|
+
if (!enabled)
|
|
5185
|
+
session.inspection = void 0;
|
|
5186
|
+
return this.state(projectId);
|
|
5187
|
+
}
|
|
5188
|
+
async frame(projectId) {
|
|
5189
|
+
const session = this.runningSession(projectId);
|
|
5190
|
+
const page = this.currentPage(session);
|
|
5191
|
+
if (!page)
|
|
5192
|
+
throw new Error("The recorder page is not available.");
|
|
5193
|
+
return page.screenshot({ type: "jpeg", quality: 78, animations: "disabled", caret: "hide", timeout: 5e3 });
|
|
5194
|
+
}
|
|
5195
|
+
async interact(projectId, interaction) {
|
|
5196
|
+
const session = this.runningSession(projectId);
|
|
5197
|
+
session.interactionQueue = session.interactionQueue.catch(() => void 0).then(async () => {
|
|
5198
|
+
const page = this.currentPage(session);
|
|
5199
|
+
if (!page)
|
|
5200
|
+
throw new Error("The recorder page is not available.");
|
|
5201
|
+
if (interaction.type === "click") {
|
|
5202
|
+
await page.mouse.click(interaction.x, interaction.y);
|
|
5203
|
+
if (session.inspectMode)
|
|
5204
|
+
await page.waitForTimeout(25);
|
|
5205
|
+
} else if (interaction.type === "move") {
|
|
5206
|
+
await page.mouse.move(interaction.x, interaction.y);
|
|
5207
|
+
session.pointerCursor = await pointerCursorAt(page, interaction.x, interaction.y);
|
|
5208
|
+
} else if (interaction.type === "text")
|
|
5209
|
+
await page.keyboard.insertText(interaction.text);
|
|
5210
|
+
else if (interaction.type === "key")
|
|
5211
|
+
await page.keyboard.press(interaction.key);
|
|
5212
|
+
else if (interaction.type === "scroll")
|
|
5213
|
+
await page.mouse.wheel(interaction.deltaX, interaction.deltaY);
|
|
5214
|
+
else if (interaction.type === "navigate") {
|
|
5215
|
+
await page.goto(interaction.url, { waitUntil: "domcontentloaded" });
|
|
5216
|
+
session.handle.recordNavigation(page.url());
|
|
5217
|
+
} else if (interaction.type === "back") {
|
|
5218
|
+
await page.goBack({ waitUntil: "domcontentloaded" });
|
|
5219
|
+
session.handle.recordNavigation(page.url());
|
|
5220
|
+
} else if (interaction.type === "forward") {
|
|
5221
|
+
await page.goForward({ waitUntil: "domcontentloaded" });
|
|
5222
|
+
session.handle.recordNavigation(page.url());
|
|
5223
|
+
} else {
|
|
5224
|
+
await page.reload({ waitUntil: "domcontentloaded" });
|
|
5225
|
+
session.handle.recordNavigation(page.url(), true);
|
|
5226
|
+
}
|
|
5227
|
+
});
|
|
5228
|
+
await session.interactionQueue;
|
|
5229
|
+
return this.state(projectId);
|
|
5230
|
+
}
|
|
3998
5231
|
/**
|
|
3999
5232
|
* Forgets a session once the operator has saved or discarded it, so reopening
|
|
4000
5233
|
* the panel starts a fresh recording instead of the previous one.
|
|
@@ -4017,11 +5250,45 @@ var RecorderSessions = class {
|
|
|
4017
5250
|
session.closed = true;
|
|
4018
5251
|
await session.close().catch(() => void 0);
|
|
4019
5252
|
}
|
|
5253
|
+
runningSession(projectId) {
|
|
5254
|
+
const session = this.sessions.get(projectId);
|
|
5255
|
+
if (!session || session.closed)
|
|
5256
|
+
throw new Error("No recorder is running for this Project.");
|
|
5257
|
+
return session;
|
|
5258
|
+
}
|
|
5259
|
+
currentPage(session) {
|
|
5260
|
+
const pages = session.context.pages().filter((page) => !page.isClosed());
|
|
5261
|
+
return pages[pages.length - 1];
|
|
5262
|
+
}
|
|
4020
5263
|
};
|
|
5264
|
+
async function pointerCursorAt(page, x, y) {
|
|
5265
|
+
return page.evaluate(`(() => {
|
|
5266
|
+
const element = document.elementFromPoint(${JSON.stringify(x)}, ${JSON.stringify(y)})
|
|
5267
|
+
if (!element) return 'default'
|
|
5268
|
+
const styleCursor = getComputedStyle(element).cursor
|
|
5269
|
+
if (['pointer', 'text', 'not-allowed', 'grab', 'crosshair'].includes(styleCursor)) return styleCursor
|
|
5270
|
+
const interactive = element.closest(
|
|
5271
|
+
'a[href],button,select,summary,label,[role="button"],[role="link"],[role="tab"],[role="menuitem"],[role="checkbox"],[role="radio"],input[type="button"],input[type="submit"],input[type="checkbox"],input[type="radio"]'
|
|
5272
|
+
)
|
|
5273
|
+
if (interactive) return interactive.matches(':disabled,[aria-disabled="true"]') ? 'not-allowed' : 'pointer'
|
|
5274
|
+
const textInput = element.closest(
|
|
5275
|
+
'textarea,input:not([type]),input[type="text"],input[type="email"],input[type="password"],input[type="search"],input[type="url"],input[type="tel"],input[type="number"],[contenteditable="true"]'
|
|
5276
|
+
)
|
|
5277
|
+
return textInput ? 'text' : 'default'
|
|
5278
|
+
})()`).catch(() => "default");
|
|
5279
|
+
}
|
|
5280
|
+
function safeDisplayUrl(value) {
|
|
5281
|
+
try {
|
|
5282
|
+
const url = new URL(value);
|
|
5283
|
+
return `${url.origin}${url.pathname}`;
|
|
5284
|
+
} catch {
|
|
5285
|
+
return value.split(/[?#]/, 1)[0];
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
4021
5288
|
|
|
4022
5289
|
// ../server/dist/routes/recorder.js
|
|
4023
5290
|
function registerRecorderRoutes(app, workspaceRoot, options = {}) {
|
|
4024
|
-
const launch = options.launch ?? (async (projectId) => launchBrowser({ userDataDir: await browserProfileDirectory(workspaceRoot, projectId), headless:
|
|
5291
|
+
const launch = options.launch ?? (async (projectId) => launchBrowser({ userDataDir: await browserProfileDirectory(workspaceRoot, projectId), headless: true }));
|
|
4025
5292
|
const sessions = new RecorderSessions(launch);
|
|
4026
5293
|
app.post("/api/recorder/:projectId/start", async (request, reply) => {
|
|
4027
5294
|
const { projectId } = request.params;
|
|
@@ -4053,11 +5320,59 @@ function registerRecorderRoutes(app, workspaceRoot, options = {}) {
|
|
|
4053
5320
|
});
|
|
4054
5321
|
app.get("/api/recorder/:projectId", async (request) => sessions.state(request.params.projectId));
|
|
4055
5322
|
app.post("/api/recorder/:projectId/stop", async (request, reply) => reply.send(await sessions.stop(request.params.projectId)));
|
|
5323
|
+
app.post("/api/recorder/:projectId/inspect", async (request, reply) => {
|
|
5324
|
+
const body = request.body;
|
|
5325
|
+
return reply.send(await sessions.setInspectMode(request.params.projectId, body?.enabled === true));
|
|
5326
|
+
});
|
|
5327
|
+
app.get("/api/recorder/:projectId/frame", async (request, reply) => {
|
|
5328
|
+
try {
|
|
5329
|
+
const frame = await sessions.frame(request.params.projectId);
|
|
5330
|
+
return reply.header("Content-Type", "image/jpeg").header("Cache-Control", "no-store").send(frame);
|
|
5331
|
+
} catch (error) {
|
|
5332
|
+
return reply.status(409).send({
|
|
5333
|
+
error: { code: "recorder-frame-unavailable", message: error instanceof Error ? error.message : String(error) }
|
|
5334
|
+
});
|
|
5335
|
+
}
|
|
5336
|
+
});
|
|
5337
|
+
app.post("/api/recorder/:projectId/interact", async (request, reply) => {
|
|
5338
|
+
let interaction = request.body;
|
|
5339
|
+
if (!isRecorderInteraction(interaction))
|
|
5340
|
+
return reply.status(400).send({ error: { code: "invalid-recorder-interaction", message: "Invalid interaction." } });
|
|
5341
|
+
if (interaction.type === "navigate") {
|
|
5342
|
+
const check = checkTargetUrl(interaction.url, config.urlPolicy);
|
|
5343
|
+
if (!check.ok)
|
|
5344
|
+
return reply.status(400).send({ error: { code: check.code, message: check.message } });
|
|
5345
|
+
interaction = { type: "navigate", url: check.url.toString() };
|
|
5346
|
+
}
|
|
5347
|
+
try {
|
|
5348
|
+
return reply.send(await sessions.interact(request.params.projectId, interaction));
|
|
5349
|
+
} catch (error) {
|
|
5350
|
+
return reply.status(409).send({
|
|
5351
|
+
error: { code: "recorder-interaction-failed", message: error instanceof Error ? error.message : String(error) }
|
|
5352
|
+
});
|
|
5353
|
+
}
|
|
5354
|
+
});
|
|
4056
5355
|
app.delete("/api/recorder/:projectId", async (request, reply) => reply.send(await sessions.discard(request.params.projectId)));
|
|
4057
5356
|
app.addHook("onClose", async () => {
|
|
4058
5357
|
await sessions.closeAll();
|
|
4059
5358
|
});
|
|
4060
5359
|
}
|
|
5360
|
+
function isRecorderInteraction(value) {
|
|
5361
|
+
if (!value || typeof value !== "object")
|
|
5362
|
+
return false;
|
|
5363
|
+
const interaction = value;
|
|
5364
|
+
if (interaction.type === "click" || interaction.type === "move")
|
|
5365
|
+
return Number.isFinite(interaction.x) && Number.isFinite(interaction.y);
|
|
5366
|
+
if (interaction.type === "text")
|
|
5367
|
+
return typeof interaction.text === "string" && interaction.text.length <= 500;
|
|
5368
|
+
if (interaction.type === "key")
|
|
5369
|
+
return typeof interaction.key === "string" && interaction.key.length <= 80;
|
|
5370
|
+
if (interaction.type === "scroll")
|
|
5371
|
+
return Number.isFinite(interaction.deltaX) && Number.isFinite(interaction.deltaY);
|
|
5372
|
+
if (interaction.type === "navigate")
|
|
5373
|
+
return typeof interaction.url === "string" && interaction.url.length <= 2048;
|
|
5374
|
+
return interaction.type === "back" || interaction.type === "forward" || interaction.type === "reload";
|
|
5375
|
+
}
|
|
4061
5376
|
|
|
4062
5377
|
// ../server/dist/routes/guidedFlowRun.js
|
|
4063
5378
|
var activeRuns2 = /* @__PURE__ */ new Map();
|
|
@@ -4204,7 +5519,7 @@ async function openInBrowser(url) {
|
|
|
4204
5519
|
}
|
|
4205
5520
|
|
|
4206
5521
|
// src/version.ts
|
|
4207
|
-
var VERSION = true ? "0.
|
|
5522
|
+
var VERSION = true ? "0.4.2" : "0.0.0-dev";
|
|
4208
5523
|
|
|
4209
5524
|
// src/commands/serve.ts
|
|
4210
5525
|
var DEFAULT_PORT = 4321;
|