test(computer-use): element click carries the token from the live schema alone

Invariant through the real click() path on the modern tools/list shape
(no capabilities[] array, element_token only in inputSchema); red on main.
This commit is contained in:
teknium1
2026-09-14 17:00:17 -07:00
committed by Teknium
parent 65625dfe87
commit 45da78d645
+11
View File
@@ -2228,6 +2228,17 @@ class TestElementTokenAttachment:
# The matching token rode along — cua-driver will prefer it.
assert args["element_token"] == "s0001:5"
def test_token_attached_when_only_input_schema_advertises_it(self):
"""cua-driver >= 0.21 dropped the per-tool `capabilities[]` array from tools/list but advertises
`element_token` in `click`'s inputSchema and REFUSES a bare element_index (`snapshot_id_required`).
The token must ride along from the live schema alone, or every element click is refused."""
backend = self._backend_with_session({}) # no capabilities[] at all — the modern shape
backend._session.supports_input_property = lambda tool, prop: (tool, prop) == ("click", "element_token")
backend._snapshot_tokens = {5: "s00000001:5"}
backend.click(element=5, button="left")
_, args = backend._session.call_tool.call_args.args
assert args["element_token"] == "s00000001:5"
def test_capture_refreshes_snapshot_tokens(self):
"""A fresh capture should overwrite any stale tokens from a