From 09d6b715f0234950fafb7ab9fc388199ef13e5ed Mon Sep 17 00:00:00 2001 From: Ocetars Date: Tue, 2 Dec 2025 20:57:03 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=96=B0=E5=A2=9E=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_dashboard.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index f5439e9d5..969f0da6d 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -160,6 +160,34 @@ async def test_plugins(app: Quart, authenticated_header: dict): assert exists is False, "插件 astrbot_plugin_essential 未成功卸载" +@pytest.mark.asyncio +async def test_commands_api(app: Quart, authenticated_header: dict): + """Tests the command management API endpoints.""" + test_client = app.test_client() + + # GET /api/commands - list commands + response = await test_client.get("/api/commands", headers=authenticated_header) + assert response.status_code == 200 + data = await response.get_json() + assert data["status"] == "ok" + assert "items" in data["data"] + assert "summary" in data["data"] + summary = data["data"]["summary"] + assert "total" in summary + assert "disabled" in summary + assert "conflicts" in summary + + # GET /api/commands/conflicts - list conflicts + response = await test_client.get( + "/api/commands/conflicts", headers=authenticated_header + ) + assert response.status_code == 200 + data = await response.get_json() + assert data["status"] == "ok" + # conflicts is a list + assert isinstance(data["data"], list) + + @pytest.mark.asyncio async def test_check_update(app: Quart, authenticated_header: dict): test_client = app.test_client()