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/runner.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
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 { test as nodeTest, describe as nodeDescribe, after } from 'node:test';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import { Browser } from "./browser.js";
|
|
13
|
+
let shared = null;
|
|
14
|
+
let options = {};
|
|
15
|
+
let teardownRegistered = false;
|
|
16
|
+
/** Hooks registered at each describe depth, innermost last. */
|
|
17
|
+
const hookStack = [{ before: [], after: [] }];
|
|
18
|
+
/** Override options for the shared browser. Call before the first test runs. */
|
|
19
|
+
export function configure(next) {
|
|
20
|
+
options = next;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Register the session teardown as a root-level after() hook. This
|
|
24
|
+
* must happen at test registration time (when the user's test file
|
|
25
|
+
* calls test() at module scope), not during a test run: a hook
|
|
26
|
+
* registered mid-test attaches to that test and would close the
|
|
27
|
+
* shared browser after the first test finishes.
|
|
28
|
+
*/
|
|
29
|
+
function ensureTeardown() {
|
|
30
|
+
if (teardownRegistered)
|
|
31
|
+
return;
|
|
32
|
+
teardownRegistered = true;
|
|
33
|
+
after(async () => {
|
|
34
|
+
if (shared)
|
|
35
|
+
await (await shared).close();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function sharedBrowser() {
|
|
39
|
+
shared ??= Browser.launch(options);
|
|
40
|
+
return shared;
|
|
41
|
+
}
|
|
42
|
+
function safeName(name) {
|
|
43
|
+
return name.replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^-|-$/g, '').slice(0, 120) || 'test';
|
|
44
|
+
}
|
|
45
|
+
function runWith(name, fn) {
|
|
46
|
+
// Capture the scopes now, at registration (a describe block pops its
|
|
47
|
+
// scope once its body has run), but read their hooks at run time so
|
|
48
|
+
// a hook declared after a test in the same scope still applies.
|
|
49
|
+
const scopes = [...hookStack];
|
|
50
|
+
return async () => {
|
|
51
|
+
const befores = scopes.flatMap((h) => h.before);
|
|
52
|
+
const afters = scopes.flatMap((h) => h.after).reverse();
|
|
53
|
+
const browser = await sharedBrowser();
|
|
54
|
+
const page = browser.newPage();
|
|
55
|
+
try {
|
|
56
|
+
if (options.auth) {
|
|
57
|
+
await page.goto(options.auth.url);
|
|
58
|
+
await page.loadAuth(options.auth.name);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
for (const h of befores)
|
|
62
|
+
await h({ page });
|
|
63
|
+
await fn({ page });
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
if (options.screenshot === 'only-on-failure') {
|
|
67
|
+
const file = path.join(options.outputDir ?? 'test-results', `${safeName(name)}.png`);
|
|
68
|
+
const saved = await page.screenshot({ path: file }).catch(() => null);
|
|
69
|
+
if (saved && e instanceof Error)
|
|
70
|
+
e.message += `\n screenshot: ${saved}`;
|
|
71
|
+
}
|
|
72
|
+
throw e;
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
for (const h of afters)
|
|
76
|
+
await h({ page });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
await page.close().catch(() => { });
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function test(name, fn) {
|
|
85
|
+
ensureTeardown();
|
|
86
|
+
nodeTest(name, runWith(name, fn));
|
|
87
|
+
}
|
|
88
|
+
test.only = (name, fn) => {
|
|
89
|
+
ensureTeardown();
|
|
90
|
+
nodeTest(name, { only: true }, runWith(name, fn));
|
|
91
|
+
};
|
|
92
|
+
test.skip = (name, fn) => {
|
|
93
|
+
ensureTeardown();
|
|
94
|
+
nodeTest(name, { skip: true }, runWith(name, fn));
|
|
95
|
+
};
|
|
96
|
+
/** Group tests. Hooks registered inside apply to the group's tests only. */
|
|
97
|
+
test.describe = (name, body) => {
|
|
98
|
+
ensureTeardown();
|
|
99
|
+
nodeDescribe(name, () => {
|
|
100
|
+
hookStack.push({ before: [], after: [] });
|
|
101
|
+
try {
|
|
102
|
+
body();
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
hookStack.pop();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
/** Run before each test in the current scope, with the test's page. */
|
|
110
|
+
test.beforeEach = (fn) => {
|
|
111
|
+
hookStack[hookStack.length - 1].before.push(fn);
|
|
112
|
+
};
|
|
113
|
+
/** Run after each test in the current scope, pass or fail. */
|
|
114
|
+
test.afterEach = (fn) => {
|
|
115
|
+
hookStack[hookStack.length - 1].after.push(fn);
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,QAAQ,IAAI,YAAY,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,OAAO,EAAsB,MAAM,cAAc,CAAC;AAwB3D,IAAI,MAAM,GAA4B,IAAI,CAAC;AAC3C,IAAI,OAAO,GAAkB,EAAE,CAAC;AAChC,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAE/B,+DAA+D;AAC/D,MAAM,SAAS,GAA4C,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AAEvF,gFAAgF;AAChF,MAAM,UAAU,SAAS,CAAC,IAAmB;IAC3C,OAAO,GAAG,IAAI,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,cAAc;IACrB,IAAI,kBAAkB;QAAE,OAAO;IAC/B,kBAAkB,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,KAAK,IAAI,EAAE;QACf,IAAI,MAAM;YAAE,MAAM,CAAC,MAAM,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,aAAa;IACpB,MAAM,KAAK,OAAO,CAAC,MAAM,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QAAQ,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,4EAA4E;AAC5E,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAY,EAAE,IAAgB,EAAQ,EAAE;IACvD,cAAc,EAAE,CAAC;IACjB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE;QACtB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC;YACH,IAAI,EAAE,CAAC;QACT,CAAC;gBAAS,CAAC;YACT,SAAS,CAAC,GAAG,EAAE,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,uEAAuE;AACvE,IAAI,CAAC,UAAU,GAAG,CAAC,EAAU,EAAQ,EAAE;IACrC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,8DAA8D;AAC9D,IAAI,CAAC,SAAS,GAAG,CAAC,EAAU,EAAQ,EAAE;IACpC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC"}
|
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser for the vibesurfer accessibility tree wire format.
|
|
3
|
+
*
|
|
4
|
+
* Full tree lines look like
|
|
5
|
+
*
|
|
6
|
+
* <ref> <role> <label> [op[,op]...] [k=v]...
|
|
7
|
+
*
|
|
8
|
+
* indented two spaces per nesting level. The label slot is always
|
|
9
|
+
* present (quoted when empty or containing whitespace); ops and attrs
|
|
10
|
+
* are optional. See `docs/PROTOCOL.md` and `docs/codes.md` in the
|
|
11
|
+
* vibesurfer repo.
|
|
12
|
+
*/
|
|
13
|
+
export interface TreeNode {
|
|
14
|
+
ref: number;
|
|
15
|
+
role: string;
|
|
16
|
+
label: string;
|
|
17
|
+
ops: string[];
|
|
18
|
+
attrs: Record<string, string>;
|
|
19
|
+
parent: number | null;
|
|
20
|
+
children: number[];
|
|
21
|
+
depth: number;
|
|
22
|
+
}
|
|
23
|
+
export interface Snapshot {
|
|
24
|
+
nodes: Map<number, TreeNode>;
|
|
25
|
+
roots: number[];
|
|
26
|
+
}
|
|
27
|
+
/** Split a tree line into tokens, keeping `"..."` spans together. */
|
|
28
|
+
export declare function tokenizeTreeLine(s: string): string[];
|
|
29
|
+
export declare function stripQuotes(t: string): string;
|
|
30
|
+
/** Parse one full-tree line (already trimmed of indentation). */
|
|
31
|
+
export declare function parseTreeLine(line: string, depth: number): TreeNode | null;
|
|
32
|
+
/** Parse the body of a full `vs_view` into a snapshot. */
|
|
33
|
+
export declare function parseFullTree(lines: string[]): Snapshot;
|
|
34
|
+
/** True if a view body is a delta (ops start with a sigil; full trees start with a ref). */
|
|
35
|
+
export declare function isDeltaBody(firstLine: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Apply a delta view body to a snapshot in place. Five ops per the
|
|
38
|
+
* protocol: `+<ref>@<parent>[:<pos>] ...` add, `-<ref>` remove,
|
|
39
|
+
* `~<ref> k=v ...` attribute-map replace, `><ref>@<parent>[:<pos>]`
|
|
40
|
+
* move, `*<ref>` plus indented subtree replace.
|
|
41
|
+
*/
|
|
42
|
+
export declare function applyDelta(snap: Snapshot, lines: string[]): void;
|
|
43
|
+
/** Depth-first iteration over a snapshot's nodes. */
|
|
44
|
+
export declare function walk(snap: Snapshot): Generator<TreeNode>;
|
|
45
|
+
/** True if the node or any ancestor carries hid=1. */
|
|
46
|
+
export declare function isHidden(snap: Snapshot, node: TreeNode): boolean;
|
package/dist/tree.js
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser for the vibesurfer accessibility tree wire format.
|
|
3
|
+
*
|
|
4
|
+
* Full tree lines look like
|
|
5
|
+
*
|
|
6
|
+
* <ref> <role> <label> [op[,op]...] [k=v]...
|
|
7
|
+
*
|
|
8
|
+
* indented two spaces per nesting level. The label slot is always
|
|
9
|
+
* present (quoted when empty or containing whitespace); ops and attrs
|
|
10
|
+
* are optional. See `docs/PROTOCOL.md` and `docs/codes.md` in the
|
|
11
|
+
* vibesurfer repo.
|
|
12
|
+
*/
|
|
13
|
+
const OPS = new Set(['click', 'fill', 'scroll', 'key', 'submit', 'hover', 'focus']);
|
|
14
|
+
/** Split a tree line into tokens, keeping `"..."` spans together. */
|
|
15
|
+
export function tokenizeTreeLine(s) {
|
|
16
|
+
const tokens = [];
|
|
17
|
+
let i = 0;
|
|
18
|
+
while (i < s.length) {
|
|
19
|
+
while (i < s.length && (s[i] === ' ' || s[i] === '\t'))
|
|
20
|
+
i++;
|
|
21
|
+
if (i >= s.length)
|
|
22
|
+
break;
|
|
23
|
+
const start = i;
|
|
24
|
+
let inQuotes = false;
|
|
25
|
+
while (i < s.length) {
|
|
26
|
+
const c = s[i];
|
|
27
|
+
if (c === '"')
|
|
28
|
+
inQuotes = !inQuotes;
|
|
29
|
+
else if ((c === ' ' || c === '\t') && !inQuotes)
|
|
30
|
+
break;
|
|
31
|
+
i++;
|
|
32
|
+
}
|
|
33
|
+
tokens.push(s.slice(start, i));
|
|
34
|
+
}
|
|
35
|
+
return tokens;
|
|
36
|
+
}
|
|
37
|
+
export function stripQuotes(t) {
|
|
38
|
+
return t.length >= 2 && t.startsWith('"') && t.endsWith('"') ? t.slice(1, -1) : t;
|
|
39
|
+
}
|
|
40
|
+
function isOpsToken(t) {
|
|
41
|
+
return t.split(',').every((p) => OPS.has(p));
|
|
42
|
+
}
|
|
43
|
+
/** Parse one full-tree line (already trimmed of indentation). */
|
|
44
|
+
export function parseTreeLine(line, depth) {
|
|
45
|
+
const tokens = tokenizeTreeLine(line);
|
|
46
|
+
const refTok = tokens[0];
|
|
47
|
+
const role = tokens[1];
|
|
48
|
+
if (refTok === undefined || role === undefined)
|
|
49
|
+
return null;
|
|
50
|
+
const ref = Number(refTok);
|
|
51
|
+
if (!Number.isInteger(ref) || ref < 0)
|
|
52
|
+
return null;
|
|
53
|
+
const label = tokens[2] !== undefined ? stripQuotes(tokens[2]) : '';
|
|
54
|
+
let i = 3;
|
|
55
|
+
let ops = [];
|
|
56
|
+
const next = tokens[i];
|
|
57
|
+
if (next !== undefined && !next.includes('=') && isOpsToken(next)) {
|
|
58
|
+
ops = next.split(',');
|
|
59
|
+
i++;
|
|
60
|
+
}
|
|
61
|
+
const attrs = {};
|
|
62
|
+
for (; i < tokens.length; i++) {
|
|
63
|
+
const tok = tokens[i];
|
|
64
|
+
if (tok === undefined)
|
|
65
|
+
continue;
|
|
66
|
+
const eq = tok.indexOf('=');
|
|
67
|
+
if (eq > 0) {
|
|
68
|
+
attrs[tok.slice(0, eq)] = stripQuotes(tok.slice(eq + 1));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { ref, role, label, ops, attrs, parent: null, children: [], depth };
|
|
72
|
+
}
|
|
73
|
+
/** Parse the body of a full `vs_view` into a snapshot. */
|
|
74
|
+
export function parseFullTree(lines) {
|
|
75
|
+
const nodes = new Map();
|
|
76
|
+
const roots = [];
|
|
77
|
+
const stack = [];
|
|
78
|
+
for (const raw of lines) {
|
|
79
|
+
if (raw.trim() === '')
|
|
80
|
+
continue;
|
|
81
|
+
const trimmed = raw.replace(/^[ ]*/, '');
|
|
82
|
+
const indent = raw.length - trimmed.length;
|
|
83
|
+
const depth = Math.floor(indent / 2);
|
|
84
|
+
const node = parseTreeLine(trimmed, depth);
|
|
85
|
+
if (!node)
|
|
86
|
+
continue;
|
|
87
|
+
while (stack.length > 0 && stack[stack.length - 1].depth >= depth)
|
|
88
|
+
stack.pop();
|
|
89
|
+
const parent = stack.length > 0 ? stack[stack.length - 1] : null;
|
|
90
|
+
if (parent) {
|
|
91
|
+
node.parent = parent.ref;
|
|
92
|
+
parent.children.push(node.ref);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
roots.push(node.ref);
|
|
96
|
+
}
|
|
97
|
+
nodes.set(node.ref, node);
|
|
98
|
+
stack.push(node);
|
|
99
|
+
}
|
|
100
|
+
return { nodes, roots };
|
|
101
|
+
}
|
|
102
|
+
/** True if a view body is a delta (ops start with a sigil; full trees start with a ref). */
|
|
103
|
+
export function isDeltaBody(firstLine) {
|
|
104
|
+
return /^[+\-~>*]/.test(firstLine.trimStart());
|
|
105
|
+
}
|
|
106
|
+
/** Parse `<ref>@<parent>[:<pos>]` from an add/move op head. */
|
|
107
|
+
function parseRefAt(s) {
|
|
108
|
+
const at = s.indexOf('@');
|
|
109
|
+
if (at < 0)
|
|
110
|
+
return null;
|
|
111
|
+
const ref = Number(s.slice(0, at));
|
|
112
|
+
const rest = s.slice(at + 1);
|
|
113
|
+
const colon = rest.indexOf(':');
|
|
114
|
+
const parent = Number(colon < 0 ? rest : rest.slice(0, colon));
|
|
115
|
+
const pos = colon < 0 ? null : Number(rest.slice(colon + 1));
|
|
116
|
+
if (!Number.isInteger(ref) || !Number.isInteger(parent))
|
|
117
|
+
return null;
|
|
118
|
+
return { ref, parent, pos: pos !== null && Number.isInteger(pos) ? pos : null };
|
|
119
|
+
}
|
|
120
|
+
function removeSubtree(snap, ref) {
|
|
121
|
+
const node = snap.nodes.get(ref);
|
|
122
|
+
if (!node)
|
|
123
|
+
return;
|
|
124
|
+
for (const c of [...node.children])
|
|
125
|
+
removeSubtree(snap, c);
|
|
126
|
+
if (node.parent === null) {
|
|
127
|
+
snap.roots = snap.roots.filter((r) => r !== ref);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const parent = snap.nodes.get(node.parent);
|
|
131
|
+
if (parent)
|
|
132
|
+
parent.children = parent.children.filter((r) => r !== ref);
|
|
133
|
+
}
|
|
134
|
+
snap.nodes.delete(ref);
|
|
135
|
+
}
|
|
136
|
+
/** Attach `ref` under `parent` (0 = root level) at `pos` (null = append). */
|
|
137
|
+
function attach(snap, ref, parent, pos) {
|
|
138
|
+
const node = snap.nodes.get(ref);
|
|
139
|
+
if (!node)
|
|
140
|
+
return;
|
|
141
|
+
const siblings = parent === 0 ? snap.roots : snap.nodes.get(parent)?.children;
|
|
142
|
+
if (!siblings)
|
|
143
|
+
return;
|
|
144
|
+
node.parent = parent === 0 ? null : parent;
|
|
145
|
+
if (pos === null || pos >= siblings.length)
|
|
146
|
+
siblings.push(ref);
|
|
147
|
+
else
|
|
148
|
+
siblings.splice(pos, 0, ref);
|
|
149
|
+
}
|
|
150
|
+
function detach(snap, ref) {
|
|
151
|
+
const node = snap.nodes.get(ref);
|
|
152
|
+
if (!node)
|
|
153
|
+
return;
|
|
154
|
+
if (node.parent === null) {
|
|
155
|
+
snap.roots = snap.roots.filter((r) => r !== ref);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
const parent = snap.nodes.get(node.parent);
|
|
159
|
+
if (parent)
|
|
160
|
+
parent.children = parent.children.filter((r) => r !== ref);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Apply a delta view body to a snapshot in place. Five ops per the
|
|
165
|
+
* protocol: `+<ref>@<parent>[:<pos>] ...` add, `-<ref>` remove,
|
|
166
|
+
* `~<ref> k=v ...` attribute-map replace, `><ref>@<parent>[:<pos>]`
|
|
167
|
+
* move, `*<ref>` plus indented subtree replace.
|
|
168
|
+
*/
|
|
169
|
+
export function applyDelta(snap, lines) {
|
|
170
|
+
let i = 0;
|
|
171
|
+
while (i < lines.length) {
|
|
172
|
+
const raw = lines[i] ?? '';
|
|
173
|
+
if (raw.trim() === '') {
|
|
174
|
+
i++;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const line = raw.trimStart();
|
|
178
|
+
const sigil = line[0];
|
|
179
|
+
if (sigil === '+') {
|
|
180
|
+
const sp = line.search(/[ \t]/);
|
|
181
|
+
const head = sp < 0 ? line.slice(1) : line.slice(1, sp);
|
|
182
|
+
const rest = sp < 0 ? '' : line.slice(sp + 1);
|
|
183
|
+
const target = parseRefAt(head);
|
|
184
|
+
if (target) {
|
|
185
|
+
const node = parseTreeLine(`${target.ref} ${rest}`, 0);
|
|
186
|
+
if (node) {
|
|
187
|
+
snap.nodes.set(node.ref, node);
|
|
188
|
+
attach(snap, node.ref, target.parent, target.pos);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
i++;
|
|
192
|
+
}
|
|
193
|
+
else if (sigil === '-') {
|
|
194
|
+
removeSubtree(snap, Number(line.slice(1).trim()));
|
|
195
|
+
i++;
|
|
196
|
+
}
|
|
197
|
+
else if (sigil === '~') {
|
|
198
|
+
const tokens = tokenizeTreeLine(line);
|
|
199
|
+
const ref = Number(tokens[0]?.slice(1));
|
|
200
|
+
const node = snap.nodes.get(ref);
|
|
201
|
+
if (node) {
|
|
202
|
+
const attrs = {};
|
|
203
|
+
for (const tok of tokens.slice(1)) {
|
|
204
|
+
const eq = tok.indexOf('=');
|
|
205
|
+
if (eq > 0)
|
|
206
|
+
attrs[tok.slice(0, eq)] = stripQuotes(tok.slice(eq + 1));
|
|
207
|
+
}
|
|
208
|
+
node.attrs = attrs;
|
|
209
|
+
}
|
|
210
|
+
i++;
|
|
211
|
+
}
|
|
212
|
+
else if (sigil === '>') {
|
|
213
|
+
const target = parseRefAt(line.slice(1));
|
|
214
|
+
if (target && snap.nodes.has(target.ref)) {
|
|
215
|
+
detach(snap, target.ref);
|
|
216
|
+
attach(snap, target.ref, target.parent, target.pos);
|
|
217
|
+
}
|
|
218
|
+
i++;
|
|
219
|
+
}
|
|
220
|
+
else if (sigil === '*') {
|
|
221
|
+
const ref = Number(line.slice(1).trim());
|
|
222
|
+
const subLines = [];
|
|
223
|
+
i++;
|
|
224
|
+
while (i < lines.length && /^[ \t]/.test(lines[i] ?? '')) {
|
|
225
|
+
subLines.push(lines[i] ?? '');
|
|
226
|
+
i++;
|
|
227
|
+
}
|
|
228
|
+
const old = snap.nodes.get(ref);
|
|
229
|
+
if (!old)
|
|
230
|
+
continue;
|
|
231
|
+
const parent = old.parent;
|
|
232
|
+
const siblings = parent === null ? snap.roots : (snap.nodes.get(parent)?.children ?? []);
|
|
233
|
+
const position = siblings.indexOf(ref);
|
|
234
|
+
removeSubtree(snap, ref);
|
|
235
|
+
const indent = (subLines[0] ?? '').length - (subLines[0] ?? '').trimStart().length;
|
|
236
|
+
const sub = parseFullTree(subLines.map((l) => l.slice(indent)));
|
|
237
|
+
for (const node of sub.nodes.values())
|
|
238
|
+
snap.nodes.set(node.ref, node);
|
|
239
|
+
for (const root of sub.roots) {
|
|
240
|
+
attach(snap, root, parent ?? 0, position < 0 ? null : position);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
// Unknown line in a delta body; skip rather than corrupt state.
|
|
245
|
+
i++;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** Depth-first iteration over a snapshot's nodes. */
|
|
250
|
+
export function* walk(snap) {
|
|
251
|
+
const visit = function* (ref) {
|
|
252
|
+
const node = snap.nodes.get(ref);
|
|
253
|
+
if (!node)
|
|
254
|
+
return;
|
|
255
|
+
yield node;
|
|
256
|
+
for (const c of node.children)
|
|
257
|
+
yield* visit(c);
|
|
258
|
+
};
|
|
259
|
+
for (const r of snap.roots)
|
|
260
|
+
yield* visit(r);
|
|
261
|
+
}
|
|
262
|
+
/** True if the node or any ancestor carries hid=1. */
|
|
263
|
+
export function isHidden(snap, node) {
|
|
264
|
+
let cur = node;
|
|
265
|
+
while (cur) {
|
|
266
|
+
if (cur.attrs['hid'] === '1')
|
|
267
|
+
return true;
|
|
268
|
+
cur = cur.parent === null ? undefined : snap.nodes.get(cur.parent);
|
|
269
|
+
}
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
//# sourceM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CAAC;YACN,gEAAgE;YAChE,CAAC,EAAE,CAAC;QACN,CAAC;IACH,CAAC;AACH,CAAC;AAED,qDAAqD;AACrD,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,IAAc;IAClC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,GAAW;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,MAAM,IAAI,CAAC;QACX,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ;YAAE,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK;QAAE,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,QAAQ,CAAC,IAAc,EAAE,IAAc;IACrD,IAAI,GAAG,GAAyB,IAAI,CAAC;IACrC,OAAO,GAAG,EAAE,CAAC;QACX,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QAC1C,GAAG,GAAG,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/wire.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire-format encoding and decoding for the vibesurfer line protocol.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `crates/vs-protocol/src/request.rs` in the vibesurfer repo:
|
|
5
|
+
* a request is one line `<primitive> [arg]... [--flag[=val]]...`, args
|
|
6
|
+
* are backslash-escaped then quoted when they contain whitespace, and
|
|
7
|
+
* flags are emitted in sorted order (matching the reference encoder's
|
|
8
|
+
* BTreeMap iteration).
|
|
9
|
+
*/
|
|
10
|
+
export interface Warning {
|
|
11
|
+
code: string;
|
|
12
|
+
args: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface WireResponse {
|
|
15
|
+
warnings: Warning[];
|
|
16
|
+
/** The new state token from the `@<token>` success envelope. */
|
|
17
|
+
token: string;
|
|
18
|
+
body: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Extra blank-line-terminated body sections for composite requests
|
|
21
|
+
* (e.g. `vs_view --layout=...`). Present only when the caller asked
|
|
22
|
+
* for them; empty otherwise.
|
|
23
|
+
*/
|
|
24
|
+
sections: string[][];
|
|
25
|
+
}
|
|
26
|
+
/** Flag map: `true` is a bare flag, a string is `--name=value`. */
|
|
27
|
+
export type Flags = Record<string, string | true | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Backslash-escape the characters the line-framed, quote-aware wire
|
|
30
|
+
* would break on: `\` `"` LF CR TAB. Everything else passes through.
|
|
31
|
+
*/
|
|
32
|
+
export declare function escapeWire(s: string): string;
|
|
33
|
+
/** Wrap an already-escaped value in quotes if empty or containing whitespace. */
|
|
34
|
+
export declare function quoteArg(escaped: string): string;
|
|
35
|
+
/** Encode one request line, including the trailing newline. */
|
|
36
|
+
export declare function encodeRequest(primitive: string, args?: string[], flags?: Flags): string;
|
|
37
|
+
/** Parse a `? code args...` warning line (leading `?` included). */
|
|
38
|
+
export declare function parseWarning(line: string): Warning;
|
|
39
|
+
export interface ParsedEnvelope {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
/** Token for `@` envelopes. */
|
|
42
|
+
token?: string;
|
|
43
|
+
/** Code and args for `!` envelopes. */
|
|
44
|
+
code?: string;
|
|
45
|
+
args?: string[];
|
|
46
|
+
}
|
|
47
|
+
/** Parse an `@<token>` or `! CODE args...` envelope line. */
|
|
48
|
+
export declare function parseEnvelope(line: string): ParsedEnvelope;
|
package/dist/wire.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire-format encoding and decoding for the vibesurfer line protocol.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `crates/vs-protocol/src/request.rs` in the vibesurfer repo:
|
|
5
|
+
* a request is one line `<primitive> [arg]... [--flag[=val]]...`, args
|
|
6
|
+
* are backslash-escaped then quoted when they contain whitespace, and
|
|
7
|
+
* flags are emitted in sorted order (matching the reference encoder's
|
|
8
|
+
* BTreeMap iteration).
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Backslash-escape the characters the line-framed, quote-aware wire
|
|
12
|
+
* would break on: `\` `"` LF CR TAB. Everything else passes through.
|
|
13
|
+
*/
|
|
14
|
+
export function escapeWire(s) {
|
|
15
|
+
if (!/[\\"\n\r\t]/.test(s))
|
|
16
|
+
return s;
|
|
17
|
+
let out = '';
|
|
18
|
+
for (const c of s) {
|
|
19
|
+
switch (c) {
|
|
20
|
+
case '\\':
|
|
21
|
+
out += '\\\\';
|
|
22
|
+
break;
|
|
23
|
+
case '"':
|
|
24
|
+
out += '\\"';
|
|
25
|
+
break;
|
|
26
|
+
case '\n':
|
|
27
|
+
out += '\\n';
|
|
28
|
+
break;
|
|
29
|
+
case '\r':
|
|
30
|
+
out += '\\r';
|
|
31
|
+
break;
|
|
32
|
+
case '\t':
|
|
33
|
+
out += '\\t';
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
out += c;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
/** Wrap an already-escaped value in quotes if empty or containing whitespace. */
|
|
42
|
+
export function quoteArg(escaped) {
|
|
43
|
+
return escaped === '' || /[ \t]/.test(escaped) ? `"${escaped}"` : escaped;
|
|
44
|
+
}
|
|
45
|
+
/** Encode one request line, including the trailing newline. */
|
|
46
|
+
export function encodeRequest(primitive, args = [], flags = {}) {
|
|
47
|
+
let out = primitive;
|
|
48
|
+
for (const a of args) {
|
|
49
|
+
out += ' ' + quoteArg(escapeWire(a));
|
|
50
|
+
}
|
|
51
|
+
for (const k of Object.keys(flags).sort()) {
|
|
52
|
+
const v = flags[k];
|
|
53
|
+
if (v === undefined)
|
|
54
|
+
continue;
|
|
55
|
+
out += ' --' + k;
|
|
56
|
+
if (v !== true) {
|
|
57
|
+
out += '=' + quoteArg(escapeWire(v));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return out + '\n';
|
|
61
|
+
}
|
|
62
|
+
/** Parse a `? code args...` warning line (leading `?` included). */
|
|
63
|
+
export function parseWarning(line) {
|
|
64
|
+
const parts = line.replace(/^\?\s*/, '').split(/\s+/).filter(Boolean);
|
|
65
|
+
return { code: parts[0] ?? '', args: parts.slice(1) };
|
|
66
|
+
}
|
|
67
|
+
/** Parse an `@<token>` or `! CODE args...` envelope line. */
|
|
68
|
+
export function parseEnvelope(line) {
|
|
69
|
+
if (line.startsWith('@')) {
|
|
70
|
+
return { ok: true, token: line.slice(1).trim() };
|
|
71
|
+
}
|
|
72
|
+
if (line.startsWith('!')) {
|
|
73
|
+
const parts = line.slice(1).trim().split(/\s+/).filter(Boolean);
|
|
74
|
+
return { ok: false, code: parts[0] ?? 'UNKNOWN', args: parts.slice(1) };
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`expected ?/@/! envelope, got: ${line}`);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=wire.js.map
|
package/dist/wire.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuBH;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACrC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,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|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "End-to-end testing for the web, driven by vibesurfer. Playwright-style locators and auto-retrying assertions over a real WebKit engine with trusted native input.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.build.json",
|
|
22
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
23
|
+
"test": "npm run test:unit && npm run test:e2e",
|
|
24
|
+
"test:unit": "node --test test/wire.test.ts test/tree.test.ts test/locator.test.ts test/aria.test.ts",
|
|
25
|
+
"test:e2e": "node --test test/e2e.test.ts test/features.test.ts",
|
|
26
|
+
"prepublishOnly": "npm run typecheck && npm run build && npm run test:unit"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22.18"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"e2e",
|
|
33
|
+
"testing",
|
|
34
|
+
"browser",
|
|
35
|
+
"webkit",
|
|
36
|
+
"vibesurfer",
|
|
37
|
+
"accessibility"
|
|
38
|
+
],
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^24.0.0",
|
|
41
|
+
"typescript": "^5.7.0"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/frane/testsurfer.git"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/frane/testsurfer#readme",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/frane/testsurfer/issues"
|
|
50
|
+
}
|
|
51
|
+
}
|