@reticlehq/engine 3.10.11 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bounded-list.d.ts +41 -0
- package/dist/bounded-list.js +82 -0
- package/dist/disagreement/contradiction-evidence.d.ts +4 -30
- package/dist/disagreement/contradiction-evidence.js +23 -30
- package/dist/disagreement/contradiction-types.d.ts +14 -4
- package/dist/disagreement/contradictions.js +34 -7
- package/dist/evidence/blind-spots.d.ts +13 -5
- package/dist/evidence/blind-spots.js +88 -8
- package/dist/evidence/instrumentation-gaps.d.ts +6 -0
- package/dist/evidence/instrumentation-gaps.js +4 -3
- package/dist/evidence/unsettled.js +13 -4
- package/dist/question/declared.d.ts +20 -6
- package/dist/question/declared.js +31 -12
- package/dist/question/predicate/net-blind-spots.d.ts +7 -0
- package/dist/question/predicate/net-blind-spots.js +15 -0
- package/dist/question/predicate/predicate-element.d.ts +3 -1
- package/dist/question/predicate/predicate-element.js +104 -16
- package/dist/question/predicate/predicate-eval-kit.d.ts +26 -0
- package/dist/question/predicate/predicate-eval-kit.js +29 -0
- package/dist/question/predicate/predicate-eval.js +13 -3
- package/dist/question/predicate/predicate.js +38 -30
- package/dist/window/event-filters.d.ts +3 -1
- package/dist/window/event-filters.js +6 -2
- package/dist/write-identity.d.ts +36 -0
- package/dist/write-identity.js +31 -0
- package/package.json +2 -2
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* It rides in `because`, beside `verifiedReason`, rather than in a field of its own: the verdict has
|
|
16
16
|
* one sentence an agent is known to read, and a caveat parked anywhere else is a caveat nobody reads.
|
|
17
17
|
*/
|
|
18
|
-
import { PredicateKind, compareSourceClauses } from '@reticlehq/core';
|
|
18
|
+
import { PredicateKind, compareSourceClauses, describePropertyAssertion } from '@reticlehq/core';
|
|
19
19
|
/** Enough to recognise the one that is stuck; not so many that a chatty window eats the verdict. */
|
|
20
20
|
const MAX_LISTED_REQUESTS = 3;
|
|
21
21
|
/**
|
|
@@ -33,7 +33,7 @@ const WORDED = {
|
|
|
33
33
|
[PredicateKind.NET]: ['method', 'urlContains'],
|
|
34
34
|
[PredicateKind.ROUTE]: ['pathname', 'contains'],
|
|
35
35
|
[PredicateKind.STATE]: ['path'],
|
|
36
|
-
[PredicateKind.TEXT]: ['contains', 'ignoreCase'],
|
|
36
|
+
[PredicateKind.TEXT]: ['contains', 'ignoreCase', 'satisfies'],
|
|
37
37
|
[PredicateKind.ELEMENT]: ['query', 'state'],
|
|
38
38
|
[PredicateKind.ANIMATION]: ['name'],
|
|
39
39
|
};
|
|
@@ -63,8 +63,17 @@ function waitPhrase(predicate) {
|
|
|
63
63
|
return `state at '${predicate.path}'`;
|
|
64
64
|
// Every part that decides the claim stays in it: the label is the check's title downstream, and
|
|
65
65
|
// one that dropped `ignoreCase` or the wanted state read as a different check from its own result.
|
|
66
|
-
case PredicateKind.TEXT:
|
|
67
|
-
|
|
66
|
+
case PredicateKind.TEXT: {
|
|
67
|
+
const parts = [];
|
|
68
|
+
if (predicate.contains !== undefined) {
|
|
69
|
+
parts.push(`containing '${predicate.contains}'`);
|
|
70
|
+
}
|
|
71
|
+
if (predicate.satisfies !== undefined) {
|
|
72
|
+
parts.push(describePropertyAssertion(predicate.satisfies));
|
|
73
|
+
}
|
|
74
|
+
const desc = parts.length > 0 ? parts.join(' ') : 'present';
|
|
75
|
+
return `text ${desc}${true === predicate.ignoreCase ? ', ignoring case' : ''}`;
|
|
76
|
+
}
|
|
68
77
|
case PredicateKind.ELEMENT:
|
|
69
78
|
return `an element matching ${JSON.stringify(predicate.query)}${predicate.state === undefined ? '' : ` in state '${predicate.state}'`}`;
|
|
70
79
|
case PredicateKind.CONSOLE:
|
|
@@ -24,10 +24,15 @@ export interface DeclaredNetFailure {
|
|
|
24
24
|
urlContains?: string;
|
|
25
25
|
status?: number;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* A net clause that declared repeats on its endpoint, and its method if named. Without `count` it
|
|
29
|
+
* said `repeatable: true`: the endpoint reads, so any number of calls is expected (#1353). With
|
|
30
|
+
* `count` it said `count: N`: up to N calls there are the declared consequence (#2273).
|
|
31
|
+
*/
|
|
28
32
|
export interface DeclaredRead {
|
|
29
33
|
urlContains: string;
|
|
30
34
|
method?: string;
|
|
35
|
+
count?: number;
|
|
31
36
|
}
|
|
32
37
|
interface DeclaredExpectations {
|
|
33
38
|
/** Requests the caller declared would FAIL, so failing is the expected outcome, not a disagreement. */
|
|
@@ -48,8 +53,9 @@ interface DeclaredExpectations {
|
|
|
48
53
|
*/
|
|
49
54
|
netUrls: readonly string[];
|
|
50
55
|
/**
|
|
51
|
-
* The net clauses that
|
|
52
|
-
* `urlContains` is never here:
|
|
56
|
+
* The net clauses that declared repeats: `repeatable: true` (reads, not writes, #1353) or a
|
|
57
|
+
* `count` (that many calls, #2273). One with no `urlContains` is never here: it would excuse
|
|
58
|
+
* every request.
|
|
53
59
|
*/
|
|
54
60
|
repeatableNetUrls: readonly DeclaredRead[];
|
|
55
61
|
/**
|
|
@@ -109,13 +115,21 @@ export declare function matchesDeclaredFailure(call: {
|
|
|
109
115
|
status: number | undefined;
|
|
110
116
|
}, declared: readonly DeclaredNetFailure[]): boolean;
|
|
111
117
|
/**
|
|
112
|
-
* Was this call declared a read?
|
|
113
|
-
*
|
|
114
|
-
* excuses a POST to the same endpoint (#1353).
|
|
118
|
+
* Was this call declared a read? A clause with `repeatable: true` (no `count`) that names it,
|
|
119
|
+
* matched as in `declares` (#1353).
|
|
115
120
|
*/
|
|
116
121
|
export declare function isDeclaredRead(call: {
|
|
117
122
|
method: string;
|
|
118
123
|
url: string;
|
|
119
124
|
matchUrl?: string;
|
|
120
125
|
}, reads: readonly DeclaredRead[] | undefined): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* How many calls the assertion declared for this call's endpoint with `count`: the largest such
|
|
128
|
+
* count among the clauses that name it, or 0 when none does (#2273).
|
|
129
|
+
*/
|
|
130
|
+
export declare function declaredCountFor(call: {
|
|
131
|
+
method: string;
|
|
132
|
+
url: string;
|
|
133
|
+
matchUrl?: string;
|
|
134
|
+
}, reads: readonly DeclaredRead[] | undefined): number;
|
|
121
135
|
export {};
|
|
@@ -106,11 +106,20 @@ export function declaredExpectations(predicate) {
|
|
|
106
106
|
return;
|
|
107
107
|
case PredicateKind.NET: {
|
|
108
108
|
netUrls.push(p.urlContains ?? '');
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
if (p.urlContains !== undefined && p.urlContains.trim() !== '') {
|
|
110
|
+
if (true === p.repeatable) {
|
|
111
|
+
repeatableNetUrls.push({
|
|
112
|
+
urlContains: p.urlContains,
|
|
113
|
+
...(p.method === undefined ? {} : { method: p.method }),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
else if (p.count !== undefined) {
|
|
117
|
+
repeatableNetUrls.push({
|
|
118
|
+
urlContains: p.urlContains,
|
|
119
|
+
count: p.count,
|
|
120
|
+
...(p.method === undefined ? {} : { method: p.method }),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
114
123
|
}
|
|
115
124
|
const declaredFailure = false === p.ok || (p.status !== undefined && p.status >= FAILURE_STATUS_MIN);
|
|
116
125
|
if (!declaredFailure) {
|
|
@@ -238,15 +247,25 @@ export function matchesDeclaredFailure(call, declared) {
|
|
|
238
247
|
});
|
|
239
248
|
}
|
|
240
249
|
/**
|
|
241
|
-
*
|
|
250
|
+
* Does this clause name this call? Same matching as `matchesDeclaredFailure`: the URL must contain
|
|
242
251
|
* the clause's `urlContains`, and a method the clause named must agree, so a repeatable GET never
|
|
243
252
|
* excuses a POST to the same endpoint (#1353).
|
|
244
253
|
*/
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
const haystack = call.matchUrl ?? call.url;
|
|
250
|
-
return reads.some((r) => haystack.includes(r.urlContains) &&
|
|
254
|
+
function declares(r, call) {
|
|
255
|
+
return ((call.matchUrl ?? call.url).includes(r.urlContains) &&
|
|
251
256
|
(r.method === undefined || r.method.toUpperCase() === call.method.toUpperCase()));
|
|
252
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Was this call declared a read? A clause with `repeatable: true` (no `count`) that names it,
|
|
260
|
+
* matched as in `declares` (#1353).
|
|
261
|
+
*/
|
|
262
|
+
export function isDeclaredRead(call, reads) {
|
|
263
|
+
return (reads ?? []).some((r) => r.count === undefined && declares(r, call));
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* How many calls the assertion declared for this call's endpoint with `count`: the largest such
|
|
267
|
+
* count among the clauses that name it, or 0 when none does (#2273).
|
|
268
|
+
*/
|
|
269
|
+
export function declaredCountFor(call, reads) {
|
|
270
|
+
return (reads ?? []).reduce((most, r) => (r.count !== undefined && declares(r, call) ? Math.max(most, r.count) : most), 0);
|
|
271
|
+
}
|
|
@@ -85,4 +85,11 @@ type NetClause = Parameters<typeof describeNetFilter>[0];
|
|
|
85
85
|
* read only when the miss is reported.
|
|
86
86
|
*/
|
|
87
87
|
export declare function unrecordedCallMiss(events: Parameters<typeof unpatchedInWindow>[0], p: NetClause, observed: () => string): EvalResult | undefined;
|
|
88
|
+
/** A `net` clause named a method, and the only matching record has none (#2474). */
|
|
89
|
+
export declare const UNOBSERVABLE_METHOD_ASSERTION = "net.unobservable-method";
|
|
90
|
+
/**
|
|
91
|
+
* Resource timing has no method, so the SDK writes none for a fetch or XHR sent before
|
|
92
|
+
* `connect()`. That record can neither match nor refute a clause that names a method.
|
|
93
|
+
*/
|
|
94
|
+
export declare function unobservableMethodMiss(filter: string, method: string | undefined): EvalResult;
|
|
88
95
|
export {};
|
|
@@ -260,3 +260,18 @@ export function unrecordedCallMiss(events, p, observed) {
|
|
|
260
260
|
assertion,
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
|
+
/** A `net` clause named a method, and the only matching record has none (#2474). */
|
|
264
|
+
export const UNOBSERVABLE_METHOD_ASSERTION = 'net.unobservable-method';
|
|
265
|
+
/**
|
|
266
|
+
* Resource timing has no method, so the SDK writes none for a fetch or XHR sent before
|
|
267
|
+
* `connect()`. That record can neither match nor refute a clause that names a method.
|
|
268
|
+
*/
|
|
269
|
+
export function unobservableMethodMiss(filter, method) {
|
|
270
|
+
return {
|
|
271
|
+
pass: false,
|
|
272
|
+
inconclusive: `a request matching ${filter} was sent before connect(), so its method was not recorded — assert without \`method\`, or call connect() earlier`,
|
|
273
|
+
observed: 'a matching request with no recorded method',
|
|
274
|
+
expected: `a ${method ?? ''} request matching ${filter}`,
|
|
275
|
+
assertion: UNOBSERVABLE_METHOD_ASSERTION,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
@@ -18,7 +18,9 @@ export declare const ARIA_HIDDEN_STATE_NOTE = "the element is painted on screen
|
|
|
18
18
|
* so the hint can say exactly what to use instead.
|
|
19
19
|
*/
|
|
20
20
|
export declare const HTML_TAG_TO_ARIA_ROLE: Map<string, string>;
|
|
21
|
-
export declare function matchOnce(session: PredicateSession, query: ElementQuery, state: ElementState | undefined, diagnose?: boolean, fullText?: boolean
|
|
21
|
+
export declare function matchOnce(session: PredicateSession, query: ElementQuery, state: ElementState | undefined, diagnose?: boolean, fullText?: boolean,
|
|
22
|
+
/** Ask the page to prove that the ref scope and every match are outside each virtualized list. */
|
|
23
|
+
outsideVirtualized?: boolean): Promise<MatchResult>;
|
|
22
24
|
export declare function evalElement(session: PredicateSession, query: ElementQuery, state: ElementState | undefined, absent: boolean, diagnose: boolean,
|
|
23
25
|
/** Describe the matches with their full text, for a caller that will JUDGE it (see `withTextProperty`). */
|
|
24
26
|
fullText?: boolean,
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* back (`residualQueryChecks`), the absent/present asymmetry, and the near-miss diagnostics that only
|
|
7
7
|
* ever enrich a failure. Nothing else in the predicate layer talks to `ReticleCommand.MATCH`.
|
|
8
8
|
*/
|
|
9
|
-
import { MatchArg, QueryBy, ReticleCommand, TRANSPORT_LIMITS, ElementState, } from '@reticlehq/core';
|
|
9
|
+
import { isFadedReason, MatchArg, QueryBy, REDACTED_VALUE, ReticleCommand, TRANSPORT_LIMITS, ElementState, } from '@reticlehq/core';
|
|
10
10
|
import { describeAltOnNonImage, describeUnusableElementQuery, residualQueryChecks, withAltProjected, satisfiesResiduals, describeResidual, } from './predicate-eval.js';
|
|
11
|
-
import { clipBody, sdkPredates } from './predicate-eval-kit.js';
|
|
11
|
+
import { clipBody, ELEMENT_STATE_ASSERTION, sdkPredates } from './predicate-eval-kit.js';
|
|
12
12
|
import { describeTestidMiss } from './testid-near-miss.js';
|
|
13
13
|
import { describeCaseMiss, describeSplitTextMiss } from './split-text-miss.js';
|
|
14
14
|
import { satisfiesProperty } from './property.js';
|
|
@@ -144,8 +144,13 @@ function describeCovered(dialog) {
|
|
|
144
144
|
* almost the colour behind it, or it is almost transparent. A `yes` here was a false green (#1797).
|
|
145
145
|
*/
|
|
146
146
|
function describeUnreadable(why) {
|
|
147
|
-
|
|
148
|
-
'Fix the colour or the opacity, then check again'
|
|
147
|
+
const reason = `the text is on the page, but a user cannot read it (${why}). ` +
|
|
148
|
+
'Fix the colour or the opacity, then check again';
|
|
149
|
+
if (!isFadedReason(why)) {
|
|
150
|
+
return reason;
|
|
151
|
+
}
|
|
152
|
+
return (`${reason}. To assert that the text faded away, check that it is absent in ` +
|
|
153
|
+
`\`state: "${ElementState.VISIBLE}"\``);
|
|
149
154
|
}
|
|
150
155
|
/**
|
|
151
156
|
* Why a match is refused before the round-trip (#1990): the page DECLARED its commands and match is
|
|
@@ -157,7 +162,9 @@ function matchNotServedMessage(sdkVersion, declared) {
|
|
|
157
162
|
"connected and this is not one of them. Update the page's @reticlehq packages: " +
|
|
158
163
|
'`reticle update` in the app.');
|
|
159
164
|
}
|
|
160
|
-
export async function matchOnce(session, query, state, diagnose, fullText = false
|
|
165
|
+
export async function matchOnce(session, query, state, diagnose, fullText = false,
|
|
166
|
+
/** Ask the page to prove that the ref scope and every match are outside each virtualized list. */
|
|
167
|
+
outsideVirtualized = false) {
|
|
161
168
|
// A page that declared its commands and left match out can never answer (#1990): the session
|
|
162
169
|
// refuses the send, and that refusal used to be read as "zero matches". Refuse before the trip.
|
|
163
170
|
if (session.commands !== undefined && !session.commands.includes(ReticleCommand.MATCH)) {
|
|
@@ -168,6 +175,7 @@ export async function matchOnce(session, query, state, diagnose, fullText = fals
|
|
|
168
175
|
state,
|
|
169
176
|
...(true === diagnose ? { diagnose: true } : {}),
|
|
170
177
|
...(fullText ? { [MatchArg.FULL_TEXT]: true } : {}),
|
|
178
|
+
...(outsideVirtualized ? { [MatchArg.OUTSIDE_VIRTUALIZED]: true } : {}),
|
|
171
179
|
});
|
|
172
180
|
// A reply with an error never looked at the page. Read as zero matches, a query the page's schema
|
|
173
181
|
// refused or a matcher that threw became a false `no`. Thrown, the verdict reads it as unknown.
|
|
@@ -271,6 +279,30 @@ function stateTheSdkPredates(sdk, state) {
|
|
|
271
279
|
}
|
|
272
280
|
return sdkPredates(sdk, since) ? { sdk, state, since } : undefined;
|
|
273
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Re-run `query` without its state constraint and apply any residual checks on this side (#2298).
|
|
284
|
+
*
|
|
285
|
+
* Shared by both absence spellings so `not(element)` and `absent: true` agree on whether the
|
|
286
|
+
* target control itself is mounted in another state. Drops truncated residual results because a
|
|
287
|
+
* cut prefix cannot prove a residual match.
|
|
288
|
+
*
|
|
289
|
+
* A scoped query also asks the page for the proof that the scope and every match are outside each
|
|
290
|
+
* virtualized list. `outsideVirtualized` is true only when this side asked and the page said yes:
|
|
291
|
+
* an older page does not answer, and an answer that nobody asked for is not used.
|
|
292
|
+
*/
|
|
293
|
+
async function mountedIgnoringState(session, query, residualChecks, fullText) {
|
|
294
|
+
const asked = query.scope !== undefined;
|
|
295
|
+
const relaxed = await matchOnce(session, withAltProjected(query, residualChecks), undefined, false, fullText, asked);
|
|
296
|
+
const outsideVirtualized = asked && true === relaxed.outsideVirtualized;
|
|
297
|
+
if (0 === residualChecks.length) {
|
|
298
|
+
return { elements: relaxed.elements, count: relaxed.count, outsideVirtualized };
|
|
299
|
+
}
|
|
300
|
+
if (relaxed.count !== relaxed.elements.length) {
|
|
301
|
+
return { elements: [], count: 0, outsideVirtualized: false };
|
|
302
|
+
}
|
|
303
|
+
const kept = relaxed.elements.filter((element) => satisfiesResiduals(element, residualChecks));
|
|
304
|
+
return { elements: kept, count: kept.length, outsideVirtualized };
|
|
305
|
+
}
|
|
274
306
|
/** The first SDK release whose element query accepts `matchCase`; an older page refuses the query. */
|
|
275
307
|
const MATCH_CASE_SINCE = '3.7.0';
|
|
276
308
|
export async function evalElement(session, query, state, absent, diagnose,
|
|
@@ -289,7 +321,7 @@ unlessText) {
|
|
|
289
321
|
inconclusive: reason,
|
|
290
322
|
observed: `SDK ${tooOld.sdk}`,
|
|
291
323
|
expected: `SDK ${tooOld.since} or newer, which can answer '${tooOld.state}'`,
|
|
292
|
-
assertion:
|
|
324
|
+
assertion: ELEMENT_STATE_ASSERTION,
|
|
293
325
|
};
|
|
294
326
|
}
|
|
295
327
|
// Fields the browser's locator would have DROPPED, enforced back here — see residualQueryChecks.
|
|
@@ -369,16 +401,34 @@ unlessText) {
|
|
|
369
401
|
if (match.matched && unlessText !== undefined) {
|
|
370
402
|
return absentUnlessSatisfied(match, unlessText, subject);
|
|
371
403
|
}
|
|
372
|
-
|
|
373
|
-
|
|
404
|
+
if (match.matched) {
|
|
405
|
+
return {
|
|
374
406
|
pass: false,
|
|
375
407
|
failureReason: describeAbsentMiss(match, state, subject),
|
|
376
408
|
observed: `${String(match.count)} element(s) matching ${subject}`,
|
|
377
409
|
expected: `no element matching ${subject}`,
|
|
378
410
|
assertion: 'element.absent',
|
|
379
411
|
evidence: match.elements,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
// Check whether the locator matches one mounted element in another state (#2298).
|
|
415
|
+
// The blind-spot rule reads this evidence. The mounted match alone proves nothing about
|
|
416
|
+
// unmounted virtual rows: only the page's `outsideVirtualized` answer does. Only attach a
|
|
417
|
+
// single unambiguous match so large match lists never bloat a passing verdict.
|
|
418
|
+
if (diagnose && state !== undefined) {
|
|
419
|
+
const mounted = await mountedIgnoringState(session, query, residual.checks, textOnThisSide);
|
|
420
|
+
if (1 === mounted.count && 1 === mounted.elements.length) {
|
|
421
|
+
return {
|
|
422
|
+
pass: true,
|
|
423
|
+
evidence: {
|
|
424
|
+
absent: true,
|
|
425
|
+
nearMiss: mounted.elements,
|
|
426
|
+
...(mounted.outsideVirtualized ? { outsideVirtualized: true } : {}),
|
|
427
|
+
},
|
|
428
|
+
};
|
|
380
429
|
}
|
|
381
|
-
|
|
430
|
+
}
|
|
431
|
+
return { pass: true, evidence: { absent: true } };
|
|
382
432
|
}
|
|
383
433
|
if (true === match.scopeMissing) {
|
|
384
434
|
return {
|
|
@@ -449,16 +499,32 @@ unlessText) {
|
|
|
449
499
|
}
|
|
450
500
|
// Diagnostic near-miss: was it there but in the wrong state, or a similar element present?
|
|
451
501
|
if (state !== undefined) {
|
|
452
|
-
const
|
|
453
|
-
if (
|
|
502
|
+
const mounted = await mountedIgnoringState(session, query, residual.checks, textOnThisSide);
|
|
503
|
+
if (mounted.elements.length > 0) {
|
|
454
504
|
const ariaNote = true === match.hint?.ariaHiddenState ? ` — ${ARIA_HIDDEN_STATE_NOTE}` : '';
|
|
455
505
|
return {
|
|
456
506
|
pass: false,
|
|
457
|
-
failureReason: `element matching ${subject} exists${describeRef(
|
|
458
|
-
observed: `element matching ${subject} is present, states: ${
|
|
507
|
+
failureReason: `element matching ${subject} exists${describeRef(mounted.elements[0])} but not in state '${state}'${ariaNote}`,
|
|
508
|
+
observed: `element matching ${subject} is present, states: ${mounted.elements[0]?.states.join(', ') ?? 'unknown'}${ariaNote}`,
|
|
459
509
|
expected: `element matching ${subject} in state '${state}'`,
|
|
510
|
+
assertion: ELEMENT_STATE_ASSERTION,
|
|
511
|
+
evidence: {
|
|
512
|
+
nearMiss: mounted.elements,
|
|
513
|
+
...(mounted.count > mounted.elements.length ? { nearMissCount: mounted.count } : {}),
|
|
514
|
+
...(mounted.outsideVirtualized ? { outsideVirtualized: true } : {}),
|
|
515
|
+
},
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
// Nothing matches it in any state: it was removed. The role-only list below named other,
|
|
519
|
+
// unrelated elements of that role (a "Huddle" dialog for a removed "Search" dialog).
|
|
520
|
+
if (ElementState.HIDDEN === state) {
|
|
521
|
+
return {
|
|
522
|
+
pass: false,
|
|
523
|
+
failureReason: `nothing matching ${subject} is on the page: it was removed, not hidden. ` +
|
|
524
|
+
'To assert that it is gone, use `absent: true`',
|
|
525
|
+
observed: `no element matching ${subject}, in any state`,
|
|
526
|
+
expected: `an element matching ${subject} in state '${state}'`,
|
|
460
527
|
assertion: 'element.state',
|
|
461
|
-
evidence: { nearMiss: relaxed.elements },
|
|
462
528
|
};
|
|
463
529
|
}
|
|
464
530
|
}
|
|
@@ -653,6 +719,19 @@ export function wholeTextOf(evidence, subject, undecided) {
|
|
|
653
719
|
}
|
|
654
720
|
return { text: joinedText(matched) };
|
|
655
721
|
}
|
|
722
|
+
/**
|
|
723
|
+
* Whether a match's text was hidden from Reticle (#2277). The page sent the redaction marker, or it
|
|
724
|
+
* sent no text for an element that has an accessible name. An element with no name and no text is
|
|
725
|
+
* empty, so a property over its text is judged.
|
|
726
|
+
*/
|
|
727
|
+
function textWasHidden(element) {
|
|
728
|
+
const text = textOf(element);
|
|
729
|
+
if (REDACTED_VALUE === text) {
|
|
730
|
+
return true;
|
|
731
|
+
}
|
|
732
|
+
const name = element?.name;
|
|
733
|
+
return '' === text.trim() && 'string' === typeof name && '' !== name.trim();
|
|
734
|
+
}
|
|
656
735
|
export function withTextProperty(base, assertion, subject, baseline) {
|
|
657
736
|
if (!base.pass) {
|
|
658
737
|
return base;
|
|
@@ -664,6 +743,13 @@ export function withTextProperty(base, assertion, subject, baseline) {
|
|
|
664
743
|
}
|
|
665
744
|
const { text } = whole;
|
|
666
745
|
const described = matched.map(shownBounded);
|
|
746
|
+
// Text that was never read decides nothing, either way: the redaction marker itself satisfies
|
|
747
|
+
// `contains "RED"` or `nonEmpty`, which was a false yes. Body checks answer the same way.
|
|
748
|
+
if (matched.some(textWasHidden)) {
|
|
749
|
+
const reason = `the text of ${subject} was redacted or hidden before Reticle read it, so ` +
|
|
750
|
+
`${assertion.property} was not decided. Check a field the app does not redact`;
|
|
751
|
+
return { pass: false, failureReason: reason, inconclusive: reason, evidence: described };
|
|
752
|
+
}
|
|
667
753
|
const result = satisfiesProperty(text, assertion, baseline);
|
|
668
754
|
// Nothing was compared — a relative property with no before-reading. See the twin in `evalState`.
|
|
669
755
|
if (true === result.unevaluated) {
|
|
@@ -699,8 +785,10 @@ async function nearestByName(session, name, state, within) {
|
|
|
699
785
|
{ label: name, ...within },
|
|
700
786
|
{ placeholder: name, ...within },
|
|
701
787
|
]) {
|
|
702
|
-
|
|
703
|
-
|
|
788
|
+
// A diagnosis only. A realm that has no such field (the computer realm has no placeholders)
|
|
789
|
+
// refuses the query; that must not take the verdict with it, so the next locator is tried.
|
|
790
|
+
const found = await matchOnce(session, query, state).catch(() => undefined);
|
|
791
|
+
if (true === found?.matched) {
|
|
704
792
|
return found.elements.slice(0, MAX_BY_NAME);
|
|
705
793
|
}
|
|
706
794
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PredicateKind, asNumber, asString } from '@reticlehq/core';
|
|
2
2
|
import type { Predicate } from './predicate-schema.js';
|
|
3
|
+
/** Assertion tag `evalElement` returns when the target is mounted in another state. */
|
|
4
|
+
export declare const ELEMENT_STATE_ASSERTION = "element.state";
|
|
3
5
|
/**
|
|
4
6
|
* What an evaluation ANSWERS, and the small comparisons every oracle answers it with.
|
|
5
7
|
*
|
|
@@ -51,6 +53,16 @@ export interface EvalResult {
|
|
|
51
53
|
* had just clicked. See VerifiedReason.OBSERVATION_LOST.
|
|
52
54
|
*/
|
|
53
55
|
observationLost?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The exact message of a page read that threw, when that throw is why this result is
|
|
58
|
+
* inconclusive.
|
|
59
|
+
*
|
|
60
|
+
* A composite reads each clause on its own, so a clause that throws no longer rejects the whole
|
|
61
|
+
* composite (#1656). This field keeps what the rejection used to say. The wait ends on it, as it
|
|
62
|
+
* ended on the rejection, and the pre-check before an action throws it again. Absent when a
|
|
63
|
+
* clause failed or passed, because then the composite has an answer.
|
|
64
|
+
*/
|
|
65
|
+
readError?: string;
|
|
54
66
|
/**
|
|
55
67
|
* The failure, structured — what was seen, what was required, and which oracle judged it.
|
|
56
68
|
*
|
|
@@ -74,6 +86,20 @@ export interface EvalResult {
|
|
|
74
86
|
caseOnlyMiss?: boolean;
|
|
75
87
|
wouldHold?: string;
|
|
76
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* A read that threw never looked at the app: the page did not answer, or went away. That is "could
|
|
91
|
+
* not tell", not "looked and it was false", so it is inconclusive, which the verdict rule turns into
|
|
92
|
+
* unknown. As a plain false it was graded assertion_failed: a command timeout on a live, throttled
|
|
93
|
+
* tab came back verified:no against a page that was never read.
|
|
94
|
+
*/
|
|
95
|
+
export declare function unansweredRead(error: unknown): EvalResult;
|
|
96
|
+
/**
|
|
97
|
+
* The result without `readError`, for a caller that shows it to an agent.
|
|
98
|
+
*
|
|
99
|
+
* `readError` is for the wait and the pre-check only. The tool schemas do not declare it, and the
|
|
100
|
+
* same message is already in `failureReason` and `inconclusive`.
|
|
101
|
+
*/
|
|
102
|
+
export declare function withoutReadError(result: EvalResult): EvalResult;
|
|
77
103
|
/** Core's `asString` and `asNumber`, under the names the oracles here read them by. */
|
|
78
104
|
export { asString as str, asNumber as num };
|
|
79
105
|
/**
|
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
import { PredicateKind, REDACTED_VALUE, asNumber, asString, selectPath } from '@reticlehq/core';
|
|
2
|
+
/** Assertion tag `evalElement` returns when the target is mounted in another state. */
|
|
3
|
+
export const ELEMENT_STATE_ASSERTION = 'element.state';
|
|
4
|
+
/** The start of the `inconclusive` sentence for a read that threw. See `unansweredRead`. */
|
|
5
|
+
const PAGE_DID_NOT_ANSWER = 'the page did not answer: ';
|
|
6
|
+
/**
|
|
7
|
+
* A read that threw never looked at the app: the page did not answer, or went away. That is "could
|
|
8
|
+
* not tell", not "looked and it was false", so it is inconclusive, which the verdict rule turns into
|
|
9
|
+
* unknown. As a plain false it was graded assertion_failed: a command timeout on a live, throttled
|
|
10
|
+
* tab came back verified:no against a page that was never read.
|
|
11
|
+
*/
|
|
12
|
+
export function unansweredRead(error) {
|
|
13
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
14
|
+
return {
|
|
15
|
+
pass: false,
|
|
16
|
+
failureReason: reason,
|
|
17
|
+
inconclusive: `${PAGE_DID_NOT_ANSWER}${reason}`,
|
|
18
|
+
readError: reason,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The result without `readError`, for a caller that shows it to an agent.
|
|
23
|
+
*
|
|
24
|
+
* `readError` is for the wait and the pre-check only. The tool schemas do not declare it, and the
|
|
25
|
+
* same message is already in `failureReason` and `inconclusive`.
|
|
26
|
+
*/
|
|
27
|
+
export function withoutReadError(result) {
|
|
28
|
+
const { readError: _readError, ...answer } = result;
|
|
29
|
+
return answer;
|
|
30
|
+
}
|
|
2
31
|
/** Core's `asString` and `asNumber`, under the names the oracles here read them by. */
|
|
3
32
|
export { asString as str, asNumber as num };
|
|
4
33
|
/**
|
|
@@ -10,7 +10,7 @@ export { evalConsole } from './predicate-console.js';
|
|
|
10
10
|
import { clipBody, dataMatches, describeBodyFieldMiss, describeFieldMiss, describeNetFilter, matchJsonBody, num, redactedOnPath, str, } from './predicate-eval-kit.js';
|
|
11
11
|
import { keyFragmentOnly } from './body-key-fragment.js';
|
|
12
12
|
import { evalExactCount } from '../../exact-count.js';
|
|
13
|
-
import { PRE_ATTACH_CAVEAT, earlierMediaReason, mediaLoadReason, nativeDownloadReason, targetsMediaLoad, targetsNativeDownload, targetsUnobservedChannel, unobservedChannelReason, unrecordedCallMiss, } from './net-blind-spots.js';
|
|
13
|
+
import { PRE_ATTACH_CAVEAT, earlierMediaReason, mediaLoadReason, nativeDownloadReason, targetsMediaLoad, targetsNativeDownload, targetsUnobservedChannel, unobservedChannelReason, unobservableMethodMiss, unrecordedCallMiss, } from './net-blind-spots.js';
|
|
14
14
|
export { clipBody, dataMatches, describeNetFilter, matchValue, str, } from './predicate-eval-kit.js';
|
|
15
15
|
/** The oracle a net body clause reports, so an agent can branch on which one decided. */
|
|
16
16
|
const NetBodyAssertion = {
|
|
@@ -216,6 +216,8 @@ export function evalNet(events, p, sdkVersion) {
|
|
|
216
216
|
let unrecordedReason;
|
|
217
217
|
/** A call matched url/method but carried NO readable status (document-initiated subresource). */
|
|
218
218
|
let unobservableStatus = false;
|
|
219
|
+
/** A call matched the url, but its record has no method (sent before connect(), #2474). */
|
|
220
|
+
let unobservableMethod = false;
|
|
219
221
|
/**
|
|
220
222
|
* The response body of a call that matched everything EXCEPT the body assertion, and HAD one.
|
|
221
223
|
*
|
|
@@ -248,10 +250,15 @@ export function evalNet(events, p, sdkVersion) {
|
|
|
248
250
|
return false;
|
|
249
251
|
}
|
|
250
252
|
const d = e.data;
|
|
251
|
-
if (p.
|
|
253
|
+
if (p.urlContains !== undefined && !urlForMatch(d).includes(p.urlContains)) {
|
|
252
254
|
return false;
|
|
253
255
|
}
|
|
254
|
-
|
|
256
|
+
const method = str(d['method']);
|
|
257
|
+
if (p.method !== undefined && method === undefined) {
|
|
258
|
+
unobservableMethod = true;
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
if (p.method !== undefined && method?.toUpperCase() !== p.method.toUpperCase()) {
|
|
255
262
|
return false;
|
|
256
263
|
}
|
|
257
264
|
if (p.status !== undefined) {
|
|
@@ -335,6 +342,9 @@ export function evalNet(events, p, sdkVersion) {
|
|
|
335
342
|
assertion: 'net.unobservable-status',
|
|
336
343
|
};
|
|
337
344
|
}
|
|
345
|
+
if (unobservableMethod && 0 === matches.length) {
|
|
346
|
+
return unobservableMethodMiss(describeNetFilter(p), p.method);
|
|
347
|
+
}
|
|
338
348
|
if (matchedButUnrecorded && 0 === matches.length) {
|
|
339
349
|
// Inconclusive, never a plain failure: nothing says the body lacked the text, only that nobody
|
|
340
350
|
// read it (#1520). The same family as evicted evidence answering `no` (#1231).
|