diff options
Diffstat (limited to 'test/manual/forms-test.ts')
| -rw-r--r-- | test/manual/forms-test.ts | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/test/manual/forms-test.ts b/test/manual/forms-test.ts index ca6c596..43b2863 100644 --- a/test/manual/forms-test.ts +++ b/test/manual/forms-test.ts @@ -1,15 +1,3 @@ -/** - * Manual integration test for the form-filling tools. - * - * Exercises browser_snapshot (ref surfacing) + browser_fill_form / browser_fill / - * browser_select_option / browser_set_checked against a data:-URL fixture that - * includes a plain input, a textarea, a "controlled" input (commits its model - * only on the `input` event — the realistic failure mode for naive value-setting), - * a native <select>, a checkbox, and a contenteditable. - * - * Requires the daemon running + a real Chrome (same as live-daemon-test.ts). - * Run: npx tsx test/manual/forms-test.ts - */ import { createDaemonTransport } from "../../src/cdp/daemon-transport"; import { createBrowserClient } from "../../src/client"; import { fillTool, selectOptionTool, setCheckedTool } from "../../src/domains/form"; @@ -22,7 +10,6 @@ const check = (cond: boolean, label: string): void => { else { failed++; console.error(` ✗ ${label}`); } }; -// Minimal handler context — the form/snapshot handlers only read `client`. const mkCtx = (client: any): any => ({ client, signal: undefined, @@ -89,7 +76,6 @@ async function main(): Promise<void> { const url = "data:text/html," + encodeURIComponent(FIXTURE); const tab = await client.newTab(url); check(tab.success, `Opened fixture tab: ${tab.success ? "ok" : tab.error.message}`); - // Give the inline script a beat to wire up listeners. await new Promise((r) => setTimeout(r, 300)); const byName = await publishRefs(client, ["plain", "ta", "controlled", "country", "agree", "bio"]); @@ -103,7 +89,6 @@ async function main(): Promise<void> { }; for (const [k, v] of Object.entries(refs)) check(typeof v === "string", `ref present for ${k} (${v})`); - // ── Batch fill text fields ────────────────────────────────────────────────── const fill = await fillFormTool.handler({ fields: [ { ref: refs.plain!, value: "hello plain" }, @@ -115,31 +100,25 @@ async function main(): Promise<void> { check(fill.success, "browser_fill_form succeeded"); if (fill.success) console.log(" " + fill.data.text); - // ── Select + checkbox ─────────────────────────────────────────────────────── const sel = await selectOptionTool.handler({ ref: refs.sel!, label: "Canada" }, ctx); check(sel.success, `browser_select_option by label: ${sel.success ? sel.data.text : (sel as any).error.message}`); const chk = await setCheckedTool.handler({ ref: refs.chk!, checked: true }, ctx); check(chk.success, `browser_set_checked: ${chk.success ? chk.data.text : (chk as any).error.message}`); - // ── Verify committed state via JS reads ───────────────────────────────────── const read = async (expr: string): Promise<unknown> => { const r = await client.evaluateJs(expr); return r.success ? r.data : `ERR:${r.error.message}`; }; check((await read("document.getElementById('plain').value")) === "hello plain", "plain input value committed"); check((await read("document.getElementById('ta').value")) === "multi\nline", "textarea value committed"); - // The controlled input's MODEL (input-event-driven) must reflect the fill — - // proves browser_fill fired the input event, not just set the DOM value. check((await read("window.__model()")) === "ctrl-value", "controlled input model committed (input event fired)"); check((await read("document.getElementById('editable').textContent")) === "my bio", "contenteditable text committed"); check((await read("document.getElementById('sel').value")) === "ca", "select value committed"); check((await read("document.getElementById('chk').checked")) === true, "checkbox checked committed"); - // ── No-matching-option path ───────────────────────────────────────────────── const badSel = await selectOptionTool.handler({ ref: refs.sel!, label: "Atlantis" }, ctx); check(!badSel.success && (badSel as any).error.kind === "invalid_state", "select with no match → invalid_state error"); - // ── Stale ref path ────────────────────────────────────────────────────────── const staleRef = refs.plain!; const nav = await client.session().call("Page.navigate", { url: "data:text/html," + encodeURIComponent("<body>gone</body>") }); check(nav.success, "navigated away to invalidate refs"); |
