aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-28 00:40:22 +0530
committerAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-08-02 19:12:46 +0530
commit1c73f4af643aa60ca554a3770264791d299e64e2 (patch)
treee1891349240438cb47b7ddde8f18f0762f4dcf79 /src
parente46f080c03a511b626b21455cfd6094554b02733 (diff)
fix(domains): stop fill_form misreporting select-by-label, let it fail
Three review fixes on the restored fill_form: - FILL_FN matches a <select> option by value, label or text but returns el.value, so filling by visible label ("Canada" -> value "ca") tripped the read-back mismatch check and reported a correctly-set field as "Filled 0/1 fields; issues: ref e4 (value mismatch)". The mismatch test now also accepts res.text, which FILL_FN sets only for selects, so mismatch detection is preserved for every other field kind. - fill_form always returned ok(), so total failure surfaced as a successful result reading "Filled 0/4 fields". It now returns invalid_state when okCount is 0, carrying the per-field issue list as the error message. Partial success stays ok(). - Removed the two comment blocks this task had added to test/manual/forms-test.ts. Neither behaviour fix has automated coverage; the manual suite that would exercise them still needs a live Chrome and was not run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src')
-rw-r--r--src/domains/form-batch.ts7
1 files changed, 5 insertions, 2 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 } });
},
});