Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# local env files
.env
.env.jev

# vercel
.vercel
Expand All @@ -47,6 +48,7 @@ node_modules/
/test-results/
/playwright-report/
/blob-report/
/benchmark-results/
/playwright/.cache/
.playwright-mcp/

Expand Down
5 changes: 5 additions & 0 deletions endform.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineEndformConfig } from "endform";

export default defineEndformConfig({
environmentVariables: ["E2E_JEV_.*"],
});
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
"format:check": "oxfmt --check",
"format:fix": "oxfmt --write",
"lint": "oxlint",
"mcp-user": "tsx mcp-user.ts"
"mcp-user": "tsx mcp-user.ts",
"jev:test": "bun scripts/jev-loop.ts",
"jev:viewer": "bun scripts/jev/viewer.ts",
"jev:benchmark": "bun scripts/jev-benchmark.ts --mode clean --repeat 10",
"jev:benchmark:faults": "bun scripts/jev-benchmark.ts --mode faults"
},
"dependencies": {
"@libsql/client": "^0.18.0",
Expand Down Expand Up @@ -51,6 +55,7 @@
"oxfmt": "0.68.0",
"oxlint": "1.83.0",
"playwright-opentelemetry": "^0.13.0",
"sharp": "0.35.4",
"tsx": "^4.23.15",
"typescript": "^7.0.2"
},
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 92 additions & 0 deletions scripts/jev-benchmark.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { expect, test } from "bun:test";
import { actionCode, candidates, select } from "./jev-benchmark";

test("builds bounded actions from an accessibility observation", () => {
const actions = candidates(
{
url: "https://example.test/dashboard",
title: "Settings",
snapshot:
'- link "General" [ref=e1]\n- textbox "Name" [ref=e2]\n- radio "Member" [ref=e3]\n- button "Save" [disabled] [ref=e4]',
invitationId: "42",
},
["John Doe"],
);
expect(actions.map((action) => action.kind)).toEqual([
"click",
"fill",
"check",
"goto",
"goto",
"wait",
"stop",
]);
});

test("keeps action arguments literal", () => {
const value = "x\n${process.exit()}";
expect(actionCode({ id: "x", kind: "goto", value, description: "go" })).toBe(
`await page.goto(${JSON.stringify(value)});`,
);
expect(() =>
actionCode({
id: "x",
kind: "click",
ref: 'e1"); throw 1',
description: "bad",
}),
).toThrow();
});

test("per-field fills take the value Jev chose for that field", () => {
const actions = candidates(
{
url: "https://example.test/checkout",
title: "Checkout",
snapshot:
'- textbox "Name" [ref=e1]: John Doe\n- textbox "City" [ref=e2]\n- button "Pay" [ref=e3]',
},
["John Doe", "New York"],
{ fieldValues: true },
);
expect(actions.filter((action) => action.kind === "fill")).toHaveLength(2);
const answers = {
next: {
type: "choice",
choice: "a0",
probabilities: { a0: 0.5, a1: 0.3, a2: 0.2 },
},
value_a0: { type: "choice", choice: "v0" },
value_a1: { type: "choice", choice: "v1" },
};
// Name already holds its chosen value, so the next most probable action runs.
const selected = select(actions, answers, ["John Doe", "New York"]);
expect(selected?.ref).toBe("e2");
expect(selected?.value).toBe("New York");
expect(actionCode(selected!)).toContain('"New York"');
expect(
select(
actions,
{ ...answers, next: { ...answers.next, choice: "missing" } },
[],
),
).toBeUndefined();
});

test("without per-field values the chosen action runs unchanged", () => {
const actions = candidates(
{
url: "https://example.test",
title: "",
snapshot: '- button "Go" [ref=e1]',
},
[],
);
expect(
select(
actions,
{ next: { type: "choice", choice: "wait", probabilities: { a0: 0.9 } } },
[],
)?.kind,
).toBe("wait");
});
Loading
Loading