"""Tests for the plugin detail endpoint (BUG-024 fix). Proves GET /api/v1/plugins/{name} returns manifest+status detail for known plugins and 404 for unknown ones. """ from __future__ import annotations import pytest from tests.conftest import ORIGIN_HEADER, login_client, seed_tenant_and_users @pytest.mark.asyncio async def test_plugin_detail_returns_manifest_and_status( client, db_session ): """GET /api/v1/plugins/calendar -> 200 with manifest metadata + status.""" await seed_tenant_and_users(db_session) await login_client(client, "admin@tenanta.com") resp = await client.get("/api/v1/plugins/calendar", headers=ORIGIN_HEADER) assert resp.status_code == 200, resp.text data = resp.json() assert data["name"] == "calendar" assert "status" in data and "installed" in data["status"] @pytest.mark.asyncio async def test_plugin_detail_unknown_plugin_returns_404(client, db_session): """GET /api/v1/plugins/__unknown__ -> 404 not_found.""" await seed_tenant_and_users(db_session) await login_client(client, "admin@tenanta.com") resp = await client.get("/api/v1/plugins/__unknown_plugin_xyz__", headers=ORIGIN_HEADER) assert resp.status_code == 404, resp.text