fix: test fix to change clicks to box drawing

This commit is contained in:
Zoe
2026-09-21 00:04:35 -05:00
parent d4b5ea0254
commit 4b08ce05a4
5 changed files with 37 additions and 8 deletions
+4 -1
View File
@@ -22,6 +22,7 @@ test("adapter accepts tool calls and rejects truncated responses", async (t) =>
test("tool descriptions advertise coordinate conventions", () => {
const normalized = toolsForCoordinates("normalized_1000")[0]?.function.description ?? "";
assert.match(normalized, /Coordinates must be normalized integers in the range \[0, 1000\], where \(0, 0\) is top-left and \(1000, 1000\) is bottom-right\./);
assert.match(normalized, /ymin, xmin, ymax, and xmax/);
const pixels = toolsForCoordinates("pixels")[0]?.function.description ?? "";
assert.match(pixels, /Click coordinates are screenshot pixels, not normalized coordinates\./);
@@ -31,9 +32,11 @@ test("tool descriptions advertise coordinate conventions", () => {
test("tool inputs reject invalid commands, bounds, and action names", () => {
assert.throws(() => shellArguments.parse({ command: "", timeoutSeconds: 1 }));
assert.throws(() => shellArguments.parse({ command: "true", timeoutSeconds: 999 }));
assert.throws(() => desktopArguments.parse({ actions: [{ type: "click", x: -1, y: 0 }] }));
assert.throws(() => desktopArguments.parse({ actions: [{ type: "click", ymin: -1, xmin: 0, ymax: 0, xmax: 0 }] }));
assert.throws(() => desktopArguments.parse({ actions: [{ type: "click", x: 10, y: 20 }] }));
assert.throws(() => desktopArguments.parse({ actions: [{ type: "execute" }] }));
assert.deepEqual(desktopArguments.parse({ actions: [] }), { actions: [] });
assert.throws(() => desktopArguments.parse({ actions: [{ type: "click_target", target: "1" }] }));
assert.equal(desktopArguments.parse({ actions: [{ type: "click_target", target: "1", observationId: "frame" }] }).actions[0]?.type, "click_target");
assert.equal(desktopArguments.parse({ actions: [{ type: "click", ymin: 10, xmin: 20, ymax: 30, xmax: 40 }] }).actions[0]?.type, "click");
});
+9 -1
View File
@@ -17,7 +17,7 @@ spec.loader.exec_module(desktop)
class ValidationTests(unittest.TestCase):
def test_settling_delay_precedes_final_capture_only_after_actions(self):
for actions in ([], [{"type": "click", "x": 500, "y": 500}]):
for actions in ([], [{"type": "click", "ymin": 400, "xmin": 400, "ymax": 600, "xmax": 600}]):
events = []
image = Mock(size=(1280, 800), width=1280, height=800)
def grab(**kwargs):
@@ -66,11 +66,17 @@ class ValidationTests(unittest.TestCase):
def test_normalized_coordinates(self):
for value, expected in [(0, (0, 0)), (500, (640, 400)), (1000, (1279, 799))]:
self.assertEqual(desktop.click_pixels({"x": value, "y": value}, 1280, 800, "normalized_1000"), expected)
self.assertEqual(desktop.click_pixels({"ymin": value, "xmin": value, "ymax": value, "xmax": value}, 1280, 800, "normalized_1000"), expected)
self.assertEqual(desktop.click_pixels({"ymin": 300, "xmin": 400, "ymax": 500, "xmax": 600}, 1280, 800, "normalized_1000"), (640, 320))
self.assertEqual(desktop.click_pixels({"x": 1000, "y": 1000}, 1, 1, "normalized_1000"), (0, 0))
self.assertEqual(desktop.click_pixels({"ymin": 0, "xmin": 0, "ymax": 1000, "xmax": 1000}, 1, 1, "normalized_1000"), (0, 0))
self.assertEqual(desktop.click_pixels({"x": 480, "y": 425}, 1280, 800, "pixels"), (480, 425))
self.assertEqual(desktop.click_pixels({"ymin": 400, "xmin": 460, "ymax": 450, "xmax": 500}, 1280, 800, "pixels"), (480, 425))
for value in (-1, 1001, 0.5, True):
with self.assertRaises(ValueError):
desktop.click_pixels({"x": value, "y": 0}, 1280, 800, "normalized_1000")
with self.assertRaises(ValueError):
desktop.click_pixels({"ymin": value, "xmin": 0, "ymax": 0, "xmax": 0}, 1280, 800, "normalized_1000")
def test_invalid_coordinate_space(self):
with self.assertRaises(ValueError):
@@ -83,6 +89,8 @@ class ValidationTests(unittest.TestCase):
for x in (-1, 100, True, "2"):
with self.assertRaises(ValueError):
desktop.validate({"actions": [{"type": "click", "x": x, "y": 0}]}, 100, 100)
with self.assertRaises(ValueError):
desktop.validate({"actions": [{"type": "click", "ymin": 0, "xmin": x, "ymax": 0, "xmax": 0}]}, 100, 100)
def test_invalid_keys(self):
with self.assertRaises(ValueError):