testsurfer 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +156 -2
- package/dist/aria.d.ts +44 -0
- package/dist/aria.js +198 -0
- package/dist/aria.js.map +1 -0
- package/dist/browser.d.ts +45 -0
- package/dist/browser.js +84 -0
- package/dist/browser.js.map +1 -0
- package/dist/client.d.ts +59 -0
- package/dist/client.js +274 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +23 -0
- package/dist/errors.js +35 -0
- package/dist/errors.js.map +1 -0
- package/dist/expect.d.ts +55 -0
- package/dist/expect.js +196 -0
- package/dist/expect.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/locator.d.ts +157 -0
- package/dist/locator.js +316 -0
- package/dist/locator.js.map +1 -0
- package/dist/page.d.ts +223 -0
- package/dist/page.js +491 -0
- package/dist/page.js.map +1 -0
- package/dist/roles.d.ts +3 -0
- package/dist/roles.js +33 -0
- package/dist/roles.js.map +1 -0
- package/dist/runner.d.ts +43 -0
- package/dist/runner.js +117 -0
- package/dist/runner.js.map +1 -0
- package/dist/tree.d.ts +46 -0
- package/dist/tree.js +272 -0
- package/dist/tree.js.map +1 -0
- package/dist/wire.d.ts +48 -0
- package/dist/wire.js +78 -0
- package/dist/wire.js.map +1 -0
- package/package.json +49 -4
package/dist/locator.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locators: lazy, re-resolving element handles over the a11y tree.
|
|
3
|
+
*
|
|
4
|
+
* A locator stores a query (role + name, text, or label), not a ref.
|
|
5
|
+
* Every action and assertion re-resolves the query against a fresh
|
|
6
|
+
* view, so locators survive re-renders and navigation. Actions retry
|
|
7
|
+
* on STALE_TOKEN and NOT_FOUND until the action timeout elapses.
|
|
8
|
+
*/
|
|
9
|
+
import { StrictModeError, TimeoutError, WireError } from "./errors.js";
|
|
10
|
+
import { isHidden, walk } from "./tree.js";
|
|
11
|
+
import { renderSnapshot } from "./aria.js";
|
|
12
|
+
import { ROLE_TO_CODES } from "./roles.js";
|
|
13
|
+
const FIELD_CODES = new Set(['tf', 'ta', 'sel', 'chk', 'rad']);
|
|
14
|
+
const normalize = (s) => s.replace(/\s+/g, ' ').trim();
|
|
15
|
+
function matchesName(label, expected, exact) {
|
|
16
|
+
const norm = normalize(label);
|
|
17
|
+
if (expected instanceof RegExp)
|
|
18
|
+
return expected.test(norm);
|
|
19
|
+
const want = normalize(expected);
|
|
20
|
+
return exact ? norm === want : norm.toLowerCase() === want.toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
function matchesText(label, expected, exact) {
|
|
23
|
+
const norm = normalize(label);
|
|
24
|
+
if (expected instanceof RegExp)
|
|
25
|
+
return expected.test(norm);
|
|
26
|
+
const want = normalize(expected);
|
|
27
|
+
return exact ? norm === want : norm.toLowerCase().includes(want.toLowerCase());
|
|
28
|
+
}
|
|
29
|
+
/** A node's label plus, for a labelled form field, its <label> text. */
|
|
30
|
+
function names(node) {
|
|
31
|
+
const lbl = node.attrs['lbl'];
|
|
32
|
+
return lbl ? [node.label, lbl] : [node.label];
|
|
33
|
+
}
|
|
34
|
+
function matchesQuery(node, query) {
|
|
35
|
+
switch (query.kind) {
|
|
36
|
+
case 'role': {
|
|
37
|
+
const codes = ROLE_TO_CODES[query.role] ?? [query.role];
|
|
38
|
+
if (!codes.includes(node.role))
|
|
39
|
+
return false;
|
|
40
|
+
const { name, exact = false, level } = query.options;
|
|
41
|
+
if (level !== undefined && node.attrs['level'] !== String(level))
|
|
42
|
+
return false;
|
|
43
|
+
if (name !== undefined && !names(node).some((n) => matchesName(n, name, exact)))
|
|
44
|
+
return false;
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
case 'text':
|
|
48
|
+
return node.label !== '' && matchesText(node.label, query.text, query.options.exact ?? false);
|
|
49
|
+
case 'label': {
|
|
50
|
+
// The field's <label> text (lbl=, vibesurfer 0.2.12+) is the
|
|
51
|
+
// label; aria-label lands in the node label itself.
|
|
52
|
+
if (!FIELD_CODES.has(node.role))
|
|
53
|
+
return false;
|
|
54
|
+
const exact = query.options.exact ?? false;
|
|
55
|
+
return names(node).some((n) => matchesText(n, query.text, exact));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function describeQuery(query) {
|
|
60
|
+
switch (query.kind) {
|
|
61
|
+
case 'role':
|
|
62
|
+
return `getByRole(${JSON.stringify(query.role)}${query.options.name !== undefined ? `, { name: ${String(query.options.name)} }` : ''})`;
|
|
63
|
+
case 'text':
|
|
64
|
+
return `getByText(${String(query.text)})`;
|
|
65
|
+
case 'label':
|
|
66
|
+
return `getByLabel(${String(query.text)})`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export function findMatches(snap, query) {
|
|
70
|
+
const out = [];
|
|
71
|
+
for (const node of walk(snap)) {
|
|
72
|
+
if (matchesQuery(node, query))
|
|
73
|
+
out.push(node);
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
78
|
+
const POLL_MS = 10;
|
|
79
|
+
/** Drop hid-marked matches when at least one unmarked match exists. */
|
|
80
|
+
function preferVisible(snap, all) {
|
|
81
|
+
const visible = all.filter((n) => !isHidden(snap, n));
|
|
82
|
+
return visible.length > 0 ? visible : all;
|
|
83
|
+
}
|
|
84
|
+
export class Locator {
|
|
85
|
+
page;
|
|
86
|
+
query;
|
|
87
|
+
index;
|
|
88
|
+
/** Refs from the previous visibility resolve, used as the composite layout hint. */
|
|
89
|
+
layoutHint = [];
|
|
90
|
+
constructor(page, query, index = null) {
|
|
91
|
+
this.page = page;
|
|
92
|
+
this.query = query;
|
|
93
|
+
this.index = index;
|
|
94
|
+
}
|
|
95
|
+
/** The owning page's expect timeout, used as the assertion default. */
|
|
96
|
+
get expectTimeout() {
|
|
97
|
+
return this.page.timeouts.expect;
|
|
98
|
+
}
|
|
99
|
+
/** Pick the first match instead of failing on multiple matches. */
|
|
100
|
+
first() {
|
|
101
|
+
return this.nth(0);
|
|
102
|
+
}
|
|
103
|
+
/** Pick the i-th match (0-based) instead of failing on multiple matches. */
|
|
104
|
+
nth(index) {
|
|
105
|
+
return new Locator(this.page, this.query, index);
|
|
106
|
+
}
|
|
107
|
+
toString() {
|
|
108
|
+
const base = describeQuery(this.query);
|
|
109
|
+
return this.index === null ? base : `${base}.nth(${this.index})`;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* All current matches against a fresh view. Visible matches are
|
|
113
|
+
* preferred, judged from the tree alone (hid=1 on self or ancestor):
|
|
114
|
+
* hidden duplicates of interactive elements are dropped when a
|
|
115
|
+
* visible one exists. No layout round trip.
|
|
116
|
+
*/
|
|
117
|
+
async resolveAll() {
|
|
118
|
+
const snap = await this.page.view();
|
|
119
|
+
return preferVisible(snap, findMatches(snap, this.query));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Matches that are currently visible. Interactive refs carry hid=1
|
|
123
|
+
* in the tree, but hidden non-interactive elements (a heading inside
|
|
124
|
+
* a `hidden` container) do not, so survivors are verified against
|
|
125
|
+
* vs_layout's per-ref visible flag.
|
|
126
|
+
*/
|
|
127
|
+
async resolveVisible() {
|
|
128
|
+
// Polling assertions resolve the same query repeatedly; the ref
|
|
129
|
+
// set from the previous poll rides along as a --layout composite
|
|
130
|
+
// hint, making the steady-state poll a single round trip. Refs
|
|
131
|
+
// that changed since last time are fetched separately.
|
|
132
|
+
const { snap, rects } = await this.page.viewWithLayout(this.layoutHint);
|
|
133
|
+
const candidates = findMatches(snap, this.query).filter((n) => !isHidden(snap, n));
|
|
134
|
+
this.layoutHint = candidates.map((n) => n.ref);
|
|
135
|
+
if (candidates.length === 0)
|
|
136
|
+
return [];
|
|
137
|
+
const missing = candidates.filter((n) => !rects.has(n.ref));
|
|
138
|
+
if (missing.length > 0) {
|
|
139
|
+
const more = await this.page.layout(missing.map((n) => n.ref));
|
|
140
|
+
for (const [ref, rect] of more)
|
|
141
|
+
rects.set(ref, rect);
|
|
142
|
+
}
|
|
143
|
+
return candidates.filter((n) => rects.get(n.ref)?.visible === true);
|
|
144
|
+
}
|
|
145
|
+
/** Strict-mode selection: exactly one node, nth() overrides, null when none. */
|
|
146
|
+
pickOne(matches) {
|
|
147
|
+
if (this.index !== null)
|
|
148
|
+
return matches[this.index] ?? null;
|
|
149
|
+
if (matches.length === 0)
|
|
150
|
+
return null;
|
|
151
|
+
if (matches.length > 1) {
|
|
152
|
+
const list = matches
|
|
153
|
+
.slice(0, 5)
|
|
154
|
+
.map((m) => ` ref=${m.ref} ${m.role} ${JSON.stringify(m.label)}`)
|
|
155
|
+
.join('\n');
|
|
156
|
+
throw new StrictModeError(`${this.toString()} matched ${matches.length} elements:\n${list}\nNarrow the query or use .first() / .nth(i).`);
|
|
157
|
+
}
|
|
158
|
+
return matches[0] ?? null;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Resolve an action target against the cached snapshot when it is
|
|
162
|
+
* still baseline-synced. Optimistic concurrency covers the race: if
|
|
163
|
+
* the page changed since, the act fails with STALE_TOKEN, the retry
|
|
164
|
+
* loop refreshes, and we re-resolve.
|
|
165
|
+
*/
|
|
166
|
+
async resolveForAction() {
|
|
167
|
+
const snap = await this.page.actionSnapshot();
|
|
168
|
+
return this.pickOne(preferVisible(snap, findMatches(snap, this.query)));
|
|
169
|
+
}
|
|
170
|
+
/** Wait until the locator resolves to one node, then run the action, retrying on staleness. */
|
|
171
|
+
async withResolved(actionName, action, timeout) {
|
|
172
|
+
const budget = timeout ?? this.page.timeouts.action;
|
|
173
|
+
const deadline = Date.now() + budget;
|
|
174
|
+
let lastNote = 'no matching element';
|
|
175
|
+
for (;;) {
|
|
176
|
+
let stale = false;
|
|
177
|
+
try {
|
|
178
|
+
const node = await this.resolveForAction();
|
|
179
|
+
if (node)
|
|
180
|
+
return await action(node);
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
if (e instanceof WireError && (e.code === 'STALE_TOKEN' || e.code === 'NOT_FOUND')) {
|
|
184
|
+
lastNote = `retrying after ${e.code}`;
|
|
185
|
+
stale = true;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
throw e;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (Date.now() >= deadline) {
|
|
192
|
+
throw new TimeoutError(`${actionName} on ${this.toString()} timed out after ${budget}ms (${lastNote})`);
|
|
193
|
+
}
|
|
194
|
+
// A staleness rejection means the page just changed; retry
|
|
195
|
+
// immediately against a fresh view. Only a missing element earns
|
|
196
|
+
// a poll-tick sleep.
|
|
197
|
+
if (!stale)
|
|
198
|
+
await sleep(POLL_MS);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Click the element. Visible targets get a trusted native click at
|
|
203
|
+
* their rect center via vs_click_at, which honors the page's input
|
|
204
|
+
* mode (robotic by default; the humanized path behind plain
|
|
205
|
+
* `vs_act click` costs seconds per click). Zero-size or hidden
|
|
206
|
+
* targets cannot be hit by coordinates and fall back to vs_act,
|
|
207
|
+
* whose JS path dispatches regardless of geometry.
|
|
208
|
+
*/
|
|
209
|
+
async click(options) {
|
|
210
|
+
await this.withResolved('click', async (n) => {
|
|
211
|
+
if (this.page.clickVia === 'act') {
|
|
212
|
+
await this.page.act(n.ref, 'click', undefined, { mode: this.page.inputMode });
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const rects = await this.page.layout([n.ref]);
|
|
216
|
+
const r = rects.get(n.ref);
|
|
217
|
+
if (r && r.visible && r.w > 1 && r.h > 1) {
|
|
218
|
+
await this.page.clickAt(r.x + r.w / 2, r.y + r.h / 2);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
await this.page.act(n.ref, 'click');
|
|
222
|
+
}
|
|
223
|
+
}, options?.timeout);
|
|
224
|
+
}
|
|
225
|
+
/** Replace the field's text via the engine's fill path. */
|
|
226
|
+
async fill(value, options) {
|
|
227
|
+
await this.withResolved('fill', (n) => this.page.act(n.ref, 'fill', value), options?.timeout);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Focus the element, then send real per-character key events
|
|
231
|
+
* (isTrusted=true), for rich-text editors and inputs that ignore a
|
|
232
|
+
* programmatic fill. Use fill() for plain inputs.
|
|
233
|
+
*/
|
|
234
|
+
async type(text, options) {
|
|
235
|
+
await this.withResolved('type', async (n) => {
|
|
236
|
+
await this.page.act(n.ref, 'focus');
|
|
237
|
+
await this.page.typeTrusted(text);
|
|
238
|
+
}, options?.timeout);
|
|
239
|
+
}
|
|
240
|
+
/** Send a key chord to the element, e.g. `Enter` or `Ctrl+K`. */
|
|
241
|
+
async press(key, options) {
|
|
242
|
+
await this.withResolved('press', (n) => this.page.act(n.ref, 'key', key), options?.timeout);
|
|
243
|
+
}
|
|
244
|
+
async hover(options) {
|
|
245
|
+
await this.withResolved('hover', (n) => this.page.act(n.ref, 'hover'), options?.timeout);
|
|
246
|
+
}
|
|
247
|
+
async focus(options) {
|
|
248
|
+
await this.withResolved('focus', (n) => this.page.act(n.ref, 'focus'), options?.timeout);
|
|
249
|
+
}
|
|
250
|
+
/** Full text content of the element via vs_read. */
|
|
251
|
+
async textContent(options) {
|
|
252
|
+
return this.withResolved('textContent', (n) => this.page.readRef(n.ref), options?.timeout);
|
|
253
|
+
}
|
|
254
|
+
/** Number of current matches (no waiting). */
|
|
255
|
+
async count() {
|
|
256
|
+
return (await this.resolveAll()).length;
|
|
257
|
+
}
|
|
258
|
+
/** True if the locator has a visible match right now (no waiting). */
|
|
259
|
+
async isVisible() {
|
|
260
|
+
const visible = await this.resolveVisible();
|
|
261
|
+
return this.index === null ? visible.length > 0 : visible[this.index] !== undefined;
|
|
262
|
+
}
|
|
263
|
+
/** Checked state of a checkbox or radio, from the tree (vibesurfer 0.2.12+). */
|
|
264
|
+
async isChecked(options) {
|
|
265
|
+
return this.withResolved('isChecked', async (n) => n.attrs['checked'] === '1', options?.timeout);
|
|
266
|
+
}
|
|
267
|
+
/** Click a checkbox or radio unless it is already checked. */
|
|
268
|
+
async check(options) {
|
|
269
|
+
if (!(await this.isChecked(options)))
|
|
270
|
+
await this.click(options);
|
|
271
|
+
}
|
|
272
|
+
/** Click a checkbox unless it is already unchecked. */
|
|
273
|
+
async uncheck(options) {
|
|
274
|
+
if (await this.isChecked(options))
|
|
275
|
+
await this.click(options);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Current value of a text field or select. The tree labels a field
|
|
279
|
+
* with its value; a password field reads `***` once filled.
|
|
280
|
+
*/
|
|
281
|
+
async inputValue(options) {
|
|
282
|
+
return this.withResolved('inputValue', async (n) => n.label, options?.timeout);
|
|
283
|
+
}
|
|
284
|
+
/** Viewport rect in CSS px, or null when the element is not rendered. */
|
|
285
|
+
async boundingBox(options) {
|
|
286
|
+
return this.withResolved('boundingBox', async (n) => {
|
|
287
|
+
const r = (await this.page.layout([n.ref])).get(n.ref);
|
|
288
|
+
return r && r.w > 0 && r.h > 0 ? r : null;
|
|
289
|
+
}, options?.timeout);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Drag this element onto `target` with a trusted press, move and
|
|
293
|
+
* release from center to center. vibesurfer also fires the HTML5
|
|
294
|
+
* drag events, so native draggable and react-dnd lists see the drop.
|
|
295
|
+
*/
|
|
296
|
+
async dragTo(target, options) {
|
|
297
|
+
const from = await this.boundingBox(options);
|
|
298
|
+
if (!from)
|
|
299
|
+
throw new TimeoutError(`dragTo: ${this.toString()} is not rendered`);
|
|
300
|
+
const to = await target.boundingBox(options);
|
|
301
|
+
if (!to)
|
|
302
|
+
throw new TimeoutError(`dragTo: ${target.toString()} is not rendered`);
|
|
303
|
+
await this.page.mouse.drag(from.x + from.w / 2, from.y + from.h / 2, to.x + to.w / 2, to.y + to.h / 2);
|
|
304
|
+
}
|
|
305
|
+
/** The matched element's subtree as template text (see toMatchAriaSnapshot). */
|
|
306
|
+
async ariaSnapshot(options) {
|
|
307
|
+
return this.withResolved('ariaSnapshot', async (n) => renderSnapshot(await this.page.actionSnapshot(), [n.ref]), options?.timeout);
|
|
308
|
+
}
|
|
309
|
+
/** Refs of the strict-mode match, for scoping a snapshot match. */
|
|
310
|
+
async resolveScope() {
|
|
311
|
+
const snap = await this.page.view();
|
|
312
|
+
const node = this.pickOne(preferVisible(snap, findMatches(snap, this.query)));
|
|
313
|
+
return { snap, refs: node ? [node.ref] : [] };
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=locator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locator.js","sourceRoot":"","sources":["../src/locator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAgC,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAoB/D,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAE/D,SAAS,WAAW,CAAC,KAAa,EAAE,QAAyB,EAAE,KAAc;IAC3E,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,QAAQ,YAAY,MAAM;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAA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AAE,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAChD,CAAC;CACF"}
|
package/dist/page.d.ts
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Page wraps one vibesurfer page: navigation, fresh views, token
|
|
3
|
+
* management, and locator factories. Authors never see state tokens;
|
|
4
|
+
* the page caches the latest one and every mutation uses it.
|
|
5
|
+
*/
|
|
6
|
+
import type { WireClient } from './client.ts';
|
|
7
|
+
import { type Snapshot } from './tree.ts';
|
|
8
|
+
import { Locator, type ByRoleOptions, type ByTextOptions } from './locator.ts';
|
|
9
|
+
export interface Timeouts {
|
|
10
|
+
/** Budget for actions (click, fill, ...) including auto-waiting. */
|
|
11
|
+
action: number;
|
|
12
|
+
/** Budget for expect() assertions. */
|
|
13
|
+
expect: number;
|
|
14
|
+
/** Budget for goto(). */
|
|
15
|
+
navigation: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Cursor and keyboard cadence for trusted input. `robotic` teleports
|
|
19
|
+
* (fast, right for tests); `human` synthesizes a Bezier path with
|
|
20
|
+
* human arrival timing (slow, right for anti-bot flows); `careful` is
|
|
21
|
+
* a single-shot move in between.
|
|
22
|
+
*/
|
|
23
|
+
export type InputMode = 'human' | 'careful' | 'robotic';
|
|
24
|
+
/**
|
|
25
|
+
* How Locator.click reaches a visible target. `act` sends vs_act click
|
|
26
|
+
* --mode directly (vibesurfer 0.2+, negotiated from the clickVia
|
|
27
|
+
* flag). `click-at` resolves the rect and issues a coordinate click,
|
|
28
|
+
* for 0.1.x daemons whose vs_act ignores --mode and always takes the
|
|
29
|
+
* slow humanized path.
|
|
30
|
+
*/
|
|
31
|
+
export type ClickVia = 'click-at' | 'act';
|
|
32
|
+
/** Options for how the page tracks daemon state across mutations. */
|
|
33
|
+
export interface ProtocolOptions {
|
|
34
|
+
/**
|
|
35
|
+
* vibesurfer 0.2+ returns each mutation's tree delta inline (act and
|
|
36
|
+
* cursor ops advance the delta baseline and emit their ViewForm).
|
|
37
|
+
* When enabled the page applies those bodies and skips the re-read
|
|
38
|
+
* after actions. Negotiated from the actDeltas flag; 0.1.x daemons
|
|
39
|
+
* advance the baseline silently and must leave it off.
|
|
40
|
+
*/
|
|
41
|
+
actDeltas?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Navigate an existing page in place via vs_goto (protocol v1),
|
|
44
|
+
* reusing the engine web view instead of paying page creation on
|
|
45
|
+
* every goto. Falls back to close+open when the daemon rejects it.
|
|
46
|
+
*/
|
|
47
|
+
navInPlace?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface LayoutRect {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
w: number;
|
|
53
|
+
h: number;
|
|
54
|
+
visible: boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare const DEFAULT_TIMEOUTS: Timeouts;
|
|
57
|
+
export declare class Page {
|
|
58
|
+
private pageId;
|
|
59
|
+
private token;
|
|
60
|
+
/** Last known tree, kept in sync via full views and deltas. */
|
|
61
|
+
private snapshot;
|
|
62
|
+
/**
|
|
63
|
+
* True while `snapshot` equals the daemon's delta baseline (our last
|
|
64
|
+
* applied view, with no act in between). The daemon advances its
|
|
65
|
+
* baseline on every act and discards that delta, so after an act the
|
|
66
|
+
* next view must be requested `--full`; between plain views, deltas
|
|
67
|
+
* are sound. Cursor ops (click-at) do not touch the baseline, so
|
|
68
|
+
* they leave this flag alone.
|
|
69
|
+
*/
|
|
70
|
+
private synced;
|
|
71
|
+
/**
|
|
72
|
+
* True while `snapshot` also reflects current page reality, so an
|
|
73
|
+
* action can resolve against it without a read. Any mutation clears
|
|
74
|
+
* it. Distinct from `synced`: a click-at leaves the baseline (and
|
|
75
|
+
* the daemon's last token) untouched, so the token check would not
|
|
76
|
+
* catch acting on the pre-click tree; this flag forces the re-read.
|
|
77
|
+
*/
|
|
78
|
+
private fresh;
|
|
79
|
+
private readonly client;
|
|
80
|
+
private readonly sessionId;
|
|
81
|
+
readonly timeouts: Timeouts;
|
|
82
|
+
readonly inputMode: InputMode;
|
|
83
|
+
readonly clickVia: ClickVia;
|
|
84
|
+
readonly actDeltas: boolean;
|
|
85
|
+
readonly navInPlace: boolean;
|
|
86
|
+
readonly baseURL: string | undefined;
|
|
87
|
+
constructor(client: WireClient, sessionId: string, timeouts: Timeouts, inputMode?: InputMode, clickVia?: ClickVia, protocol?: ProtocolOptions, baseURL?: string);
|
|
88
|
+
/**
|
|
89
|
+
* Fold a 0.2 mutation response body (the ViewForm the daemon emitted
|
|
90
|
+
* while advancing its baseline) into the snapshot. Empty body means
|
|
91
|
+
* NoChange; a full tree replaces; a delta applies when we hold the
|
|
92
|
+
* pre-mutation baseline, otherwise the snapshot is unusable until
|
|
93
|
+
* the next full view.
|
|
94
|
+
*/
|
|
95
|
+
private applyMutationBody;
|
|
96
|
+
private get id();
|
|
97
|
+
/**
|
|
98
|
+
* Navigate to a URL, relative to the baseURL launch option when set.
|
|
99
|
+
* Navigates in place on protocol-v1 daemons; older ones close the
|
|
100
|
+
* page and open a new one.
|
|
101
|
+
*/
|
|
102
|
+
goto(target: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Refresh the snapshot from the daemon and return it. Sends a plain
|
|
105
|
+
* (delta) view when our snapshot matches the daemon's baseline and a
|
|
106
|
+
* `--full` view otherwise; the body shape decides how it is applied,
|
|
107
|
+
* so a surprise full tree (navigation, daemon restart) is handled
|
|
108
|
+
* either way.
|
|
109
|
+
*/
|
|
110
|
+
view(): Promise<Snapshot>;
|
|
111
|
+
/**
|
|
112
|
+
* One round trip for view + layout via the `--layout=` composite:
|
|
113
|
+
* the daemon appends rect lines for the requested refs as an extra
|
|
114
|
+
* body section. Refs no longer in the tree come back as inline
|
|
115
|
+
* NOT_FOUND lines and are simply absent from the map.
|
|
116
|
+
*/
|
|
117
|
+
viewWithLayout(refs: number[]): Promise<{
|
|
118
|
+
snap: Snapshot;
|
|
119
|
+
rects: Map<number, LayoutRect>;
|
|
120
|
+
}>;
|
|
121
|
+
private applyViewResponse;
|
|
122
|
+
/**
|
|
123
|
+
* Snapshot for resolving an action target: the cached tree when it
|
|
124
|
+
* is still baseline-synced, otherwise a fresh view. Acting on a
|
|
125
|
+
* cached tree is safe because every mutation carries our token; if
|
|
126
|
+
* the page moved on, the daemon answers STALE_TOKEN and the action
|
|
127
|
+
* loop re-resolves against a fresh view.
|
|
128
|
+
*/
|
|
129
|
+
actionSnapshot(): Promise<Snapshot>;
|
|
130
|
+
/**
|
|
131
|
+
* Run one act primitive against a ref with the cached token. On
|
|
132
|
+
* STALE_TOKEN the cached token is refreshed before rethrowing, so
|
|
133
|
+
* the caller can re-resolve and retry.
|
|
134
|
+
*/
|
|
135
|
+
act(ref: number, op: string, value?: string, extraFlags?: Record<string, string>): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Trusted native click at viewport coordinates via vs_click_at. The
|
|
138
|
+
* cursor op leaves the daemon's delta baseline and last token
|
|
139
|
+
* untouched, so `synced` survives (the next delta view picks up the
|
|
140
|
+
* click's effects) but `fresh` does not.
|
|
141
|
+
*/
|
|
142
|
+
clickAt(x: number, y: number, mode?: InputMode): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Text of one ref and its subtree via vs_read. The body renders each
|
|
145
|
+
* node as `[ref] role: label`, indented; the labels are the text.
|
|
146
|
+
*/
|
|
147
|
+
readRef(ref: number): Promise<string>;
|
|
148
|
+
/** Trusted per-character typing into the focused element. */
|
|
149
|
+
typeTrusted(text: string, options?: {
|
|
150
|
+
secret?: boolean;
|
|
151
|
+
mode?: InputMode;
|
|
152
|
+
}): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Block until a daemon-side wait condition holds. The returned wait
|
|
155
|
+
* token is deliberately not cached: vs_wait computes it from a raw
|
|
156
|
+
* engine snapshot without advancing the page's last-emitted token,
|
|
157
|
+
* so it is not valid as an act pre-image.
|
|
158
|
+
*/
|
|
159
|
+
waitFor(cond: 'stable' | 'net-idle' | 'token-change' | 'text' | 'ref' | 'gone', value?: string, timeoutMs?: number): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Bounding rects for refs via vs_layout. Body lines look like
|
|
162
|
+
* `<ref> x=0 y=0 w=0 h=0 visible=false z=0`.
|
|
163
|
+
*/
|
|
164
|
+
layout(refs: number[]): Promise<Map<number, LayoutRect>>;
|
|
165
|
+
/**
|
|
166
|
+
* Evaluate a JavaScript expression or function in the page and
|
|
167
|
+
* return its JSON-serializable result. A function is called with no
|
|
168
|
+
* arguments. Runs through vs_inspect eval, which reads the page
|
|
169
|
+
* without mutating the daemon's state token.
|
|
170
|
+
*/
|
|
171
|
+
evaluate<T = unknown>(fnOrExpr: string | (() => unknown)): Promise<T>;
|
|
172
|
+
/** The page's current URL. */
|
|
173
|
+
url(): Promise<string>;
|
|
174
|
+
/**
|
|
175
|
+
* Save a PNG of the viewport (or the whole page with `fullPage`).
|
|
176
|
+
* Returns the file path; with `path`, the file is copied there.
|
|
177
|
+
*/
|
|
178
|
+
screenshot(options?: {
|
|
179
|
+
path?: string;
|
|
180
|
+
fullPage?: boolean;
|
|
181
|
+
}): Promise<string>;
|
|
182
|
+
/**
|
|
183
|
+
* Save this page's login state (cookies, local and session storage,
|
|
184
|
+
* IndexedDB) under `name`, encrypted at rest by the daemon. Load it
|
|
185
|
+
* in a later run with loadAuth(name) to skip the login flow.
|
|
186
|
+
*/
|
|
187
|
+
saveAuth(name: string): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Restore login state saved with saveAuth(name). Storage is per
|
|
190
|
+
* origin, so goto() a page on the site first, then load, then goto()
|
|
191
|
+
* the page under test.
|
|
192
|
+
*/
|
|
193
|
+
loadAuth(name: string): Promise<void>;
|
|
194
|
+
/** Delete login state saved under `name`. */
|
|
195
|
+
clearAuth(name: string): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Trusted native pointer input at viewport coordinates (CSS px).
|
|
198
|
+
* Every event reaches the page with isTrusted=true, so canvas apps,
|
|
199
|
+
* sliders and drag-and-drop work. Cadence follows the page's input
|
|
200
|
+
* mode unless a call overrides it.
|
|
201
|
+
*/
|
|
202
|
+
readonly mouse: {
|
|
203
|
+
move: (x: number, y: number, options?: {
|
|
204
|
+
mode?: InputMode;
|
|
205
|
+
}) => Promise<void>;
|
|
206
|
+
click: (x: number, y: number, options?: {
|
|
207
|
+
mode?: InputMode;
|
|
208
|
+
}) => Promise<void>;
|
|
209
|
+
/** Press at (x1, y1), move along a path, release at (x2, y2). Fires the HTML5 drag events too. */
|
|
210
|
+
drag: (x1: number, y1: number, x2: number, y2: number, options?: {
|
|
211
|
+
mode?: InputMode;
|
|
212
|
+
}) => Promise<void>;
|
|
213
|
+
};
|
|
214
|
+
private cursorOp;
|
|
215
|
+
/** The whole page as template text (see toMatchAriaSnapshot). */
|
|
216
|
+
ariaSnapshot(): Promise<string>;
|
|
217
|
+
/** The document title (the doc node's label). */
|
|
218
|
+
title(): Promise<string>;
|
|
219
|
+
getByRole(role: string, options?: ByRoleOptions): Locator;
|
|
220
|
+
getByText(text: string | RegExp, options?: ByTextOptions): Locator;
|
|
221
|
+
getByLabel(text: string | RegExp, options?: ByTextOptions): Locator;
|
|
222
|
+
close(): Promise<void>;
|
|
223
|
+
}
|