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>
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""Integration tests for admin settings endpoints."""
|
|
|
|
import pytest
|
|
from httpx import AsyncClient
|
|
|
|
|
|
class TestAdminSettings:
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_settings(
|
|
self, client: AsyncClient, admin_auth_headers: dict
|
|
):
|
|
"""List platform settings (may be empty if not seeded via migration)."""
|
|
response = await client.get("/api/v1/admin/settings", headers=admin_auth_headers)
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert "settings" in data
|
|
assert isinstance(data["settings"], dict)
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_update_settings(
|
|
self, client: AsyncClient, admin_auth_headers: dict
|
|
):
|
|
"""Update maintenance_mode setting."""
|
|
response = await client.put(
|
|
"/api/v1/admin/settings",
|
|
json={"settings": {"maintenance_mode": "true"}},
|
|
headers=admin_auth_headers,
|
|
)
|
|
assert response.status_code == 200
|
|
|
|
# Verify change
|
|
get_resp = await client.get("/api/v1/admin/settings", headers=admin_auth_headers)
|
|
settings = get_resp.json()["settings"]
|
|
assert settings["maintenance_mode"] is True or settings["maintenance_mode"] == "true"
|
|
|
|
@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/settings", headers=auth_headers)
|
|
assert response.status_code == 403
|