@riddledc/riddle-proof 0.7.43 → 0.7.45
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 +13 -0
- package/dist/{chunk-ZB5DSQF2.js → chunk-IJGMTTVP.js} +152 -25
- package/dist/cli.cjs +152 -25
- package/dist/cli.js +1 -1
- package/dist/index.cjs +152 -25
- package/dist/index.js +1 -1
- package/dist/profile.cjs +152 -25
- package/dist/profile.d.cts +4 -0
- package/dist/profile.d.ts +4 -0
- package/dist/profile.js +1 -1
- package/package.json +1 -1
package/dist/profile.cjs
CHANGED
|
@@ -296,6 +296,15 @@ function normalizeNetworkMock(input, index) {
|
|
|
296
296
|
const payload = normalizeNetworkMockResponsePayload(input, `target.network_mocks[${index}]`);
|
|
297
297
|
const responsesInput = input.responses ?? input.sequence;
|
|
298
298
|
const responses = normalizeNetworkMockResponses(responsesInput, index, payload);
|
|
299
|
+
const requestBodyContains = normalizeStringList(
|
|
300
|
+
input.request_body_contains ?? input.requestBodyContains ?? input.body_contains ?? input.bodyContains,
|
|
301
|
+
`target.network_mocks[${index}].request_body_contains`
|
|
302
|
+
);
|
|
303
|
+
const requestBodyPatterns = normalizeStringList(
|
|
304
|
+
input.request_body_patterns ?? input.requestBodyPatterns ?? input.body_patterns ?? input.bodyPatterns,
|
|
305
|
+
`target.network_mocks[${index}].request_body_patterns`
|
|
306
|
+
);
|
|
307
|
+
validateRegexPatterns(requestBodyPatterns, `target.network_mocks[${index}].request_body_patterns`);
|
|
299
308
|
const requiredHitCount = numberValue(
|
|
300
309
|
input.required_hit_count ?? input.requiredHitCount ?? input.required_hits ?? input.requiredHits ?? input.min_hits ?? input.minHits
|
|
301
310
|
);
|
|
@@ -310,7 +319,10 @@ function normalizeNetworkMock(input, index) {
|
|
|
310
319
|
responses,
|
|
311
320
|
repeat_responses: input.repeat_responses === true || input.repeatResponses === true || input.cycle_responses === true || input.cycleResponses === true,
|
|
312
321
|
required_hit_count: requiredHitCount,
|
|
313
|
-
required: input.required === false ? false : true
|
|
322
|
+
required: input.required === false ? false : true,
|
|
323
|
+
capture_request_body: input.capture_request_body === true || input.captureRequestBody === true || Boolean(requestBodyContains?.length) || Boolean(requestBodyPatterns?.length),
|
|
324
|
+
request_body_contains: requestBodyContains,
|
|
325
|
+
request_body_patterns: requestBodyPatterns
|
|
314
326
|
};
|
|
315
327
|
}
|
|
316
328
|
function normalizeNetworkMockResponsePayload(input, label, defaults = {}) {
|
|
@@ -393,6 +405,16 @@ function normalizeStringList(value, label) {
|
|
|
393
405
|
if (!values.length) throw new Error(`${label} must contain non-empty strings.`);
|
|
394
406
|
return values;
|
|
395
407
|
}
|
|
408
|
+
function validateRegexPatterns(patterns, label) {
|
|
409
|
+
for (const pattern of patterns || []) {
|
|
410
|
+
try {
|
|
411
|
+
new RegExp(pattern);
|
|
412
|
+
} catch (error) {
|
|
413
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
414
|
+
throw new Error(`${label} contains invalid regex ${JSON.stringify(pattern)}: ${message}`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
396
418
|
function normalizeCheck(input, index) {
|
|
397
419
|
if (!isRecord(input)) throw new Error(`checks[${index}] must be an object.`);
|
|
398
420
|
const type = stringValue(input.type);
|
|
@@ -445,6 +467,7 @@ function normalizeCheck(input, index) {
|
|
|
445
467
|
text: stringValue(input.text),
|
|
446
468
|
pattern: stringValue(input.pattern),
|
|
447
469
|
flags: stringValue(input.flags),
|
|
470
|
+
viewports: normalizeStringList(input.viewports ?? input.viewport_names ?? input.viewportNames, `checks[${index}] viewports`),
|
|
448
471
|
allowed_console_texts: normalizeStringList(input.allowed_console_texts ?? input.allowedConsoleTexts ?? input.allow_console_texts ?? input.allowConsoleTexts, `checks[${index}] allowed_console_texts`),
|
|
449
472
|
allowed_console_patterns: normalizeStringList(input.allowed_console_patterns ?? input.allowedConsolePatterns ?? input.allow_console_patterns ?? input.allowConsolePatterns, `checks[${index}] allowed_console_patterns`),
|
|
450
473
|
allowed_page_error_texts: normalizeStringList(input.allowed_page_error_texts ?? input.allowedPageErrorTexts ?? input.allow_page_error_texts ?? input.allowPageErrorTexts, `checks[${index}] allowed_page_error_texts`),
|
|
@@ -683,15 +706,22 @@ function successfulRoute(route, targetUrl) {
|
|
|
683
706
|
const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
|
|
684
707
|
return matched && !route.error && (route.http_status === null || route.http_status === void 0 || route.http_status < 400);
|
|
685
708
|
}
|
|
709
|
+
function viewportsForCheck(check, viewports) {
|
|
710
|
+
if (!check.viewports?.length) return viewports;
|
|
711
|
+
const names = new Set(check.viewports);
|
|
712
|
+
return viewports.filter((viewport) => names.has(viewport.name));
|
|
713
|
+
}
|
|
686
714
|
function assessCheckFromEvidence(check, evidence) {
|
|
687
|
-
const viewports = evidence.viewports || [];
|
|
715
|
+
const viewports = viewportsForCheck(check, evidence.viewports || []);
|
|
688
716
|
if (!viewports.length) {
|
|
689
717
|
return {
|
|
690
718
|
type: check.type,
|
|
691
719
|
label: checkLabel(check),
|
|
692
720
|
status: "failed",
|
|
693
|
-
evidence: {
|
|
694
|
-
|
|
721
|
+
evidence: {
|
|
722
|
+
expected_viewports: check.viewports || []
|
|
723
|
+
},
|
|
724
|
+
message: check.viewports?.length ? `No matching viewport evidence was captured for ${check.viewports.join(", ")}.` : "No viewport evidence was captured."
|
|
695
725
|
};
|
|
696
726
|
}
|
|
697
727
|
if (check.type === "route_loaded") {
|
|
@@ -1055,6 +1085,17 @@ function assessNetworkMocksFromEvidence(profile, evidence) {
|
|
|
1055
1085
|
reason: event.reason ?? event.error ?? "mock_failed"
|
|
1056
1086
|
});
|
|
1057
1087
|
}
|
|
1088
|
+
if (event.request_body_matches === false) {
|
|
1089
|
+
failed.push({
|
|
1090
|
+
label: event.label ?? null,
|
|
1091
|
+
url: event.url ?? null,
|
|
1092
|
+
method: event.method ?? null,
|
|
1093
|
+
reason: "request_body_mismatch",
|
|
1094
|
+
request_body_failures: event.request_body_failures ?? [],
|
|
1095
|
+
request_body_length: event.request_body_length ?? null,
|
|
1096
|
+
request_body_sample: event.request_body_sample ?? null
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1058
1099
|
}
|
|
1059
1100
|
return {
|
|
1060
1101
|
type: "network_mocks_succeeded",
|
|
@@ -1296,6 +1337,11 @@ function frameTextSample(frame) {
|
|
|
1296
1337
|
frame && frame.text,
|
|
1297
1338
|
].map((part) => String(part || "")).filter(Boolean).join(" ");
|
|
1298
1339
|
}
|
|
1340
|
+
function viewportsForCheck(check, viewports) {
|
|
1341
|
+
if (!Array.isArray(check.viewports) || !check.viewports.length) return viewports;
|
|
1342
|
+
const names = new Set(check.viewports);
|
|
1343
|
+
return viewports.filter((viewport) => names.has(viewport.name));
|
|
1344
|
+
}
|
|
1299
1345
|
function summarizeRouteInventory(viewport, inventory) {
|
|
1300
1346
|
const directRoutes = Array.isArray(inventory.direct_routes) ? inventory.direct_routes : [];
|
|
1301
1347
|
const clickthroughs = Array.isArray(inventory.clickthroughs) ? inventory.clickthroughs : [];
|
|
@@ -1422,6 +1468,17 @@ function assessProfile(profile, evidence) {
|
|
|
1422
1468
|
reason: event.reason || event.error || "mock_failed",
|
|
1423
1469
|
});
|
|
1424
1470
|
}
|
|
1471
|
+
if (event && event.request_body_matches === false) {
|
|
1472
|
+
failed.push({
|
|
1473
|
+
label: event.label || null,
|
|
1474
|
+
url: event.url || null,
|
|
1475
|
+
method: event.method || null,
|
|
1476
|
+
reason: "request_body_mismatch",
|
|
1477
|
+
request_body_failures: event.request_body_failures || [],
|
|
1478
|
+
request_body_length: event.request_body_length || null,
|
|
1479
|
+
request_body_sample: event.request_body_sample || null,
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1425
1482
|
}
|
|
1426
1483
|
const hitsByLabel = {};
|
|
1427
1484
|
const requiredHitsByLabel = {};
|
|
@@ -1486,9 +1543,22 @@ function assessProfile(profile, evidence) {
|
|
|
1486
1543
|
});
|
|
1487
1544
|
}
|
|
1488
1545
|
for (const check of profile.checks || []) {
|
|
1546
|
+
const checkViewports = viewportsForCheck(check, viewports);
|
|
1547
|
+
if (!checkViewports.length) {
|
|
1548
|
+
checks.push({
|
|
1549
|
+
type: check.type,
|
|
1550
|
+
label: check.label || check.type,
|
|
1551
|
+
status: "failed",
|
|
1552
|
+
evidence: { expected_viewports: check.viewports || [] },
|
|
1553
|
+
message: Array.isArray(check.viewports) && check.viewports.length
|
|
1554
|
+
? "No matching viewport evidence was captured for " + check.viewports.join(", ") + "."
|
|
1555
|
+
: "No viewport evidence was captured.",
|
|
1556
|
+
});
|
|
1557
|
+
continue;
|
|
1558
|
+
}
|
|
1489
1559
|
if (check.type === "route_loaded") {
|
|
1490
1560
|
const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
|
|
1491
|
-
const failed =
|
|
1561
|
+
const failed = checkViewports.filter((viewport) => {
|
|
1492
1562
|
const route = { ...(viewport.route || {}), expected_path: expectedPath };
|
|
1493
1563
|
route.matched = routePathMatches(route.observed, expectedPath, evidence.target_url) || route.matched;
|
|
1494
1564
|
return !routeOk(route, evidence.target_url);
|
|
@@ -1499,8 +1569,8 @@ function assessProfile(profile, evidence) {
|
|
|
1499
1569
|
status: failed.length ? "failed" : "passed",
|
|
1500
1570
|
evidence: {
|
|
1501
1571
|
expected_path: expectedPath,
|
|
1502
|
-
observed_paths:
|
|
1503
|
-
http_statuses:
|
|
1572
|
+
observed_paths: checkViewports.map((viewport) => viewport.route && viewport.route.observed),
|
|
1573
|
+
http_statuses: checkViewports.map((viewport) => viewport.route ? viewport.route.http_status ?? null : null),
|
|
1504
1574
|
},
|
|
1505
1575
|
message: failed.length ? "Route did not load as " + expectedPath + " in " + failed.length + " viewport(s)." : undefined,
|
|
1506
1576
|
});
|
|
@@ -1508,24 +1578,24 @@ function assessProfile(profile, evidence) {
|
|
|
1508
1578
|
}
|
|
1509
1579
|
if (check.type === "selector_visible") {
|
|
1510
1580
|
const selector = check.selector || "";
|
|
1511
|
-
const failed =
|
|
1581
|
+
const failed = checkViewports.filter((viewport) => !viewport.selectors || !viewport.selectors[selector] || viewport.selectors[selector].visible_count < 1);
|
|
1512
1582
|
checks.push({
|
|
1513
1583
|
type: check.type,
|
|
1514
1584
|
label: check.label || check.type,
|
|
1515
1585
|
status: failed.length ? "failed" : "passed",
|
|
1516
|
-
evidence: { selector, visible_counts:
|
|
1586
|
+
evidence: { selector, visible_counts: checkViewports.map((viewport) => viewport.selectors && viewport.selectors[selector] ? viewport.selectors[selector].visible_count : 0) },
|
|
1517
1587
|
message: failed.length ? "Selector " + selector + " was not visible in " + failed.length + " viewport(s)." : undefined,
|
|
1518
1588
|
});
|
|
1519
1589
|
continue;
|
|
1520
1590
|
}
|
|
1521
1591
|
if (check.type === "selector_absent") {
|
|
1522
1592
|
const selector = check.selector || "";
|
|
1523
|
-
const failed =
|
|
1593
|
+
const failed = checkViewports.filter((viewport) => viewport.selectors && viewport.selectors[selector] && viewport.selectors[selector].count > 0);
|
|
1524
1594
|
checks.push({
|
|
1525
1595
|
type: check.type,
|
|
1526
1596
|
label: check.label || check.type,
|
|
1527
1597
|
status: failed.length ? "failed" : "passed",
|
|
1528
|
-
evidence: { selector, counts:
|
|
1598
|
+
evidence: { selector, counts: checkViewports.map((viewport) => viewport.selectors && viewport.selectors[selector] ? viewport.selectors[selector].count : 0) },
|
|
1529
1599
|
message: failed.length ? "Selector " + selector + " was present in " + failed.length + " viewport(s)." : undefined,
|
|
1530
1600
|
});
|
|
1531
1601
|
continue;
|
|
@@ -1533,12 +1603,12 @@ function assessProfile(profile, evidence) {
|
|
|
1533
1603
|
if (check.type === "selector_count_at_least") {
|
|
1534
1604
|
const selector = check.selector || "";
|
|
1535
1605
|
const minCount = check.min_count == null ? 1 : check.min_count;
|
|
1536
|
-
const failed =
|
|
1606
|
+
const failed = checkViewports.filter((viewport) => !viewport.selectors || !viewport.selectors[selector] || viewport.selectors[selector].count < minCount);
|
|
1537
1607
|
checks.push({
|
|
1538
1608
|
type: check.type,
|
|
1539
1609
|
label: check.label || check.type,
|
|
1540
1610
|
status: failed.length ? "failed" : "passed",
|
|
1541
|
-
evidence: { selector, min_count: minCount, counts:
|
|
1611
|
+
evidence: { selector, min_count: minCount, counts: checkViewports.map((viewport) => viewport.selectors && viewport.selectors[selector] ? viewport.selectors[selector].count : 0) },
|
|
1542
1612
|
message: failed.length ? "Selector " + selector + " count was below " + minCount + " in " + failed.length + " viewport(s)." : undefined,
|
|
1543
1613
|
});
|
|
1544
1614
|
continue;
|
|
@@ -1546,12 +1616,12 @@ function assessProfile(profile, evidence) {
|
|
|
1546
1616
|
if (check.type === "selector_count_equals" || check.type === "selector_count_equal" || check.type === "selector_count_eq") {
|
|
1547
1617
|
const selector = check.selector || "";
|
|
1548
1618
|
const expectedCount = check.expected_count == null ? 0 : check.expected_count;
|
|
1549
|
-
const failed =
|
|
1619
|
+
const failed = checkViewports.filter((viewport) => (viewport.selectors && viewport.selectors[selector] ? viewport.selectors[selector].count : 0) !== expectedCount);
|
|
1550
1620
|
checks.push({
|
|
1551
1621
|
type: check.type,
|
|
1552
1622
|
label: check.label || check.type,
|
|
1553
1623
|
status: failed.length ? "failed" : "passed",
|
|
1554
|
-
evidence: { selector, expected_count: expectedCount, counts:
|
|
1624
|
+
evidence: { selector, expected_count: expectedCount, counts: checkViewports.map((viewport) => viewport.selectors && viewport.selectors[selector] ? viewport.selectors[selector].count : 0) },
|
|
1555
1625
|
message: failed.length ? "Selector " + selector + " count did not equal " + expectedCount + " in " + failed.length + " viewport(s)." : undefined,
|
|
1556
1626
|
});
|
|
1557
1627
|
continue;
|
|
@@ -1559,7 +1629,7 @@ function assessProfile(profile, evidence) {
|
|
|
1559
1629
|
if (check.type === "selector_text_order") {
|
|
1560
1630
|
const selector = check.selector || "";
|
|
1561
1631
|
const expectedTexts = check.expected_texts || [];
|
|
1562
|
-
const results =
|
|
1632
|
+
const results = checkViewports.map((viewport) => {
|
|
1563
1633
|
const texts = textSequenceForCheck(viewport, check);
|
|
1564
1634
|
const match = textOrderMatch(texts, expectedTexts);
|
|
1565
1635
|
return {
|
|
@@ -1581,7 +1651,7 @@ function assessProfile(profile, evidence) {
|
|
|
1581
1651
|
}
|
|
1582
1652
|
if (check.type === "frame_text_visible") {
|
|
1583
1653
|
const selector = check.selector || "";
|
|
1584
|
-
const results =
|
|
1654
|
+
const results = checkViewports.map((viewport) => {
|
|
1585
1655
|
const frames = frameEvidenceForSelector(viewport, selector);
|
|
1586
1656
|
const matches = frames
|
|
1587
1657
|
.map((frame, index) => ({ index, frame, matched: textMatches(frameTextSample(frame), check) }))
|
|
@@ -1608,7 +1678,7 @@ function assessProfile(profile, evidence) {
|
|
|
1608
1678
|
if (check.type === "frame_no_horizontal_overflow") {
|
|
1609
1679
|
const selector = check.selector || "";
|
|
1610
1680
|
const maxOverflow = check.max_overflow_px == null ? 4 : check.max_overflow_px;
|
|
1611
|
-
const results =
|
|
1681
|
+
const results = checkViewports.map((viewport) => {
|
|
1612
1682
|
const frames = frameEvidenceForSelector(viewport, selector);
|
|
1613
1683
|
const frameOverflows = frames.map((frame, index) => ({
|
|
1614
1684
|
index,
|
|
@@ -1638,7 +1708,7 @@ function assessProfile(profile, evidence) {
|
|
|
1638
1708
|
if (check.type === "text_visible" || check.type === "text_absent") {
|
|
1639
1709
|
const key = check.pattern ? "pattern:" + check.pattern + "/" + (check.flags || "") : "text:" + (check.text || "");
|
|
1640
1710
|
const expectedVisible = check.type === "text_visible";
|
|
1641
|
-
const matches =
|
|
1711
|
+
const matches = checkViewports.map((viewport) => viewport.text_matches && typeof viewport.text_matches[key] === "boolean" ? viewport.text_matches[key] : textMatches(viewport.body_text_sample || "", check));
|
|
1642
1712
|
const failed = matches.filter((matched) => matched !== expectedVisible).length;
|
|
1643
1713
|
checks.push({
|
|
1644
1714
|
type: check.type,
|
|
@@ -1650,7 +1720,7 @@ function assessProfile(profile, evidence) {
|
|
|
1650
1720
|
continue;
|
|
1651
1721
|
}
|
|
1652
1722
|
if (check.type === "route_inventory") {
|
|
1653
|
-
const inventories =
|
|
1723
|
+
const inventories = checkViewports
|
|
1654
1724
|
.map((viewport) => ({ viewport: viewport.name, inventory: viewport.route_inventory }))
|
|
1655
1725
|
.filter((item) => item.inventory && typeof item.inventory === "object");
|
|
1656
1726
|
if (!inventories.length) {
|
|
@@ -1702,7 +1772,7 @@ function assessProfile(profile, evidence) {
|
|
|
1702
1772
|
}
|
|
1703
1773
|
if (check.type === "no_horizontal_overflow" || check.type === "no_mobile_horizontal_overflow") {
|
|
1704
1774
|
const maxOverflow = check.max_overflow_px == null ? 4 : check.max_overflow_px;
|
|
1705
|
-
const applicable = check.type === "no_mobile_horizontal_overflow" ?
|
|
1775
|
+
const applicable = check.type === "no_mobile_horizontal_overflow" ? checkViewports.filter((viewport) => viewport.width <= 820) : checkViewports;
|
|
1706
1776
|
if (!applicable.length) {
|
|
1707
1777
|
checks.push({
|
|
1708
1778
|
type: check.type,
|
|
@@ -1857,6 +1927,52 @@ function compactSetupResultText(value) {
|
|
|
1857
1927
|
if (text.length <= 500) return text;
|
|
1858
1928
|
return text.slice(0, 500) + "... (" + text.length + " chars)";
|
|
1859
1929
|
}
|
|
1930
|
+
function compactNetworkMockRequestBody(value) {
|
|
1931
|
+
const text = String(value || "").replace(/\s+/g, " ").trim();
|
|
1932
|
+
if (text.length <= 1000) return text;
|
|
1933
|
+
return text.slice(0, 1000) + "... (" + text.length + " chars)";
|
|
1934
|
+
}
|
|
1935
|
+
function networkMockStringList(value) {
|
|
1936
|
+
return Array.isArray(value) ? value.map((item) => String(item)).filter(Boolean) : [];
|
|
1937
|
+
}
|
|
1938
|
+
function networkMockShouldCaptureRequestBody(mock) {
|
|
1939
|
+
return mock && (
|
|
1940
|
+
mock.capture_request_body === true
|
|
1941
|
+
|| networkMockStringList(mock.request_body_contains).length > 0
|
|
1942
|
+
|| networkMockStringList(mock.request_body_patterns).length > 0
|
|
1943
|
+
);
|
|
1944
|
+
}
|
|
1945
|
+
function networkMockRequestBodyFailures(body, mock) {
|
|
1946
|
+
const failures = [];
|
|
1947
|
+
const rawBody = String(body || "");
|
|
1948
|
+
const compactBody = compactNetworkMockRequestBody(rawBody);
|
|
1949
|
+
for (const expected of networkMockStringList(mock.request_body_contains)) {
|
|
1950
|
+
if (!rawBody.includes(expected) && !compactBody.includes(expected)) {
|
|
1951
|
+
failures.push({
|
|
1952
|
+
type: "request_body_missing_text",
|
|
1953
|
+
text: String(expected).slice(0, 200),
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
for (const pattern of networkMockStringList(mock.request_body_patterns)) {
|
|
1958
|
+
try {
|
|
1959
|
+
const regex = new RegExp(pattern);
|
|
1960
|
+
if (!regex.test(rawBody) && !regex.test(compactBody)) {
|
|
1961
|
+
failures.push({
|
|
1962
|
+
type: "request_body_pattern_not_matched",
|
|
1963
|
+
pattern: String(pattern).slice(0, 200),
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
} catch (error) {
|
|
1967
|
+
failures.push({
|
|
1968
|
+
type: "request_body_invalid_pattern",
|
|
1969
|
+
pattern: String(pattern).slice(0, 200),
|
|
1970
|
+
error: String(error && error.message ? error.message : error).slice(0, 500),
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
return failures;
|
|
1975
|
+
}
|
|
1860
1976
|
async function setupLocatorVisible(locator, index) {
|
|
1861
1977
|
return await locator.nth(index).isVisible({ timeout: 1000 }).catch(() => false);
|
|
1862
1978
|
}
|
|
@@ -1885,7 +2001,11 @@ async function registerNetworkMocks(mocks) {
|
|
|
1885
2001
|
body = JSON.stringify(response.body_json);
|
|
1886
2002
|
contentType = response.content_type || headers["content-type"] || headers["Content-Type"] || "application/json";
|
|
1887
2003
|
}
|
|
1888
|
-
|
|
2004
|
+
const shouldCaptureRequestBody = networkMockShouldCaptureRequestBody(mock);
|
|
2005
|
+
const requestBody = shouldCaptureRequestBody && request.postData ? request.postData() || "" : "";
|
|
2006
|
+
const requestBodyFailures = shouldCaptureRequestBody ? networkMockRequestBodyFailures(requestBody, mock) : [];
|
|
2007
|
+
const status = response.status || mock.status || 200;
|
|
2008
|
+
const event = {
|
|
1889
2009
|
ok: true,
|
|
1890
2010
|
label: mock.label,
|
|
1891
2011
|
response_label: response.label || null,
|
|
@@ -1895,10 +2015,17 @@ async function registerNetworkMocks(mocks) {
|
|
|
1895
2015
|
sequence_cycle: responseIndex !== null && mock.repeat_responses === true && hitIndex >= responses.length,
|
|
1896
2016
|
url: request.url(),
|
|
1897
2017
|
method,
|
|
1898
|
-
status
|
|
1899
|
-
}
|
|
2018
|
+
status,
|
|
2019
|
+
};
|
|
2020
|
+
if (shouldCaptureRequestBody) {
|
|
2021
|
+
event.request_body_matches = requestBodyFailures.length === 0;
|
|
2022
|
+
event.request_body_failures = requestBodyFailures;
|
|
2023
|
+
event.request_body_length = requestBody.length;
|
|
2024
|
+
event.request_body_sample = compactNetworkMockRequestBody(requestBody);
|
|
2025
|
+
}
|
|
2026
|
+
networkMockEvents.push(event);
|
|
1900
2027
|
await route.fulfill({
|
|
1901
|
-
status
|
|
2028
|
+
status,
|
|
1902
2029
|
headers,
|
|
1903
2030
|
contentType,
|
|
1904
2031
|
body,
|
package/dist/profile.d.cts
CHANGED
|
@@ -50,6 +50,9 @@ interface RiddleProofProfileNetworkMock extends RiddleProofProfileNetworkMockRes
|
|
|
50
50
|
repeat_responses?: boolean;
|
|
51
51
|
required_hit_count?: number;
|
|
52
52
|
required?: boolean;
|
|
53
|
+
capture_request_body?: boolean;
|
|
54
|
+
request_body_contains?: string[];
|
|
55
|
+
request_body_patterns?: string[];
|
|
53
56
|
}
|
|
54
57
|
interface RiddleProofProfileRouteInventoryRoute {
|
|
55
58
|
name?: string;
|
|
@@ -83,6 +86,7 @@ interface RiddleProofProfileCheck {
|
|
|
83
86
|
text?: string;
|
|
84
87
|
pattern?: string;
|
|
85
88
|
flags?: string;
|
|
89
|
+
viewports?: string[];
|
|
86
90
|
allowed_console_texts?: string[];
|
|
87
91
|
allowed_console_patterns?: string[];
|
|
88
92
|
allowed_page_error_texts?: string[];
|
package/dist/profile.d.ts
CHANGED
|
@@ -50,6 +50,9 @@ interface RiddleProofProfileNetworkMock extends RiddleProofProfileNetworkMockRes
|
|
|
50
50
|
repeat_responses?: boolean;
|
|
51
51
|
required_hit_count?: number;
|
|
52
52
|
required?: boolean;
|
|
53
|
+
capture_request_body?: boolean;
|
|
54
|
+
request_body_contains?: string[];
|
|
55
|
+
request_body_patterns?: string[];
|
|
53
56
|
}
|
|
54
57
|
interface RiddleProofProfileRouteInventoryRoute {
|
|
55
58
|
name?: string;
|
|
@@ -83,6 +86,7 @@ interface RiddleProofProfileCheck {
|
|
|
83
86
|
text?: string;
|
|
84
87
|
pattern?: string;
|
|
85
88
|
flags?: string;
|
|
89
|
+
viewports?: string[];
|
|
86
90
|
allowed_console_texts?: string[];
|
|
87
91
|
allowed_console_patterns?: string[];
|
|
88
92
|
allowed_page_error_texts?: string[];
|
package/dist/profile.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
resolveRiddleProofProfileTimeoutSec,
|
|
20
20
|
slugifyRiddleProofProfileName,
|
|
21
21
|
summarizeRiddleProofProfileResult
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-IJGMTTVP.js";
|
|
23
23
|
export {
|
|
24
24
|
RIDDLE_PROOF_PROFILE_CHECK_TYPES,
|
|
25
25
|
RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
|