Files
hermes-agent/tests/web_console/test_commands_api.py
Alexander Whitestone 8e0f24db3f
Some checks failed
Forge CI / smoke-and-build (pull_request) Failing after 59s
feat(web-console): cherry-pick React web console GUI from gary-the-ai fork
Cherry-pick the Hermes Web Console from gary-the-ai/hermes-web-console-gui.
React + TypeScript frontend with Vite, Python aiohttp backend API.

Components:
- web_console/ — React frontend (chat, sessions, memory, settings, skills,
  gateway config, cron, workspace, tools, browser, insights pages)
- gateway/web_console/ — Python backend API (23 endpoints, SSE event bus,
  11 service modules)
- gateway/platforms/api_server_ui.py — embedded browser UI for API server
- gateway/platforms/api_server.py — route registration refactored into
  _register_routes(), web console mounted via maybe_register_web_console()
- run-gui.sh / setup-gui.sh — one-command launch and setup scripts
- tests/gateway/test_api_server_gui_mount.py — 4 integration tests (passing)
- tests/web_console/ — 13 backend test files (51 passing)
- docs/plans/ — implementation plan, API schema, frontend architecture

Fix: added missing ModelContextError class and CRON_MIN_CONTEXT_TOKENS to
cron/scheduler.py (pre-existing import bug).

Closes #325
2026-04-13 18:01:51 -04:00

47 lines
1.5 KiB
Python

"""Tests for the web console commands API."""
from __future__ import annotations
import pytest
from aiohttp import web
from aiohttp.test_utils import TestClient, TestServer
from gateway.web_console.routes import register_web_console_routes
class TestCommandsApi:
@staticmethod
async def _make_client() -> TestClient:
app = web.Application()
register_web_console_routes(app)
client = TestClient(TestServer(app))
await client.start_server()
return client
@pytest.mark.asyncio
async def test_commands_registry_route_exposes_cli_registry(self):
client = await self._make_client()
try:
resp = await client.get("/api/gui/commands")
assert resp.status == 200
payload = await resp.json()
assert payload["ok"] is True
assert isinstance(payload["commands"], list)
assert payload["commands"]
by_name = {entry["name"]: entry for entry in payload["commands"]}
assert "new" in by_name
assert "model" in by_name
assert "commands" in by_name
new_entry = by_name["new"]
assert "reset" in new_entry["aliases"]
assert "reset" in new_entry["names"]
assert new_entry["cli_only"] is False
commands_entry = by_name["commands"]
assert commands_entry["gateway_only"] is True
assert commands_entry["args_hint"] == "[page]"
finally:
await client.close()