feat(spec): add WebState + camelCase attribute aliases

WebState extends State with live `document`/`window` for V8-side web
extractors. KnownAttrSelectors gains camelCase aliases (contentDescription,
ariaLabel, testID, etc.) so cross-framework specs autocomplete.
This commit is contained in:
pj committed 2026-04-27 18:43:24 +07:00
1 parent 0d6f32f8a4
commit 01e43a869d
2 files changed
+22

No files matched your search

+1
View File
@@ -23,6 +23,7 @@ export type {
TapAction, TapAction,
SanderlingRuntime, SanderlingRuntime,
WaitAction, WaitAction,
WebState,
WeightedEntry, WeightedEntry,
} from "./types.ts"; } from "./types.ts";
+21
View File
@@ -1,3 +1,5 @@
/// <reference lib="dom" />
export type Snapshots = Record<string, unknown>; export type Snapshots = Record<string, unknown>;
/** /**
@@ -10,20 +12,28 @@ export type Snapshots = Record<string, unknown>;
*/ */
export interface KnownAttrSelectors { export interface KnownAttrSelectors {
testTag?: string; testTag?: string;
testID?: string;
identifier?: string; identifier?: string;
accessibilityIdentifier?: string; accessibilityIdentifier?: string;
"resource-id"?: string; "resource-id"?: string;
id?: string;
"content-desc"?: string; "content-desc"?: string;
contentDescription?: string;
accessibilityText?: string; accessibilityText?: string;
accessibilityLabel?: string; accessibilityLabel?: string;
ariaLabel?: string;
"aria-label"?: string;
label?: string; label?: string;
text?: string; text?: string;
tag?: string;
class?: string; class?: string;
className?: string;
elementType?: string; elementType?: string;
package?: string; package?: string;
placeholderValue?: string; placeholderValue?: string;
placeholder?: string;
hintText?: string; hintText?: string;
clickable?: boolean; clickable?: boolean;
@@ -99,6 +109,17 @@ export interface State {
exceptions: readonly ExceptionRecord[]; exceptions: readonly ExceptionRecord[];
} }
/**
* State as observed inside a web (V8/browser) extractor. Adds the live
* `document` and `window` handles. `state.document` is V8-only — goja-side
* predicates do not see it; if you need DOM data in a predicate, surface it
* via an `extract()`.
*/
export interface WebState extends State {
readonly document: Document;
readonly window: Window;
}
export interface Extracted<T> { export interface Extracted<T> {
readonly current: T; readonly current: T;
readonly previous: T | undefined; readonly previous: T | undefined;