Admin Dashboard — Testing Strategy
Status: populated Owner: Platform Engineering (Frontend) Last updated: 2026-04-18
1. Test Pyramid
┌─────────────┐
│ E2E (10%) │ Playwright — critical admin flows
├─────────────┤
│ Integration │ Route handler tests (MSW-backed)
│ (20%) │
├─────────────┤
│ Unit (70%) │ Vitest — components, hooks, utils
└─────────────┘
Target coverage: 80% unit + integration combined.
2. Unit Tests (Vitest + React Testing Library)
Component Tests
| Component | Test focus |
|---|---|
MetricsSummaryCards | Renders all KPIs; handles loading/error states |
ThroughputChart | Renders with 24 data points; handles empty data |
DeliveryBreakdownPie | All 4 segments render; legend visible |
TopOperatorsTable | Renders 5 rows; handles < 5 operators |
OperatorCreateModal | Form validation; password masking; submit flow |
RoutingRuleList | DnD reorder emits correct event; rule condition pills render |
ServiceHealthGrid | All health states render correct badge colors |
AlertBannerList | Dismiss removes banner; sessionStorage updated |
AdminMessageLogTable | Cross-tenant filters; tenant dropdown populated |
Hook Tests
| Hook | Test focus |
|---|---|
useDashboardPoller(interval) | Polls on interval; pauses on tab hidden; cleans up on unmount |
useOperatorHealth(operatorId) | Fetches health; handles 404 gracefully |
useRoutingRuleOrder() | Local state sync with remote; conflict detection |
Utility Tests
| Utility | Test focus |
|---|---|
formatThroughputPoint(point) | All fields formatted correctly |
aggregateDeliveryStats(messages) | Correct counts per status |
validateOperatorConfig(config) | Valid/invalid SMPP host:port combinations |
3. Integration Tests (Route Handlers)
| Route Handler | Test cases |
|---|---|
GET /api/metrics | Aggregates four analytics endpoints; partial failure returns partial data |
POST /api/operators | Success → 201; upstream 422 → error message propagated |
DELETE /api/operators/[id] | Success → 204; 422 with active routing rules → error message |
POST /api/routing-rules/reorder | Reorder payload validated; upstream 409 propagated |
4. E2E Tests (Playwright)
| Journey | Steps | Assertion |
|---|---|---|
| Admin login | Navigate to /, sign in with admin credentials | /dashboard loads with metrics cards |
| Dashboard polling | Wait 30s on /dashboard | Charts update with new data |
| Create operator | /operators → Add Operator → fill form → submit | New operator appears in list |
| Edit operator | Click Edit on operator → change TPS → save | Updated TPS shown in list |
| Delete operator (blocked) | Click Delete on operator used by routing rule | Error message with routing rule reference |
| Routing rule reorder | Drag rule 2 above rule 1 → save | New order persisted after page refresh |
| Cross-tenant message search | /messages → set tenant filter → apply | Only messages from that tenant shown |
| Suspend user | /users → Suspend on a user | User status shows suspended |
| System health page | Navigate to /health | All services show health status badges |
Playwright config:
- Browser matrix: Chromium only (internal tool; full cross-browser not required)
- Breakpoints: 1440px desktop
- Test admin account seeded via
globalSetup
5. Accessibility
axe-corevia Playwright on each E2E test.- Admin tool targets WCAG 2.1 AA.
- Chart components include
aria-labeldescriptions for screen readers.
6. CI Pipeline
pnpm test # Vitest unit
pnpm test:coverage # Coverage gate (< 80% fails)
pnpm e2e # Playwright against MSW mock backend
pnpm lint
pnpm typecheck