feat: implement full admin panel with dashboard, user management, and platform settings
Adds complete super_admin panel with 9 pages and account owner categories page. Backend includes 5 new DB tables, ~25 API endpoints, settings manager with in-memory cache, and 29 integration tests. Frontend includes reusable admin components (DataTable, Pagination, ActionMenu, etc.) with code-split lazy loading. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
58
backend/tests/test_admin_plan_limits.py
Normal file
58
backend/tests/test_admin_plan_limits.py
Normal file
@@ -0,0 +1,58 @@
|
||||
"""Integration tests for admin plan limits and account override endpoints."""
|
||||
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
|
||||
class TestAdminPlanLimits:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_plan_limits(
|
||||
self, client: AsyncClient, admin_auth_headers: dict
|
||||
):
|
||||
"""List all plan limits."""
|
||||
response = await client.get("/api/v1/admin/plan-limits", headers=admin_auth_headers)
|
||||
assert response.status_code == 200
|
||||
plans = response.json()
|
||||
assert len(plans) >= 3 # free, pro, team seeded in conftest
|
||||
plan_names = [p["plan"] for p in plans]
|
||||
assert "free" in plan_names
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_plan_limits(
|
||||
self, client: AsyncClient, admin_auth_headers: dict
|
||||
):
|
||||
"""Update a plan's limits."""
|
||||
response = await client.put(
|
||||
"/api/v1/admin/plan-limits",
|
||||
json={
|
||||
"plan": "free",
|
||||
"max_trees": 5,
|
||||
"max_sessions_per_month": 30,
|
||||
"max_users": 2,
|
||||
"custom_branding": False,
|
||||
"priority_support": False,
|
||||
"export_formats": ["markdown", "text"],
|
||||
},
|
||||
headers=admin_auth_headers,
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["max_trees"] == 5
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_account_overrides(
|
||||
self, client: AsyncClient, admin_auth_headers: dict
|
||||
):
|
||||
"""List account overrides."""
|
||||
response = await client.get("/api/v1/admin/account-overrides", headers=admin_auth_headers)
|
||||
assert response.status_code == 200
|
||||
assert isinstance(response.json(), list)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_non_admin_cannot_access(
|
||||
self, client: AsyncClient, auth_headers: dict
|
||||
):
|
||||
"""Non-admin gets 403."""
|
||||
response = await client.get("/api/v1/admin/plan-limits", headers=auth_headers)
|
||||
assert response.status_code == 403
|
||||
Reference in New Issue
Block a user