Skip to main content

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

ComponentTest focus
MetricsSummaryCardsRenders all KPIs; handles loading/error states
ThroughputChartRenders with 24 data points; handles empty data
DeliveryBreakdownPieAll 4 segments render; legend visible
TopOperatorsTableRenders 5 rows; handles < 5 operators
OperatorCreateModalForm validation; password masking; submit flow
RoutingRuleListDnD reorder emits correct event; rule condition pills render
ServiceHealthGridAll health states render correct badge colors
AlertBannerListDismiss removes banner; sessionStorage updated
AdminMessageLogTableCross-tenant filters; tenant dropdown populated

Hook Tests

HookTest 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

UtilityTest 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 HandlerTest cases
GET /api/metricsAggregates four analytics endpoints; partial failure returns partial data
POST /api/operatorsSuccess → 201; upstream 422 → error message propagated
DELETE /api/operators/[id]Success → 204; 422 with active routing rules → error message
POST /api/routing-rules/reorderReorder payload validated; upstream 409 propagated

4. E2E Tests (Playwright)

JourneyStepsAssertion
Admin loginNavigate to /, sign in with admin credentials/dashboard loads with metrics cards
Dashboard pollingWait 30s on /dashboardCharts update with new data
Create operator/operators → Add Operator → fill form → submitNew operator appears in list
Edit operatorClick Edit on operator → change TPS → saveUpdated TPS shown in list
Delete operator (blocked)Click Delete on operator used by routing ruleError message with routing rule reference
Routing rule reorderDrag rule 2 above rule 1 → saveNew order persisted after page refresh
Cross-tenant message search/messages → set tenant filter → applyOnly messages from that tenant shown
Suspend user/users → Suspend on a userUser status shows suspended
System health pageNavigate to /healthAll 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-core via Playwright on each E2E test.
  • Admin tool targets WCAG 2.1 AA.
  • Chart components include aria-label descriptions 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