test(spec): tolerate legacy bridge fields on builtin nodes

This commit is contained in:
pj committed 2026-06-01 16:31:37 +05:30
1 parent 58585b88b2
commit 26e27832a2
2 files changed
+20 -12

No files matched your search

+16 -9
View File
@@ -31,6 +31,7 @@ import {
} from "../src/index.ts"; } from "../src/index.ts";
import { setSamplerRng } from "../src/actions.ts"; import { setSamplerRng } from "../src/actions.ts";
import { Pcg } from "../src/pcg.ts"; import { Pcg } from "../src/pcg.ts";
import type { GeneratorNode } from "../src/action-tree.ts";
import type { import type {
AccessibilityElement, AccessibilityElement,
EventuallyFormula, EventuallyFormula,
@@ -272,15 +273,21 @@ test("weighted returns a weighted node carrying the branches", () => {
]); ]);
}); });
test("builtin factories return builtin nodes", () => { test("builtin factories return builtin nodes carrying their verb", () => {
assert.deepEqual(taps, { kind: "builtin", verb: "taps" }); const cases: Array<[GeneratorNode, string]> = [
assert.deepEqual(doubleTaps, { kind: "builtin", verb: "doubleTaps" }); [taps, "taps"],
assert.deepEqual(longPresses, { kind: "builtin", verb: "longPresses" }); [doubleTaps, "doubleTaps"],
assert.deepEqual(scrolls, { kind: "builtin", verb: "scrolls" }); [longPresses, "longPresses"],
assert.deepEqual(typing, { kind: "builtin", verb: "typing" }); [scrolls, "scrolls"],
assert.deepEqual(swipes, { kind: "builtin", verb: "swipes" }); [typing, "typing"],
assert.deepEqual(waitOnce, { kind: "builtin", verb: "waitOnce" }); [swipes, "swipes"],
assert.deepEqual(pressKey, { kind: "builtin", verb: "pressKeys" }); [waitOnce, "waitOnce"],
[pressKey, "pressKeys"],
];
for (const [node, verb] of cases) {
assert.equal(node.kind, "builtin");
assert.equal((node as { verb: string }).verb, verb);
}
}); });
test("from with a single item returns it without drawing", () => { test("from with a single item returns it without drawing", () => {
+4 -3
View File
@@ -55,14 +55,15 @@ test("defaults bundle exports defaultActions as a weighted node", async () => {
test("typing resolves as a builtin node", async () => { test("typing resolves as a builtin node", async () => {
installRuntime(emptyState); installRuntime(emptyState);
const { typing } = await import("../src/defaults/actions.ts"); const { typing } = await import("../src/defaults/actions.ts");
assert.deepEqual(typing, { kind: "builtin", verb: "typing" }); assert.equal(typing.kind, "builtin");
assert.equal((typing as { verb: string }).verb, "typing");
}); });
test("longPresses and scrolls resolve as builtin nodes", async () => { test("longPresses and scrolls resolve as builtin nodes", async () => {
installRuntime(emptyState); installRuntime(emptyState);
const { longPresses, scrolls } = await import("../src/defaults/actions.ts"); const { longPresses, scrolls } = await import("../src/defaults/actions.ts");
assert.deepEqual(longPresses, { kind: "builtin", verb: "longPresses" }); assert.equal((longPresses as { verb: string }).verb, "longPresses");
assert.deepEqual(scrolls, { kind: "builtin", verb: "scrolls" }); assert.equal((scrolls as { verb: string }).verb, "scrolls");
}); });
test("defaults barrel re-exports both properties and actions", async () => { test("defaults barrel re-exports both properties and actions", async () => {