Platform Admin Service — Testing Strategy
Status: populated
Owner: TBD
Last updated: 2026-04-18
Companion: TESTING_STANDARDS · DEFINITION_OF_DONE
1. Coverage targets
| Tier | Target | Gate |
|---|
| Unit | ≥ 80% statements + lines | Vitest CI |
| Integration | Mandatory scenarios below | CI gate |
| Contract (Pact) | All produced events + internal evaluate | Pact broker |
| E2E | Config → service read; flag evaluate flow | Playwright staging |
2. Mandatory integration tests
2.1 Tenant isolation (test/integration/tenant-isolation.spec.ts)
| Scenario | Assertion |
|---|
| TENANT scope config for Tenant A not visible to Tenant B | Guard + DB filter |
| Tenant Admin cannot read PLATFORM scope config | 403 |
2.2 Outbox (test/integration/outbox.spec.ts)
| Scenario | Assertion |
|---|
| Config upsert writes config + outbox row atomically | DB transaction |
Outbox relay publishes platform_admin.config.updated.v1 | Event received |
2.3 Inbox (test/integration/inbox.spec.ts)
| Scenario | Assertion |
|---|
tenant.tenant.activated.v1 triggers default config provisioning | Config rows created |
| Duplicate event processed idempotently | No duplicate config rows |
2.4 Feature flag evaluation
| Scenario | Assertion |
|---|
defaultEnabled=true, no overrides → enabled=true | Correct decision |
defaultEnabled=true, tenant in disabledTenantIds → enabled=false | Override takes precedence |
Archived flag → always enabled=false regardless of overrides | Invariant enforced |
| Cache hit within 60 s → same result, cache hit counter incremented | Cache behavior |
| Cache miss after 60 s → DB query executed | TTL expiry |
2.5 Health aggregation
| Scenario | Assertion |
|---|
All sources healthy → overall=healthy | Aggregation correct |
One source unhealthy → overall=unhealthy | Aggregation correct |
| Source heartbeat expired → treated as unhealthy | Staleness policy |
3. Contract tests (Pact)
| Subject | File |
|---|
platform_admin.config.updated.v1 | test/contract/config.updated.schema.spec.ts |
platform_admin.flag.updated.v1 | test/contract/flag.updated.schema.spec.ts |
| Internal evaluate (consumer: identity-service) | test/contract/identity-flag-evaluate.pact.spec.ts |
4. E2E tests (staging)
| Scenario | File |
|---|
| Super admin upserts config → identity-service reads new value | config-propagation.e2e.spec.ts |
| Flag created + tenant override → evaluate returns override | flag-evaluate-override.e2e.spec.ts |
| Health aggregate reflects real service health | health-aggregate.e2e.spec.ts |
Internal evaluate endpoint must achieve p95 ≤ 120 ms under 1000 RPS simulated load in staging. Tested as part of M1 readiness gate.