Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

test(background): drive the tray menu through a fake pystray on headless hosts

rubenluetke10-beep95de195784af
diff --git a/tests/unit/core/test_background_service.py b/tests/unit/core/test_background_service.py
index 341ce31e38..bceb70bec6 100644
--- a/tests/unit/core/test_background_service.py
+++ b/tests/unit/core/test_background_service.py
@@ -506,8 +506,25 @@ def test_drain_is_bounded() -> None:
asyncio.run(scenario())
+class _FakeMenuItem:
+ def __init__(self, text, action, **_kwargs) -> None:
+ self.text = text
+ self._action = action
+
+
+class _FakeMenu:
+ SEPARATOR = object()
+
+ def __init__(self, *items) -> None:
+ self.items = [i for i in items if isinstance(i, _FakeMenuItem)]
+
+
def test_tray_quit_all_skips_the_hand_off(monkeypatch) -> None:
- pytest.importorskip("pystray")
+ # A fake pystray: the real one opens an X display on import, which a
+ # headless Linux runner does not have.
+ monkeypatch.setitem(
+ sys.modules, "pystray", SimpleNamespace(Menu=_FakeMenu, MenuItem=_FakeMenuItem)
+ )
from jarvis.ui.tray import JarvisTray, TrayCommand
seen: list[str] = []