feat(L+M): configurable dashboard widget system + test framework
Phase L: Dashboard widget system - Migration 046: dashboard_configs table (user/tenant/role fallback cascade) - DashboardConfig model + dashboard_service with get/upsert per-user and tenant-default - API router: GET/PUT /api/dashboard/config, GET/PUT /api/dashboard/tenant-default - Frontend: 5 widget components (ProductionStats, QueueStatus, RecentRenders, CostOverview, WorkerStatus) - DashboardGrid with API-backed config, DashboardCustomizeModal (checkbox selection, save/cancel) - Dashboard.tsx: widget grid + analytics section (privileged users) - Admin.tsx: restructured with new section order and Maintenance 2-col grid Phase M: Test framework - Backend: pytest-asyncio + pytest-cov + factory-boy in pyproject.toml - conftest.py: excel_dir fixtures + async DB fixtures + mock storage/celery stubs - Domain tests: billing_service, cache_service, notifications_service, imports_sanity - Integration: test_api_health.py smoke test (requires running backend) - Frontend: vitest + @testing-library/react + msw added to package.json - vite.config.ts: test block (jsdom + globals + setupFiles) - tsconfig.json: exclude src/__tests__ from main tsc (test runner handles its own types) - MSW handlers for /api/auth/me, Billing.test.tsx, formatters.test.ts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""Tests for notification config service."""
|
||||
import pytest
|
||||
from app.domains.notifications.service import (
|
||||
upsert_notification_config,
|
||||
get_notification_configs,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_upsert_creates_config(db, admin_user):
|
||||
"""Kann Notification-Config anlegen."""
|
||||
await upsert_notification_config(db, admin_user.id, "render_complete", "in_app", True)
|
||||
configs = await get_notification_configs(db, admin_user.id)
|
||||
assert len(configs) >= 1
|
||||
render_cfg = next((c for c in configs if c.event_type == "render_complete"), None)
|
||||
assert render_cfg is not None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_upsert_updates_existing(db, admin_user):
|
||||
"""Update überschreibt bestehende Config."""
|
||||
await upsert_notification_config(db, admin_user.id, "order_submitted", "in_app", True)
|
||||
await upsert_notification_config(db, admin_user.id, "order_submitted", "in_app", False)
|
||||
configs = await get_notification_configs(db, admin_user.id)
|
||||
cfg = next((c for c in configs if c.event_type == "order_submitted"), None)
|
||||
assert cfg is not None
|
||||
assert cfg.enabled is False
|
||||
Reference in New Issue
Block a user