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>
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
"""Integration tests for admin dashboard endpoints."""
|
|
|
|
import pytest
|
|
from httpx import AsyncClient
|
|
|
|
|
|
class TestAdminDashboard:
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_dashboard_metrics(
|
|
self, client: AsyncClient, admin_auth_headers: dict, test_user: dict
|
|
):
|
|
"""Super admin can get dashboard metrics."""
|
|
response = await client.get("/api/v1/admin/dashboard/metrics", headers=admin_auth_headers)
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert "total_users" in data
|
|
assert data["total_users"] >= 2 # admin + test_user
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_dashboard_activity(
|
|
self, client: AsyncClient, admin_auth_headers: dict
|
|
):
|
|
"""Super admin can get recent activity."""
|
|
response = await client.get("/api/v1/admin/dashboard/activity", headers=admin_auth_headers)
|
|
assert response.status_code == 200
|
|
assert isinstance(response.json(), list)
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_non_admin_cannot_access_dashboard(
|
|
self, client: AsyncClient, auth_headers: dict
|
|
):
|
|
"""Non-admin gets 403."""
|
|
response = await client.get("/api/v1/admin/dashboard/metrics", headers=auth_headers)
|
|
assert response.status_code == 403
|