@riddledc/riddle-proof 0.7.57 → 0.7.59
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 -3
- package/dist/{chunk-H5LDZKGN.js → chunk-Q5VW6MAP.js} +171 -33
- package/dist/cli.cjs +171 -33
- package/dist/cli.js +1 -1
- package/dist/index.cjs +171 -33
- package/dist/index.js +1 -1
- package/dist/profile.cjs +171 -33
- package/dist/profile.d.cts +3 -1
- package/dist/profile.d.ts +3 -1
- package/dist/profile.js +1 -1
- package/dist/proof-run-engine.d.cts +3 -3
- package/dist/proof-run-engine.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8746,6 +8746,7 @@ var RIDDLE_PROOF_PROFILE_CHECK_TYPES = [
|
|
|
8746
8746
|
];
|
|
8747
8747
|
var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
|
|
8748
8748
|
"click",
|
|
8749
|
+
"press",
|
|
8749
8750
|
"fill",
|
|
8750
8751
|
"set_input_value",
|
|
8751
8752
|
"assert_text_visible",
|
|
@@ -8915,7 +8916,7 @@ function isSupportedCheckType(value) {
|
|
|
8915
8916
|
}
|
|
8916
8917
|
function normalizeSetupActionType(value, index) {
|
|
8917
8918
|
const normalizedInput = String(value || "").trim().replace(/-/g, "_");
|
|
8918
|
-
const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput;
|
|
8919
|
+
const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput;
|
|
8919
8920
|
if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
|
|
8920
8921
|
return normalized;
|
|
8921
8922
|
}
|
|
@@ -8949,6 +8950,11 @@ function normalizeSetupAction(input, index) {
|
|
|
8949
8950
|
if (!isRecord2(input)) throw new Error(`target.setup_actions[${index}] must be an object.`);
|
|
8950
8951
|
const type = normalizeSetupActionType(stringValue5(input.type), index);
|
|
8951
8952
|
const selector = stringValue5(input.selector);
|
|
8953
|
+
const frameSelector = stringFromOwn(input, "frame_selector", "frameSelector", "iframe_selector", "iframeSelector");
|
|
8954
|
+
const frameIndex = numberValue3(valueFromOwn(input, "frame_index", "frameIndex", "iframe_index", "iframeIndex"));
|
|
8955
|
+
if (frameIndex !== void 0 && (!Number.isInteger(frameIndex) || frameIndex < 0)) {
|
|
8956
|
+
throw new Error(`target.setup_actions[${index}].frame_index must be a non-negative integer.`);
|
|
8957
|
+
}
|
|
8952
8958
|
if ((type === "click" || type === "fill" || type === "set_input_value" || type === "wait_for_selector" || type === "wait_for_text" || type === "assert_text_visible" || type === "assert_text_absent" || type === "assert_selector_count") && !selector) {
|
|
8953
8959
|
throw new Error(`target.setup_actions[${index}] ${type} requires selector.`);
|
|
8954
8960
|
}
|
|
@@ -8968,6 +8974,9 @@ function normalizeSetupAction(input, index) {
|
|
|
8968
8974
|
throw new Error(`target.setup_actions[${index}] ${type} requires value.`);
|
|
8969
8975
|
}
|
|
8970
8976
|
const key = stringValue5(input.key);
|
|
8977
|
+
if (type === "press" && !key) {
|
|
8978
|
+
throw new Error(`target.setup_actions[${index}] ${type} requires key.`);
|
|
8979
|
+
}
|
|
8971
8980
|
if ((type === "local_storage" || type === "session_storage") && !key) {
|
|
8972
8981
|
throw new Error(`target.setup_actions[${index}] ${type} requires key.`);
|
|
8973
8982
|
}
|
|
@@ -8998,6 +9007,8 @@ function normalizeSetupAction(input, index) {
|
|
|
8998
9007
|
return {
|
|
8999
9008
|
type,
|
|
9000
9009
|
selector,
|
|
9010
|
+
frame_selector: frameSelector,
|
|
9011
|
+
frame_index: frameIndex,
|
|
9001
9012
|
force: type === "click" && (input.force === true || input.force_click === true || input.forceClick === true),
|
|
9002
9013
|
key,
|
|
9003
9014
|
value,
|
|
@@ -9884,6 +9895,8 @@ function assessSetupActionsFromEvidence(profile, evidence) {
|
|
|
9884
9895
|
viewport: viewport.name,
|
|
9885
9896
|
action: result.action ?? result.type ?? null,
|
|
9886
9897
|
selector: result.selector ?? null,
|
|
9898
|
+
frame_selector: result.frame_selector ?? null,
|
|
9899
|
+
frame_index: result.frame_index ?? null,
|
|
9887
9900
|
reason: result.reason ?? result.error ?? null
|
|
9888
9901
|
});
|
|
9889
9902
|
}
|
|
@@ -10396,10 +10409,12 @@ function assessProfile(profile, evidence) {
|
|
|
10396
10409
|
if (result && result.ok === false) {
|
|
10397
10410
|
failed.push({
|
|
10398
10411
|
viewport: viewport.name,
|
|
10399
|
-
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
10412
|
+
action: result.action || result.type || null,
|
|
10413
|
+
selector: result.selector || null,
|
|
10414
|
+
frame_selector: result.frame_selector || null,
|
|
10415
|
+
frame_index: result.frame_index ?? null,
|
|
10416
|
+
reason: result.reason || result.error || null,
|
|
10417
|
+
});
|
|
10403
10418
|
}
|
|
10404
10419
|
}
|
|
10405
10420
|
if (results.length < actionCount && results.every((result) => !result || result.ok !== false)) {
|
|
@@ -10862,8 +10877,8 @@ function setupJsonValue(value) {
|
|
|
10862
10877
|
function setupValuesEqual(left, right) {
|
|
10863
10878
|
return JSON.stringify(setupJsonValue(left)) === JSON.stringify(setupJsonValue(right));
|
|
10864
10879
|
}
|
|
10865
|
-
async function setupReadWindowValue(path) {
|
|
10866
|
-
return await
|
|
10880
|
+
async function setupReadWindowValue(context, path) {
|
|
10881
|
+
return await context.evaluate(({ path }) => {
|
|
10867
10882
|
const toJsonValue = (value) => {
|
|
10868
10883
|
if (value === null || value === undefined) return null;
|
|
10869
10884
|
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
@@ -10885,6 +10900,80 @@ async function setupReadWindowValue(path) {
|
|
|
10885
10900
|
return { ok: true, value: toJsonValue(current) };
|
|
10886
10901
|
}, { path });
|
|
10887
10902
|
}
|
|
10903
|
+
function setupFrameSelector(action) {
|
|
10904
|
+
return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
|
|
10905
|
+
}
|
|
10906
|
+
function setupFrameIndex(action) {
|
|
10907
|
+
const raw = action?.frame_index ?? action?.frameIndex ?? action?.iframe_index ?? action?.iframeIndex ?? 0;
|
|
10908
|
+
const number = Number(raw);
|
|
10909
|
+
return Number.isInteger(number) && number >= 0 ? number : 0;
|
|
10910
|
+
}
|
|
10911
|
+
function setupScopeEvidence(scope) {
|
|
10912
|
+
if (!scope || !scope.frame_selector) return {};
|
|
10913
|
+
return {
|
|
10914
|
+
frame_selector: scope.frame_selector,
|
|
10915
|
+
frame_index: scope.frame_index,
|
|
10916
|
+
frame_count: scope.frame_count,
|
|
10917
|
+
};
|
|
10918
|
+
}
|
|
10919
|
+
function setupScopeFailure(base, scope) {
|
|
10920
|
+
return {
|
|
10921
|
+
...base,
|
|
10922
|
+
...setupScopeEvidence(scope),
|
|
10923
|
+
reason: scope?.reason || "frame_scope_unavailable",
|
|
10924
|
+
error: scope?.error || undefined,
|
|
10925
|
+
};
|
|
10926
|
+
}
|
|
10927
|
+
async function setupActionScope(action, timeout) {
|
|
10928
|
+
const frameSelector = setupFrameSelector(action);
|
|
10929
|
+
if (!frameSelector) return { ok: true, context: page };
|
|
10930
|
+
const frameIndex = setupFrameIndex(action);
|
|
10931
|
+
let frameCount = 0;
|
|
10932
|
+
let locator = null;
|
|
10933
|
+
try {
|
|
10934
|
+
await page.waitForSelector(frameSelector, { state: "attached", timeout });
|
|
10935
|
+
locator = page.locator(frameSelector);
|
|
10936
|
+
frameCount = await locator.count();
|
|
10937
|
+
} catch (error) {
|
|
10938
|
+
return {
|
|
10939
|
+
ok: false,
|
|
10940
|
+
reason: "frame_selector_not_found",
|
|
10941
|
+
frame_selector: frameSelector,
|
|
10942
|
+
frame_index: frameIndex,
|
|
10943
|
+
frame_count: frameCount,
|
|
10944
|
+
error: String(error && error.message ? error.message : error).slice(0, 1000),
|
|
10945
|
+
};
|
|
10946
|
+
}
|
|
10947
|
+
if (!frameCount) {
|
|
10948
|
+
return { ok: false, reason: "frame_selector_not_found", frame_selector: frameSelector, frame_index: frameIndex, frame_count: frameCount };
|
|
10949
|
+
}
|
|
10950
|
+
if (frameIndex >= frameCount) {
|
|
10951
|
+
return { ok: false, reason: "frame_index_out_of_range", frame_selector: frameSelector, frame_index: frameIndex, frame_count: frameCount };
|
|
10952
|
+
}
|
|
10953
|
+
const handle = await locator.nth(frameIndex).elementHandle({ timeout }).catch((error) => ({ __riddle_error: error }));
|
|
10954
|
+
if (!handle || handle.__riddle_error) {
|
|
10955
|
+
return {
|
|
10956
|
+
ok: false,
|
|
10957
|
+
reason: "frame_element_unavailable",
|
|
10958
|
+
frame_selector: frameSelector,
|
|
10959
|
+
frame_index: frameIndex,
|
|
10960
|
+
frame_count: frameCount,
|
|
10961
|
+
error: handle?.__riddle_error ? String(handle.__riddle_error && handle.__riddle_error.message ? handle.__riddle_error.message : handle.__riddle_error).slice(0, 1000) : undefined,
|
|
10962
|
+
};
|
|
10963
|
+
}
|
|
10964
|
+
const frame = typeof handle.contentFrame === "function" ? await handle.contentFrame().catch((error) => ({ __riddle_error: error })) : null;
|
|
10965
|
+
if (!frame || frame.__riddle_error) {
|
|
10966
|
+
return {
|
|
10967
|
+
ok: false,
|
|
10968
|
+
reason: "content_frame_unavailable",
|
|
10969
|
+
frame_selector: frameSelector,
|
|
10970
|
+
frame_index: frameIndex,
|
|
10971
|
+
frame_count: frameCount,
|
|
10972
|
+
error: frame?.__riddle_error ? String(frame.__riddle_error && frame.__riddle_error.message ? frame.__riddle_error.message : frame.__riddle_error).slice(0, 1000) : undefined,
|
|
10973
|
+
};
|
|
10974
|
+
}
|
|
10975
|
+
return { ok: true, context: frame, frame_selector: frameSelector, frame_index: frameIndex, frame_count: frameCount };
|
|
10976
|
+
}
|
|
10888
10977
|
async function setupLocatorText(locator, index) {
|
|
10889
10978
|
return await locator.nth(index).textContent({ timeout: 1000 }).catch(() => "");
|
|
10890
10979
|
}
|
|
@@ -11046,7 +11135,8 @@ async function registerNetworkMocks(mocks) {
|
|
|
11046
11135
|
}
|
|
11047
11136
|
async function executeSetupAction(action, ordinal) {
|
|
11048
11137
|
const type = setupActionType(action);
|
|
11049
|
-
const
|
|
11138
|
+
const frameSelector = setupFrameSelector(action);
|
|
11139
|
+
const base = { ok: false, action: type || "unknown", ordinal, selector: action.selector || null, frame_selector: frameSelector || null };
|
|
11050
11140
|
const timeout = setupNumber(action.timeout_ms, 5000);
|
|
11051
11141
|
try {
|
|
11052
11142
|
if (type === "wait") {
|
|
@@ -11055,36 +11145,65 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11055
11145
|
return { ...base, ok: true, ms };
|
|
11056
11146
|
}
|
|
11057
11147
|
if (type === "wait_for_selector") {
|
|
11058
|
-
await
|
|
11059
|
-
return
|
|
11148
|
+
const scope = await setupActionScope(action, timeout);
|
|
11149
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11150
|
+
await scope.context.waitForSelector(action.selector, { state: "visible", timeout });
|
|
11151
|
+
return { ...base, ...setupScopeEvidence(scope), ok: true, timeout_ms: timeout };
|
|
11152
|
+
}
|
|
11153
|
+
if (type === "press") {
|
|
11154
|
+
const key = String(action.key || "").trim();
|
|
11155
|
+
if (!key) return { ...base, reason: "missing_key" };
|
|
11156
|
+
const scope = await setupActionScope(action, timeout);
|
|
11157
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11158
|
+
if (!action.selector) {
|
|
11159
|
+
if (scope.frame_selector) {
|
|
11160
|
+
await scope.context.locator("body").press(key, { timeout });
|
|
11161
|
+
} else {
|
|
11162
|
+
await page.keyboard.press(key);
|
|
11163
|
+
}
|
|
11164
|
+
return { ...base, ...setupScopeEvidence(scope), ok: true, key };
|
|
11165
|
+
}
|
|
11166
|
+
const locator = scope.context.locator(action.selector);
|
|
11167
|
+
const count = await locator.count();
|
|
11168
|
+
if (!count) return { ...base, reason: "selector_not_found", count, key };
|
|
11169
|
+
const targetIndex = Number.isInteger(action.index) ? action.index : 0;
|
|
11170
|
+
if (targetIndex < 0 || targetIndex >= count) return { ...base, reason: "index_out_of_range", count, target_index: targetIndex, key };
|
|
11171
|
+
await locator.nth(targetIndex).press(key, { timeout });
|
|
11172
|
+
return { ...base, ...setupScopeEvidence(scope), ok: true, count, target_index: targetIndex, key };
|
|
11060
11173
|
}
|
|
11061
11174
|
if (type === "local_storage" || type === "session_storage") {
|
|
11062
11175
|
const value = setupActionValue(action);
|
|
11063
|
-
await
|
|
11176
|
+
const scope = await setupActionScope(action, timeout);
|
|
11177
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11178
|
+
await scope.context.evaluate(({ type, key, value }) => {
|
|
11064
11179
|
const storage = type === "session_storage" ? window.sessionStorage : window.localStorage;
|
|
11065
11180
|
storage.setItem(key, value);
|
|
11066
11181
|
}, { type, key: action.key, value });
|
|
11067
11182
|
if (action.reload === true) {
|
|
11068
11183
|
await page.reload({ waitUntil: "domcontentloaded", timeout: 45000 });
|
|
11069
11184
|
}
|
|
11070
|
-
return { ...base, ok: true, key: action.key, value_length: value.length, reload: action.reload === true };
|
|
11185
|
+
return { ...base, ...setupScopeEvidence(scope), ok: true, key: action.key, value_length: value.length, reload: action.reload === true };
|
|
11071
11186
|
}
|
|
11072
11187
|
if (type === "clear_storage") {
|
|
11073
11188
|
const storage = action.storage || "both";
|
|
11074
|
-
await
|
|
11189
|
+
const scope = await setupActionScope(action, timeout);
|
|
11190
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11191
|
+
await scope.context.evaluate(({ storage }) => {
|
|
11075
11192
|
if (storage === "local" || storage === "both") window.localStorage.clear();
|
|
11076
11193
|
if (storage === "session" || storage === "both") window.sessionStorage.clear();
|
|
11077
11194
|
}, { storage });
|
|
11078
11195
|
if (action.reload === true) {
|
|
11079
11196
|
await page.reload({ waitUntil: "domcontentloaded", timeout: 45000 });
|
|
11080
11197
|
}
|
|
11081
|
-
return { ...base, ok: true, storage, reload: action.reload === true };
|
|
11198
|
+
return { ...base, ...setupScopeEvidence(scope), ok: true, storage, reload: action.reload === true };
|
|
11082
11199
|
}
|
|
11083
11200
|
if (type === "window_call") {
|
|
11084
11201
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
11085
11202
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
11086
11203
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
11087
|
-
const
|
|
11204
|
+
const scope = await setupActionScope(action, timeout);
|
|
11205
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11206
|
+
const result = await scope.context.evaluate(async ({ path, args }) => {
|
|
11088
11207
|
const toJsonValue = (value) => {
|
|
11089
11208
|
if (value === null || value === undefined) return null;
|
|
11090
11209
|
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
@@ -11124,6 +11243,7 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11124
11243
|
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
11125
11244
|
return {
|
|
11126
11245
|
...base,
|
|
11246
|
+
...setupScopeEvidence(scope),
|
|
11127
11247
|
ok: Boolean(result.ok && expectationMet),
|
|
11128
11248
|
path,
|
|
11129
11249
|
arg_count: args.length,
|
|
@@ -11154,13 +11274,16 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11154
11274
|
: action.expect;
|
|
11155
11275
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
11156
11276
|
if (!hasExpected) return { ...base, path, reason: "missing_expected_value" };
|
|
11277
|
+
const scope = await setupActionScope(action, timeout);
|
|
11278
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11157
11279
|
const startedAt = Date.now();
|
|
11158
11280
|
let result = null;
|
|
11159
11281
|
while (Date.now() - startedAt <= timeout) {
|
|
11160
|
-
result = await setupReadWindowValue(path);
|
|
11282
|
+
result = await setupReadWindowValue(scope.context, path);
|
|
11161
11283
|
if (result.ok && setupValuesEqual(result.value, expected)) {
|
|
11162
11284
|
return {
|
|
11163
11285
|
...base,
|
|
11286
|
+
...setupScopeEvidence(scope),
|
|
11164
11287
|
ok: true,
|
|
11165
11288
|
path,
|
|
11166
11289
|
value: setupJsonValue(result.value),
|
|
@@ -11172,6 +11295,7 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11172
11295
|
}
|
|
11173
11296
|
return {
|
|
11174
11297
|
...base,
|
|
11298
|
+
...setupScopeEvidence(scope),
|
|
11175
11299
|
path,
|
|
11176
11300
|
reason: result?.ok ? "unexpected_value" : result?.reason || "path_not_found",
|
|
11177
11301
|
missing_part: result?.missing_part || undefined,
|
|
@@ -11188,11 +11312,13 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11188
11312
|
const hasExpected = expected !== undefined;
|
|
11189
11313
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
11190
11314
|
if (!hasExpected && minValue === undefined && maxValue === undefined) return { ...base, path, reason: "missing_number_expectation" };
|
|
11315
|
+
const scope = await setupActionScope(action, timeout);
|
|
11316
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11191
11317
|
const startedAt = Date.now();
|
|
11192
11318
|
let result = null;
|
|
11193
11319
|
let lastReason = "path_not_found";
|
|
11194
11320
|
while (Date.now() - startedAt <= timeout) {
|
|
11195
|
-
result = await setupReadWindowValue(path);
|
|
11321
|
+
result = await setupReadWindowValue(scope.context, path);
|
|
11196
11322
|
if (result.ok) {
|
|
11197
11323
|
const actual = setupFiniteNumber(result.value);
|
|
11198
11324
|
if (actual === undefined) {
|
|
@@ -11206,6 +11332,7 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11206
11332
|
} else {
|
|
11207
11333
|
return {
|
|
11208
11334
|
...base,
|
|
11335
|
+
...setupScopeEvidence(scope),
|
|
11209
11336
|
ok: true,
|
|
11210
11337
|
path,
|
|
11211
11338
|
value: actual,
|
|
@@ -11222,6 +11349,7 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11222
11349
|
}
|
|
11223
11350
|
return {
|
|
11224
11351
|
...base,
|
|
11352
|
+
...setupScopeEvidence(scope),
|
|
11225
11353
|
path,
|
|
11226
11354
|
reason: lastReason,
|
|
11227
11355
|
missing_part: result?.missing_part || undefined,
|
|
@@ -11233,7 +11361,9 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11233
11361
|
};
|
|
11234
11362
|
}
|
|
11235
11363
|
if (type === "click") {
|
|
11236
|
-
const
|
|
11364
|
+
const scope = await setupActionScope(action, timeout);
|
|
11365
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11366
|
+
const locator = scope.context.locator(action.selector);
|
|
11237
11367
|
const count = await locator.count();
|
|
11238
11368
|
if (!count) return { ...base, reason: "selector_not_found", count };
|
|
11239
11369
|
let targetIndex = Number.isInteger(action.index) ? action.index : 0;
|
|
@@ -11265,33 +11395,39 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11265
11395
|
? { timeout, noWaitAfter: true, force: true }
|
|
11266
11396
|
: { timeout, noWaitAfter: true };
|
|
11267
11397
|
await locator.nth(targetIndex).click(clickOptions);
|
|
11268
|
-
return { ...base, ok: true, count, target_index: targetIndex, text: matchedText, force: action.force === true || undefined };
|
|
11398
|
+
return { ...base, ...setupScopeEvidence(scope), ok: true, count, target_index: targetIndex, text: matchedText, force: action.force === true || undefined };
|
|
11269
11399
|
}
|
|
11270
11400
|
if (type === "fill" || type === "set_input_value") {
|
|
11271
|
-
const
|
|
11401
|
+
const scope = await setupActionScope(action, timeout);
|
|
11402
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11403
|
+
const locator = scope.context.locator(action.selector);
|
|
11272
11404
|
const count = await locator.count();
|
|
11273
11405
|
if (!count) return { ...base, reason: "selector_not_found", count };
|
|
11274
11406
|
const targetIndex = Number.isInteger(action.index) ? action.index : 0;
|
|
11275
11407
|
if (targetIndex < 0 || targetIndex >= count) return { ...base, reason: "index_out_of_range", count, target_index: targetIndex };
|
|
11276
11408
|
const value = setupActionValue(action);
|
|
11277
11409
|
await locator.nth(targetIndex).fill(value, { timeout });
|
|
11278
|
-
return { ...base, ok: true, count, target_index: targetIndex, value_length: value.length };
|
|
11410
|
+
return { ...base, ...setupScopeEvidence(scope), ok: true, count, target_index: targetIndex, value_length: value.length };
|
|
11279
11411
|
}
|
|
11280
11412
|
if (type === "assert_selector_count") {
|
|
11281
|
-
const
|
|
11413
|
+
const scope = await setupActionScope(action, timeout);
|
|
11414
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11415
|
+
const locator = scope.context.locator(action.selector);
|
|
11282
11416
|
const expectedCount = setupNumber(action.expected_count, -1);
|
|
11283
11417
|
if (!Number.isInteger(expectedCount) || expectedCount < 0) return { ...base, reason: "invalid_expected_count", expected_count: action.expected_count };
|
|
11284
11418
|
const startedAt = Date.now();
|
|
11285
11419
|
let count = 0;
|
|
11286
11420
|
while (Date.now() - startedAt <= timeout) {
|
|
11287
11421
|
count = await locator.count().catch(() => 0);
|
|
11288
|
-
if (count === expectedCount) return { ...base, ok: true, count, expected_count: expectedCount, timeout_ms: timeout };
|
|
11422
|
+
if (count === expectedCount) return { ...base, ...setupScopeEvidence(scope), ok: true, count, expected_count: expectedCount, timeout_ms: timeout };
|
|
11289
11423
|
await page.waitForTimeout(100);
|
|
11290
11424
|
}
|
|
11291
|
-
return { ...base, reason: "selector_count_mismatch", count, expected_count: expectedCount, timeout_ms: timeout };
|
|
11425
|
+
return { ...base, ...setupScopeEvidence(scope), reason: "selector_count_mismatch", count, expected_count: expectedCount, timeout_ms: timeout };
|
|
11292
11426
|
}
|
|
11293
11427
|
if (type === "wait_for_text") {
|
|
11294
|
-
const
|
|
11428
|
+
const scope = await setupActionScope(action, timeout);
|
|
11429
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11430
|
+
const locator = scope.context.locator(action.selector);
|
|
11295
11431
|
const startedAt = Date.now();
|
|
11296
11432
|
let lastText = "";
|
|
11297
11433
|
while (Date.now() - startedAt <= timeout) {
|
|
@@ -11300,15 +11436,17 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11300
11436
|
const text = await setupLocatorText(locator, index);
|
|
11301
11437
|
lastText = text || lastText;
|
|
11302
11438
|
if (setupTextMatches(text, action)) {
|
|
11303
|
-
return { ...base, ok: true, text: compactSetupResultText(text), target_index: index, timeout_ms: timeout };
|
|
11439
|
+
return { ...base, ...setupScopeEvidence(scope), ok: true, text: compactSetupResultText(text), target_index: index, timeout_ms: timeout };
|
|
11304
11440
|
}
|
|
11305
11441
|
}
|
|
11306
11442
|
await page.waitForTimeout(100);
|
|
11307
11443
|
}
|
|
11308
|
-
return { ...base, reason: "text_not_found", text: compactSetupResultText(lastText), timeout_ms: timeout };
|
|
11444
|
+
return { ...base, ...setupScopeEvidence(scope), reason: "text_not_found", text: compactSetupResultText(lastText), timeout_ms: timeout };
|
|
11309
11445
|
}
|
|
11310
11446
|
if (type === "assert_text_visible" || type === "assert_text_absent") {
|
|
11311
|
-
const
|
|
11447
|
+
const scope = await setupActionScope(action, timeout);
|
|
11448
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
11449
|
+
const locator = scope.context.locator(action.selector);
|
|
11312
11450
|
const startedAt = Date.now();
|
|
11313
11451
|
let lastText = "";
|
|
11314
11452
|
let matchedText = "";
|
|
@@ -11327,7 +11465,7 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11327
11465
|
if (type === "assert_text_visible") {
|
|
11328
11466
|
const visible = await setupLocatorVisible(locator, index);
|
|
11329
11467
|
if (visible) {
|
|
11330
|
-
return { ...base, ok: true, count, text: compactSetupResultText(text), target_index: index, timeout_ms: timeout };
|
|
11468
|
+
return { ...base, ...setupScopeEvidence(scope), ok: true, count, text: compactSetupResultText(text), target_index: index, timeout_ms: timeout };
|
|
11331
11469
|
}
|
|
11332
11470
|
hiddenMatch = true;
|
|
11333
11471
|
break;
|
|
@@ -11336,17 +11474,17 @@ async function executeSetupAction(action, ordinal) {
|
|
|
11336
11474
|
}
|
|
11337
11475
|
}
|
|
11338
11476
|
if (type === "assert_text_absent" && !matched) {
|
|
11339
|
-
return { ...base, ok: true, count, timeout_ms: timeout };
|
|
11477
|
+
return { ...base, ...setupScopeEvidence(scope), ok: true, count, timeout_ms: timeout };
|
|
11340
11478
|
}
|
|
11341
11479
|
await page.waitForTimeout(100);
|
|
11342
11480
|
}
|
|
11343
11481
|
if (type === "assert_text_visible") {
|
|
11344
11482
|
if (hiddenMatch) {
|
|
11345
|
-
return { ...base, reason: "matching_element_not_visible", text: compactSetupResultText(matchedText), timeout_ms: timeout };
|
|
11483
|
+
return { ...base, ...setupScopeEvidence(scope), reason: "matching_element_not_visible", text: compactSetupResultText(matchedText), timeout_ms: timeout };
|
|
11346
11484
|
}
|
|
11347
|
-
return { ...base, reason: "text_not_found", text: compactSetupResultText(lastText), timeout_ms: timeout };
|
|
11485
|
+
return { ...base, ...setupScopeEvidence(scope), reason: "text_not_found", text: compactSetupResultText(lastText), timeout_ms: timeout };
|
|
11348
11486
|
}
|
|
11349
|
-
return { ...base, reason: "text_still_present", text: compactSetupResultText(matchedText || lastText), timeout_ms: timeout };
|
|
11487
|
+
return { ...base, ...setupScopeEvidence(scope), reason: "text_still_present", text: compactSetupResultText(matchedText || lastText), timeout_ms: timeout };
|
|
11350
11488
|
}
|
|
11351
11489
|
return { ...base, reason: "unsupported_action" };
|
|
11352
11490
|
} catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
resolveRiddleProofProfileTimeoutSec,
|
|
59
59
|
slugifyRiddleProofProfileName,
|
|
60
60
|
summarizeRiddleProofProfileResult
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-Q5VW6MAP.js";
|
|
62
62
|
import {
|
|
63
63
|
DEFAULT_RIDDLE_API_BASE_URL,
|
|
64
64
|
DEFAULT_RIDDLE_API_KEY_FILE,
|