diff --git a/tests/hermes_cli/test_dashboard_admin_endpoints.py b/tests/hermes_cli/test_dashboard_admin_endpoints.py index 3f04e6533f0a2..2f438983d14a6 100644 --- a/tests/hermes_cli/test_dashboard_admin_endpoints.py +++ b/tests/hermes_cli/test_dashboard_admin_endpoints.py @@ -1009,3 +1009,27 @@ def test_desktop_lifespan_reaps_orphan_gateways_on_startup( assert called == [True] + +def test_desktop_lifespan_terminates_managed_gateway_restart(monkeypatch): + """A Desktop-owned gateway child must not survive its serve backend.""" + import hermes_cli.web_server as ws + + calls = [] + + class _FakeRunningProc: + def poll(self): + return None + + def terminate(self): + calls.append("terminate") + + monkeypatch.setenv("HERMES_DESKTOP", "1") + monkeypatch.setattr(ws, "_warm_gateway_module", lambda: None) + monkeypatch.setattr(ws, "_start_desktop_cron_ticker", lambda *_args: None) + monkeypatch.setitem(ws._ACTION_PROCS, "gateway-restart", _FakeRunningProc()) + + client, _header = _client() + with client: + pass + + assert calls == ["terminate"]