aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/domains/form-batch.ts7
-rw-r--r--test/manual/forms-test.ts8
2 files changed, 5 insertions, 10 deletions
diff --git a/src/domains/form-batch.ts b/src/domains/form-batch.ts
index b926025..c4b4df6 100644
--- a/src/domains/form-batch.ts
+++ b/src/domains/form-batch.ts
@@ -1,5 +1,5 @@
import { Type } from "typebox";
-import { type Result, ok } from "../util/result";
+import { type Result, err, ok } from "../util/result";
import { defineBrowserTool, type ToolErr, type ToolOk } from "../util/tool";
import { detailsOf, resolveAndCall } from "./form";
@@ -99,7 +99,7 @@ export const fillFormTool = defineBrowserTool({
const res = r.data;
const wanted = typeof f.value === "boolean" ? undefined : String(f.value);
const got = res.value !== undefined ? String(res.value) : undefined;
- const mismatch = wanted !== undefined && got !== undefined && got !== wanted;
+ const mismatch = wanted !== undefined && got !== undefined && got !== wanted && res.text !== wanted;
const fieldOk = res.ok === true && !mismatch;
if (fieldOk) okCount++;
else issues.push(`ref ${f.ref} (${res.ok === false ? (res.reason ?? "failed") : "value mismatch"})`);
@@ -108,6 +108,9 @@ export const fillFormTool = defineBrowserTool({
const text =
`Filled ${okCount}/${args.fields.length} fields` +
(issues.length > 0 ? `; issues: ${issues.join(", ")}` : "");
+ if (okCount === 0) {
+ return err({ kind: "invalid_state", message: text, details: { results } });
+ }
return ok({ text, details: { results } });
},
});
diff --git a/test/manual/forms-test.ts b/test/manual/forms-test.ts
index 51c1600..ca6c596 100644
--- a/test/manual/forms-test.ts
+++ b/test/manual/forms-test.ts
@@ -15,12 +15,6 @@ import { createBrowserClient } from "../../src/client";
import { fillTool, selectOptionTool, setCheckedTool } from "../../src/domains/form";
import { fillFormTool } from "../../src/domains/form-batch";
-// NOTE: we intentionally do NOT import snapshotTool here — it pulls in pi-tui /
-// pi-coding-agent value imports that don't resolve under bare tsx. Instead we
-// publish an 'eN' ref map onto the session from Accessibility.getFullAXTree,
-// which is what browser_snapshot does when it prints [eN]. The snapshot's own
-// ref rendering is covered by `npm run typecheck` + the real-page smoke test.
-
let passed = 0;
let failed = 0;
const check = (cond: boolean, label: string): void => {
@@ -60,8 +54,6 @@ const FIXTURE = `
</script>
</body></html>`;
-// Publish an 'eN' ref map onto the session for the given accessible names and
-// return name → ref, mirroring what browser_snapshot does.
const publishRefs = async (client: any, names: ReadonlyArray<string>): Promise<Record<string, string | undefined>> => {
const ax = await client.session().call("Accessibility.getFullAXTree", {});
if (!ax.success) return {};