Skip to main content

Scheduling Service — Testing Strategy

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: Service Template · TESTING_STANDARDS

1. Coverage Targets

LayerTarget
Global line coverage≥ 80%
Domain layer (state machine, conflict detection)≥ 95%

2. Mandatory Tests

Test fileWhat it covers
test/integration/tenant-isolation.integration.spec.tsAppointments/slots never leak across tenants
test/integration/outbox.integration.spec.tsEvents written to outbox in same transaction
test/integration/inbox.integration.spec.tsNATS consumed events deduplicated

3. Scenario Coverage Matrix

ScenarioTypePriority
Book appointment — slot becomes busyUnit + IntegrationMust
Book appointment — slot already busy → 409UnitMust
Double-booking blocked (no permission)UnitMust
Double-booking allowed (scheduler role)Unit + IntegrationMust
Reschedule — new slot free → old slot releasedIntegrationMust
Cancel — slot released, waitlist auto-fill triggeredIntegrationMust
No-show recordingUnitMust
Check-in (arrived transition)UnitMust
Fulfil (fulfilled transition)UnitMust
All invalid transitions rejectedUnitMust
Optimistic lock conflict on status updateIntegrationMust
Waitlist entry created and fulfilledIntegrationMust
Availability search returns only free slotsIntegrationMust
Schedule exception blocks slot creationUnitMust
Portal bridge: portal.appointment.requested creates proposedIntegrationMust
Reminder dispatch — success pathUnitShould
Reminder dispatch — retry on failureUnitShould
Patient deceased event cancels future appointmentsIntegrationShould
Tenant isolation for appointmentsIntegration (mandatory)Must
FHIR Appointment read returns correct statusUnitMust
HL7 SIU S12 inbound creates appointmentIntegrationShould

4. Contract Tests

ContractConsumerPact provider test
GET /api/v1/appointments/:idpatient-chart-serviceappointment-by-id.pact.spec.ts
appointment.created event schemaorders-serviceappointment-created.schema.spec.ts
appointment.fulfilled event schemabilling-serviceappointment-fulfilled.schema.spec.ts