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/page.js
ADDED
|
@@ -0,0 +1,491 @@
|
|
|
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
|
+
/** Parse `<ref> x=.. y=.. w=.. h=.. visible=.. z=..` lines; `!` error lines are skipped. */
|
|
7
|
+
function parseLayoutLines(lines) {
|
|
8
|
+
const out = new Map();
|
|
9
|
+
for (const line of lines) {
|
|
10
|
+
if (line.startsWith('!'))
|
|
11
|
+
continue;
|
|
12
|
+
const tokens = line.trim().split(/\s+/);
|
|
13
|
+
const ref = Number(tokens[0]);
|
|
14
|
+
if (!Number.isInteger(ref))
|
|
15
|
+
continue;
|
|
16
|
+
const rect = { x: 0, y: 0, w: 0, h: 0, visible: false };
|
|
17
|
+
for (const tok of tokens.slice(1)) {
|
|
18
|
+
const eq = tok.indexOf('=');
|
|
19
|
+
if (eq <= 0)
|
|
20
|
+
continue;
|
|
21
|
+
const k = tok.slice(0, eq);
|
|
22
|
+
const v = tok.slice(eq + 1);
|
|
23
|
+
if (k === 'visible')
|
|
24
|
+
rect.visible = v === 'true';
|
|
25
|
+
else if (k === 'x')
|
|
26
|
+
rect.x = Number(v);
|
|
27
|
+
else if (k === 'y')
|
|
28
|
+
rect.y = Number(v);
|
|
29
|
+
else if (k === 'w')
|
|
30
|
+
rect.w = Number(v);
|
|
31
|
+
else if (k === 'h')
|
|
32
|
+
rect.h = Number(v);
|
|
33
|
+
}
|
|
34
|
+
out.set(ref, rect);
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
import { WireError } from "./errors.js";
|
|
39
|
+
import { applyDelta, isDeltaBody, parseFullTree, walk } from "./tree.js";
|
|
40
|
+
import { Locator } from "./locator.js";
|
|
41
|
+
import { renderSnapshot } from "./aria.js";
|
|
42
|
+
export const DEFAULT_TIMEOUTS = {
|
|
43
|
+
action: 10_000,
|
|
44
|
+
expect: 5_000,
|
|
45
|
+
navigation: 30_000,
|
|
46
|
+
};
|
|
47
|
+
export class Page {
|
|
48
|
+
pageId = null;
|
|
49
|
+
token = null;
|
|
50
|
+
/** Last known tree, kept in sync via full views and deltas. */
|
|
51
|
+
snapshot = null;
|
|
52
|
+
/**
|
|
53
|
+
* True while `snapshot` equals the daemon's delta baseline (our last
|
|
54
|
+
* applied view, with no act in between). The daemon advances its
|
|
55
|
+
* baseline on every act and discards that delta, so after an act the
|
|
56
|
+
* next view must be requested `--full`; between plain views, deltas
|
|
57
|
+
* are sound. Cursor ops (click-at) do not touch the baseline, so
|
|
58
|
+
* they leave this flag alone.
|
|
59
|
+
*/
|
|
60
|
+
synced = false;
|
|
61
|
+
/**
|
|
62
|
+
* True while `snapshot` also reflects current page reality, so an
|
|
63
|
+
* action can resolve against it without a read. Any mutation clears
|
|
64
|
+
* it. Distinct from `synced`: a click-at leaves the baseline (and
|
|
65
|
+
* the daemon's last token) untouched, so the token check would not
|
|
66
|
+
* catch acting on the pre-click tree; this flag forces the re-read.
|
|
67
|
+
*/
|
|
68
|
+
fresh = false;
|
|
69
|
+
client;
|
|
70
|
+
sessionId;
|
|
71
|
+
timeouts;
|
|
72
|
+
inputMode;
|
|
73
|
+
clickVia;
|
|
74
|
+
actDeltas;
|
|
75
|
+
navInPlace;
|
|
76
|
+
baseURL;
|
|
77
|
+
constructor(client, sessionId, timeouts, inputMode = 'robotic', clickVia = 'click-at', protocol = {}, baseURL) {
|
|
78
|
+
this.baseURL = baseURL;
|
|
79
|
+
this.client = client;
|
|
80
|
+
this.sessionId = sessionId;
|
|
81
|
+
this.timeouts = timeouts;
|
|
82
|
+
this.inputMode = inputMode;
|
|
83
|
+
this.clickVia = clickVia;
|
|
84
|
+
this.actDeltas = protocol.actDeltas ?? false;
|
|
85
|
+
this.navInPlace = protocol.navInPlace ?? false;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Fold a 0.2 mutation response body (the ViewForm the daemon emitted
|
|
89
|
+
* while advancing its baseline) into the snapshot. Empty body means
|
|
90
|
+
* NoChange; a full tree replaces; a delta applies when we hold the
|
|
91
|
+
* pre-mutation baseline, otherwise the snapshot is unusable until
|
|
92
|
+
* the next full view.
|
|
93
|
+
*/
|
|
94
|
+
applyMutationBody(resp) {
|
|
95
|
+
const first = resp.body[0];
|
|
96
|
+
if (first === undefined)
|
|
97
|
+
return;
|
|
98
|
+
if (!isDeltaBody(first)) {
|
|
99
|
+
this.snapshot = parseFullTree(resp.body);
|
|
100
|
+
this.synced = true;
|
|
101
|
+
this.fresh = true;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (this.synced && this.snapshot) {
|
|
105
|
+
applyDelta(this.snapshot, resp.body);
|
|
106
|
+
this.fresh = true;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.synced = false;
|
|
110
|
+
this.fresh = false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
get id() {
|
|
114
|
+
if (!this.pageId)
|
|
115
|
+
throw new Error('page has no URL yet; call page.goto(url) first');
|
|
116
|
+
return this.pageId;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Navigate to a URL, relative to the baseURL launch option when set.
|
|
120
|
+
* Navigates in place on protocol-v1 daemons; older ones close the
|
|
121
|
+
* page and open a new one.
|
|
122
|
+
*/
|
|
123
|
+
async goto(target) {
|
|
124
|
+
const url = this.baseURL ? new URL(target, this.baseURL).href : target;
|
|
125
|
+
if (this.pageId && this.navInPlace) {
|
|
126
|
+
try {
|
|
127
|
+
const resp = await this.client.call('vs_goto', [this.pageId, url], {
|
|
128
|
+
session: this.sessionId,
|
|
129
|
+
});
|
|
130
|
+
this.token = resp.token;
|
|
131
|
+
this.snapshot = null;
|
|
132
|
+
this.synced = false;
|
|
133
|
+
this.fresh = false;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// Old daemon or dead page; fall through to close+open.
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (this.pageId) {
|
|
141
|
+
await this.client
|
|
142
|
+
.call('vs_close', [this.pageId], { session: this.sessionId })
|
|
143
|
+
.catch(() => { });
|
|
144
|
+
this.pageId = null;
|
|
145
|
+
}
|
|
146
|
+
this.token = null;
|
|
147
|
+
this.snapshot = null;
|
|
148
|
+
this.synced = false;
|
|
149
|
+
this.fresh = false;
|
|
150
|
+
const resp = await this.client.call('vs_open', [url], { session: this.sessionId });
|
|
151
|
+
const id = resp.body[0];
|
|
152
|
+
if (!id)
|
|
153
|
+
throw new Error(`vs_open returned no page id for ${url}`);
|
|
154
|
+
this.pageId = id;
|
|
155
|
+
this.token = resp.token;
|
|
156
|
+
// No settle wait here: locators auto-wait and assertions poll, so
|
|
157
|
+
// a still-loading tree just resolves a poll tick later.
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Refresh the snapshot from the daemon and return it. Sends a plain
|
|
161
|
+
* (delta) view when our snapshot matches the daemon's baseline and a
|
|
162
|
+
* `--full` view otherwise; the body shape decides how it is applied,
|
|
163
|
+
* so a surprise full tree (navigation, daemon restart) is handled
|
|
164
|
+
* either way.
|
|
165
|
+
*/
|
|
166
|
+
async view() {
|
|
167
|
+
const canDelta = this.synced && this.snapshot !== null;
|
|
168
|
+
const flags = { session: this.sessionId };
|
|
169
|
+
if (!canDelta)
|
|
170
|
+
flags['full'] = true;
|
|
171
|
+
const resp = await this.client.call('vs_view', [this.id], flags);
|
|
172
|
+
return this.applyViewResponse(resp, canDelta);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* One round trip for view + layout via the `--layout=` composite:
|
|
176
|
+
* the daemon appends rect lines for the requested refs as an extra
|
|
177
|
+
* body section. Refs no longer in the tree come back as inline
|
|
178
|
+
* NOT_FOUND lines and are simply absent from the map.
|
|
179
|
+
*/
|
|
180
|
+
async viewWithLayout(refs) {
|
|
181
|
+
if (refs.length === 0) {
|
|
182
|
+
return { snap: await this.view(), rects: new Map() };
|
|
183
|
+
}
|
|
184
|
+
const canDelta = this.synced && this.snapshot !== null;
|
|
185
|
+
const flags = {
|
|
186
|
+
session: this.sessionId,
|
|
187
|
+
layout: refs.join(','),
|
|
188
|
+
};
|
|
189
|
+
if (!canDelta)
|
|
190
|
+
flags['full'] = true;
|
|
191
|
+
const resp = await this.client.call('vs_view', [this.id], flags, { extraSections: 1 });
|
|
192
|
+
const snap = this.applyViewResponse(resp, canDelta);
|
|
193
|
+
return { snap, rects: parseLayoutLines(resp.sections[0] ?? []) };
|
|
194
|
+
}
|
|
195
|
+
applyViewResponse(resp, canDelta) {
|
|
196
|
+
this.token = resp.token;
|
|
197
|
+
const first = resp.body[0];
|
|
198
|
+
if (first === undefined) {
|
|
199
|
+
// No change since our baseline (or a genuinely empty page).
|
|
200
|
+
this.snapshot ??= { nodes: new Map(), roots: [] };
|
|
201
|
+
}
|
|
202
|
+
else if (canDelta && this.snapshot && isDeltaBody(first)) {
|
|
203
|
+
applyDelta(this.snapshot, resp.body);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
this.snapshot = parseFullTree(resp.body);
|
|
207
|
+
}
|
|
208
|
+
this.synced = true;
|
|
209
|
+
this.fresh = true;
|
|
210
|
+
return this.snapshot;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Snapshot for resolving an action target: the cached tree when it
|
|
214
|
+
* is still baseline-synced, otherwise a fresh view. Acting on a
|
|
215
|
+
* cached tree is safe because every mutation carries our token; if
|
|
216
|
+
* the page moved on, the daemon answers STALE_TOKEN and the action
|
|
217
|
+
* loop re-resolves against a fresh view.
|
|
218
|
+
*/
|
|
219
|
+
async actionSnapshot() {
|
|
220
|
+
if (this.fresh && this.snapshot)
|
|
221
|
+
return this.snapshot;
|
|
222
|
+
return this.view();
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Run one act primitive against a ref with the cached token. On
|
|
226
|
+
* STALE_TOKEN the cached token is refreshed before rethrowing, so
|
|
227
|
+
* the caller can re-resolve and retry.
|
|
228
|
+
*/
|
|
229
|
+
async act(ref, op, value, extraFlags) {
|
|
230
|
+
if (this.token === null)
|
|
231
|
+
await this.view();
|
|
232
|
+
const args = value === undefined ? [this.id, String(ref), op] : [this.id, String(ref), op, value];
|
|
233
|
+
try {
|
|
234
|
+
const resp = await this.client.call('vs_act', args, {
|
|
235
|
+
...extraFlags,
|
|
236
|
+
session: this.sessionId,
|
|
237
|
+
token: this.token ?? '',
|
|
238
|
+
});
|
|
239
|
+
this.token = resp.token;
|
|
240
|
+
if (this.actDeltas) {
|
|
241
|
+
this.applyMutationBody(resp);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
// 0.1.x: the act advanced the daemon's delta baseline without
|
|
245
|
+
// showing us the delta; the cached tree cannot be patched.
|
|
246
|
+
this.synced = false;
|
|
247
|
+
this.fresh = false;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
if (e instanceof WireError && e.code === 'STALE_TOKEN' && e.args[0]) {
|
|
252
|
+
this.token = e.args[0];
|
|
253
|
+
}
|
|
254
|
+
this.synced = false;
|
|
255
|
+
this.fresh = false;
|
|
256
|
+
throw e;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Trusted native click at viewport coordinates via vs_click_at. The
|
|
261
|
+
* cursor op leaves the daemon's delta baseline and last token
|
|
262
|
+
* untouched, so `synced` survives (the next delta view picks up the
|
|
263
|
+
* click's effects) but `fresh` does not.
|
|
264
|
+
*/
|
|
265
|
+
async clickAt(x, y, mode) {
|
|
266
|
+
if (this.token === null)
|
|
267
|
+
await this.view();
|
|
268
|
+
try {
|
|
269
|
+
const resp = await this.client.call('vs_click_at', [this.id, String(Math.round(x)), String(Math.round(y))], { session: this.sessionId, token: this.token ?? '', mode: mode ?? this.inputMode });
|
|
270
|
+
this.token = resp.token;
|
|
271
|
+
if (this.actDeltas) {
|
|
272
|
+
this.applyMutationBody(resp);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
// 0.1.x cursor ops leave the baseline (and token) untouched;
|
|
276
|
+
// the snapshot just needs a re-read before the next action.
|
|
277
|
+
this.fresh = false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
catch (e) {
|
|
281
|
+
if (e instanceof WireError && e.code === 'STALE_TOKEN' && e.args[0]) {
|
|
282
|
+
this.token = e.args[0];
|
|
283
|
+
}
|
|
284
|
+
this.synced = false;
|
|
285
|
+
this.fresh = false;
|
|
286
|
+
throw e;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Text of one ref and its subtree via vs_read. The body renders each
|
|
291
|
+
* node as `[ref] role: label`, indented; the labels are the text.
|
|
292
|
+
*/
|
|
293
|
+
async readRef(ref) {
|
|
294
|
+
const resp = await this.client.call('vs_read', [this.id, String(ref)], {
|
|
295
|
+
session: this.sessionId,
|
|
296
|
+
});
|
|
297
|
+
this.token = resp.token;
|
|
298
|
+
return resp.body
|
|
299
|
+
.map((l) => l.replace(/^\s*\[\d+\] [^:]*: ?/, ''))
|
|
300
|
+
.filter((l) => l.trim() !== '')
|
|
301
|
+
.join(' ');
|
|
302
|
+
}
|
|
303
|
+
/** Trusted per-character typing into the focused element. */
|
|
304
|
+
async typeTrusted(text, options) {
|
|
305
|
+
const flags = {
|
|
306
|
+
session: this.sessionId,
|
|
307
|
+
token: this.token ?? '',
|
|
308
|
+
mode: options?.mode ?? this.inputMode,
|
|
309
|
+
};
|
|
310
|
+
if (options?.secret)
|
|
311
|
+
flags['secret'] = true;
|
|
312
|
+
try {
|
|
313
|
+
const resp = await this.client.call('vs_type', [this.id, text], flags);
|
|
314
|
+
this.token = resp.token;
|
|
315
|
+
// vs_type advances neither baseline nor token on any released
|
|
316
|
+
// engine; the snapshot stays delta-patchable but not fresh.
|
|
317
|
+
this.fresh = false;
|
|
318
|
+
}
|
|
319
|
+
catch (e) {
|
|
320
|
+
this.synced = false;
|
|
321
|
+
this.fresh = false;
|
|
322
|
+
throw e;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Block until a daemon-side wait condition holds. The returned wait
|
|
327
|
+
* token is deliberately not cached: vs_wait computes it from a raw
|
|
328
|
+
* engine snapshot without advancing the page's last-emitted token,
|
|
329
|
+
* so it is not valid as an act pre-image.
|
|
330
|
+
*/
|
|
331
|
+
async waitFor(cond, value, timeoutMs) {
|
|
332
|
+
const args = value === undefined ? [this.id, cond] : [this.id, cond, value];
|
|
333
|
+
const budget = timeoutMs ?? this.timeouts.navigation;
|
|
334
|
+
const resp = await this.client.call('vs_wait', args, { session: this.sessionId, timeout: String(budget) }, { timeoutMs: budget + 10_000 });
|
|
335
|
+
if (this.actDeltas) {
|
|
336
|
+
// 0.2 wait advances the baseline without emitting the tree; the
|
|
337
|
+
// token is a valid pre-image but the snapshot must be re-read.
|
|
338
|
+
this.token = resp.token;
|
|
339
|
+
this.synced = false;
|
|
340
|
+
this.fresh = false;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Bounding rects for refs via vs_layout. Body lines look like
|
|
345
|
+
* `<ref> x=0 y=0 w=0 h=0 visible=false z=0`.
|
|
346
|
+
*/
|
|
347
|
+
async layout(refs) {
|
|
348
|
+
if (refs.length === 0)
|
|
349
|
+
return new Map();
|
|
350
|
+
const resp = await this.client.call('vs_layout', [this.id, ...refs.map(String)], {
|
|
351
|
+
session: this.sessionId,
|
|
352
|
+
});
|
|
353
|
+
this.token = resp.token;
|
|
354
|
+
return parseLayoutLines(resp.body);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Evaluate a JavaScript expression or function in the page and
|
|
358
|
+
* return its JSON-serializable result. A function is called with no
|
|
359
|
+
* arguments. Runs through vs_inspect eval, which reads the page
|
|
360
|
+
* without mutating the daemon's state token.
|
|
361
|
+
*/
|
|
362
|
+
async evaluate(fnOrExpr) {
|
|
363
|
+
const src = typeof fnOrExpr === 'function' ? `(${fnOrExpr.toString()})()` : `(${fnOrExpr})`;
|
|
364
|
+
const resp = await this.client.call('vs_inspect', ['eval', this.id, `JSON.stringify(${src}) ?? "null"`], { session: this.sessionId, full: true });
|
|
365
|
+
const line = resp.body.find((l) => l.startsWith('result='));
|
|
366
|
+
if (line === undefined) {
|
|
367
|
+
throw new Error(`evaluate failed: ${resp.body.join(' ').slice(0, 300)}`);
|
|
368
|
+
}
|
|
369
|
+
return JSON.parse(line.slice('result='.length));
|
|
370
|
+
}
|
|
371
|
+
/** The page's current URL. */
|
|
372
|
+
async url() {
|
|
373
|
+
return this.evaluate('location.href');
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Save a PNG of the viewport (or the whole page with `fullPage`).
|
|
377
|
+
* Returns the file path; with `path`, the file is copied there.
|
|
378
|
+
*/
|
|
379
|
+
async screenshot(options = {}) {
|
|
380
|
+
const flags = { session: this.sessionId };
|
|
381
|
+
if (options.fullPage)
|
|
382
|
+
flags['full-page'] = true;
|
|
383
|
+
const resp = await this.client.call('vs_capture', [this.id], flags);
|
|
384
|
+
const saved = (resp.body[0] ?? '').trim();
|
|
385
|
+
if (!saved)
|
|
386
|
+
throw new Error('vs_capture returned no path');
|
|
387
|
+
if (!options.path)
|
|
388
|
+
return saved;
|
|
389
|
+
const fs = await import('node:fs/promises');
|
|
390
|
+
const nodePath = await import('node:path');
|
|
391
|
+
await fs.mkdir(nodePath.dirname(options.path), { recursive: true });
|
|
392
|
+
await fs.copyFile(saved, options.path);
|
|
393
|
+
return options.path;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Save this page's login state (cookies, local and session storage,
|
|
397
|
+
* IndexedDB) under `name`, encrypted at rest by the daemon. Load it
|
|
398
|
+
* in a later run with loadAuth(name) to skip the login flow.
|
|
399
|
+
*/
|
|
400
|
+
async saveAuth(name) {
|
|
401
|
+
await this.client.call('vs_auth', ['save', this.id, name], { session: this.sessionId });
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Restore login state saved with saveAuth(name). Storage is per
|
|
405
|
+
* origin, so goto() a page on the site first, then load, then goto()
|
|
406
|
+
* the page under test.
|
|
407
|
+
*/
|
|
408
|
+
async loadAuth(name) {
|
|
409
|
+
// The reply carries the zero token, not a page state; re-read later.
|
|
410
|
+
await this.client.call('vs_auth', ['load', this.id, name], { session: this.sessionId });
|
|
411
|
+
this.token = null;
|
|
412
|
+
this.synced = false;
|
|
413
|
+
this.fresh = false;
|
|
414
|
+
}
|
|
415
|
+
/** Delete login state saved under `name`. */
|
|
416
|
+
async clearAuth(name) {
|
|
417
|
+
await this.client.call('vs_auth', ['clear', name], { session: this.sessionId });
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Trusted native pointer input at viewport coordinates (CSS px).
|
|
421
|
+
* Every event reaches the page with isTrusted=true, so canvas apps,
|
|
422
|
+
* sliders and drag-and-drop work. Cadence follows the page's input
|
|
423
|
+
* mode unless a call overrides it.
|
|
424
|
+
*/
|
|
425
|
+
mouse = {
|
|
426
|
+
move: (x, y, options) => this.cursorOp('vs_move_to', [x, y], options?.mode, false),
|
|
427
|
+
click: (x, y, options) => this.clickAt(x, y, options?.mode),
|
|
428
|
+
/** Press at (x1, y1), move along a path, release at (x2, y2). Fires the HTML5 drag events too. */
|
|
429
|
+
drag: (x1, y1, x2, y2, options) => this.cursorOp('vs_drag', [x1, y1, x2, y2], options?.mode, true),
|
|
430
|
+
};
|
|
431
|
+
async cursorOp(op, coords, mode, mutates) {
|
|
432
|
+
if (this.token === null)
|
|
433
|
+
await this.view();
|
|
434
|
+
const flags = { session: this.sessionId, mode: mode ?? this.inputMode };
|
|
435
|
+
if (mutates)
|
|
436
|
+
flags['token'] = this.token ?? '';
|
|
437
|
+
try {
|
|
438
|
+
const resp = await this.client.call(op, [this.id, ...coords.map((c) => String(Math.round(c)))], flags);
|
|
439
|
+
if (resp.token && !/^0+$/.test(resp.token))
|
|
440
|
+
this.token = resp.token;
|
|
441
|
+
if (mutates && this.actDeltas)
|
|
442
|
+
this.applyMutationBody(resp);
|
|
443
|
+
else
|
|
444
|
+
this.fresh = false;
|
|
445
|
+
}
|
|
446
|
+
catch (e) {
|
|
447
|
+
if (e instanceof WireError && e.code === 'STALE_TOKEN' && e.args[0]) {
|
|
448
|
+
this.token = e.args[0];
|
|
449
|
+
}
|
|
450
|
+
this.synced = false;
|
|
451
|
+
this.fresh = false;
|
|
452
|
+
throw e;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
/** The whole page as template text (see toMatchAriaSnapshot). */
|
|
456
|
+
async ariaSnapshot() {
|
|
457
|
+
const snap = await this.view();
|
|
458
|
+
return renderSnapshot(snap, snap.roots);
|
|
459
|
+
}
|
|
460
|
+
/** The document title (the doc node's label). */
|
|
461
|
+
async title() {
|
|
462
|
+
const snap = await this.view();
|
|
463
|
+
for (const node of walk(snap)) {
|
|
464
|
+
if (node.role === 'doc')
|
|
465
|
+
return node.label;
|
|
466
|
+
}
|
|
467
|
+
return '';
|
|
468
|
+
}
|
|
469
|
+
getByRole(role, options = {}) {
|
|
470
|
+
return new Locator(this, { kind: 'role', role, options });
|
|
471
|
+
}
|
|
472
|
+
getByText(text, options = {}) {
|
|
473
|
+
return new Locator(this, { kind: 'text', text, options });
|
|
474
|
+
}
|
|
475
|
+
getByLabel(text, options = {}) {
|
|
476
|
+
return new Locator(this, { kind: 'label', text, options });
|
|
477
|
+
}
|
|
478
|
+
async close() {
|
|
479
|
+
if (!this.pageId)
|
|
480
|
+
return;
|
|
481
|
+
await this.client
|
|
482
|
+
.call('vs_close', [this.pageId], { session: this.sessionId })
|
|
483
|
+
.catch(() => { });
|
|
484
|
+
this.pageId = null;
|
|
485
|
+
this.token = null;
|
|
486
|
+
this.snapshot = null;
|
|
487
|
+
this.synced = false;
|
|
488
|
+
this.fresh = false;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
//# sourceMappingURL=page.js.map
|
package/dist/page.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,4FAA4F;AAC5F,SAAS,gBAAgB,CAAC,KAAe;IACvC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CA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,GAAE,CAAC,CAAC,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
|
package/dist/roles.d.ts
ADDED
package/dist/roles.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Role vocabulary shared by locators and tree snapshots. */
|
|
2
|
+
/** ARIA role names accepted by getByRole, mapped to wire role codes. */
|
|
3
|
+
export const ROLE_TO_CODES = {
|
|
4
|
+
document: ['doc'],
|
|
5
|
+
button: ['btn'],
|
|
6
|
+
link: ['lnk'],
|
|
7
|
+
textbox: ['tf', 'ta'],
|
|
8
|
+
combobox: ['sel'],
|
|
9
|
+
checkbox: ['chk'],
|
|
10
|
+
radio: ['rad'],
|
|
11
|
+
img: ['img'],
|
|
12
|
+
image: ['img'],
|
|
13
|
+
heading: ['hd'],
|
|
14
|
+
paragraph: ['p'],
|
|
15
|
+
listitem: ['li'],
|
|
16
|
+
list: ['lst'],
|
|
17
|
+
table: ['tbl'],
|
|
18
|
+
row: ['row'],
|
|
19
|
+
cell: ['cell'],
|
|
20
|
+
columnheader: ['hdr'],
|
|
21
|
+
navigation: ['nav'],
|
|
22
|
+
form: ['frm'],
|
|
23
|
+
dialog: ['dlg'],
|
|
24
|
+
menuitem: ['itm'],
|
|
25
|
+
tab: ['itm'],
|
|
26
|
+
option: ['itm'],
|
|
27
|
+
region: ['sec'],
|
|
28
|
+
article: ['art'],
|
|
29
|
+
main: ['mn'],
|
|
30
|
+
iframe: ['ifr'],
|
|
31
|
+
generic: ['el'],
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.js","sourceRoot":"","sources":["../src/roles.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,wEAAwE;AACxE,MAAM,CAAC,MAAM,aAAa,GAA6B;IACrD,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,MAAM,EAAE,CAAC,KAAK,CAAC;IACf,IAAI,EAAE,CAAC,KAAK,CAAC;IACb,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,KAAK,EAAE,CAAC,KAAK,CAAC;IACd,GAAG,EAAE,CAAC,KAAK,CAAC;IACZ,KAAK,EAAE,CAAC,KAAK,CAAC;IACd,OAAO,EAAE,CAAC,IAAI,CAAC;IACf,SAAS,EAAE,CAAC,GAAG,CAAC;IAChB,QAAQ,EAAE,CAAC,IAAI,CAAC;IAChB,IAAI,EAAE,CAAC,KAAK,CAAC;IACb,KAAK,EAAE,CAAC,KAAK,CAAC;IACd,GAAG,EAAE,CAAC,KAAK,CAAC;IACZ,IAAI,EAAE,CAAC,MAAM,CAAC;IACd,YAAY,EAAE,CAAC,KAAK,CAAC;IACrB,UAAU,EAAE,CAAC,KAAK,CAAC;IACnB,IAAI,EAAE,CAAC,KAAK,CAAC;IACb,MAAM,EAAE,CAAC,KAAK,CAAC;IACf,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,GAAG,EAAE,CAAC,KAAK,CAAC;IACZ,MAAM,EAAE,CAAC,KAAK,CAAC;IACf,MAAM,EAAE,CAAC,KAAK,CAAC;IACf,OAAO,EAAE,CAAC,KAAK,CAAC;IAChB,IAAI,EAAE,CAAC,IAAI,CAAC;IACZ,MAAM,EAAE,CAAC,KAAK,CAAC;IACf,OAAO,EAAE,CAAC,IAAI,CAAC;CAChB,CAAC"}
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A thin `test` wrapper over node:test that provides the `{ page }`
|
|
3
|
+
* fixture. One browser session is shared across the file; each test
|
|
4
|
+
* gets a fresh page that is closed afterwards.
|
|
5
|
+
*
|
|
6
|
+
* The locator and assertion library is runner-agnostic; under vitest
|
|
7
|
+
* or plain node:test you can skip this wrapper and manage a Browser
|
|
8
|
+
* yourself with `Browser.launch()`.
|
|
9
|
+
*/
|
|
10
|
+
import { type LaunchOptions } from './browser.ts';
|
|
11
|
+
import type { Page } from './page.ts';
|
|
12
|
+
export interface TestFixtures {
|
|
13
|
+
page: Page;
|
|
14
|
+
}
|
|
15
|
+
export interface RunnerOptions extends LaunchOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Start every test's page logged in: open `url` (any page on the
|
|
18
|
+
* site), restore the login saved under `name` with page.saveAuth(),
|
|
19
|
+
* and hand the test the page. Storage is per origin, which is why a
|
|
20
|
+
* URL on the site is needed.
|
|
21
|
+
*/
|
|
22
|
+
auth?: {
|
|
23
|
+
name: string;
|
|
24
|
+
url: string;
|
|
25
|
+
};
|
|
26
|
+
/** Save a PNG of the page when a test fails. Default `off`. */
|
|
27
|
+
screenshot?: 'off' | 'only-on-failure';
|
|
28
|
+
/** Directory for failure screenshots. Default `test-results`. */
|
|
29
|
+
outputDir?: string;
|
|
30
|
+
}
|
|
31
|
+
type TestFn = (fixtures: TestFixtures) => Promise<void> | void;
|
|
32
|
+
type HookFn = (fixtures: TestFixtures) => Promise<void> | void;
|
|
33
|
+
/** Override options for the shared browser. Call before the first test runs. */
|
|
34
|
+
export declare function configure(next: RunnerOptions): void;
|
|
35
|
+
export declare function test(name: string, fn: TestFn): void;
|
|
36
|
+
export declare namespace test {
|
|
37
|
+
var only: (name: string, fn: TestFn) => void;
|
|
38
|
+
var skip: (name: string, fn: TestFn) => void;
|
|
39
|
+
var describe: (name: string, body: () => void) => void;
|
|
40
|
+
var beforeEach: (fn: HookFn) => void;
|
|
41
|
+
var afterEach: (fn: HookFn) => void;
|
|
42
|
+
}
|
|
43
|
+
export {};
|