Main gained a single typed GatewayEventMap sourced from the tui_gateway emitters (test_gateway_event_contract), so the six display.* notifications this PR emits must be listed there or the contract test and the desktop typecheck both fail. The native Windows/macOS dispatch test (#109505) ran on a runner with no approver, where the approval gate blocks click/type before dispatch; it now stubs `_request_approval` exactly like the capture-fence tests.
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
"""Exercise existing computer-use actions on the actual Windows/macOS CI hosts."""
|
|
|
|
import json
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
from tools.computer_use import tool
|
|
|
|
|
|
@pytest.fixture
|
|
def backend(monkeypatch):
|
|
tool.reset_backend_for_tests()
|
|
monkeypatch.setenv("HERMES_COMPUTER_USE_BACKEND", "noop")
|
|
# Input actions are approval-gated; a CI runner has no approver, so the gate would block
|
|
# before the dispatch this test is about. Same seam the capture-fence tests use.
|
|
monkeypatch.setattr(tool, "_request_approval", lambda *a, **k: None)
|
|
value = tool._get_backend()
|
|
yield value
|
|
tool.reset_backend_for_tests()
|
|
|
|
|
|
@pytest.mark.parametrize("host_platform", [
|
|
pytest.param("win32", marks=pytest.mark.windows_only),
|
|
pytest.param("darwin", marks=pytest.mark.macos_only),
|
|
])
|
|
@pytest.mark.parametrize("args, expected_call", [
|
|
({"action": "capture", "mode": "ax"}, "capture"),
|
|
({"action": "click", "coordinate": [10, 10]}, "click"),
|
|
({"action": "type", "text": "test input"}, "type"),
|
|
({"action": "list_windows"}, "list_windows"),
|
|
])
|
|
def test_native_computer_use_dispatches_to_backend(backend, args, expected_call, host_platform):
|
|
import tools.computer_use_tool # noqa: F401 - register the real tool handler
|
|
from tools.registry import registry
|
|
|
|
assert sys.platform == host_platform
|
|
result = registry.dispatch("computer_use", args)
|
|
|
|
assert "error" not in json.loads(result)
|
|
assert [name for name, _ in backend.calls] == [expected_call]
|