- Docs
- Architecture
- Method
- Testing strategy per context
Testing Strategy per Context¶
This page expands the test layers into a per-bounded-context strategy. The seven contexts come from the domain glossary. Use the test layer that proves the behavior: domain rules at unit level, contracts and isolation at integration/feature level, and critical user flows at E2E level.
1. Per-context strategy¶
| Context | Unit focus | Integration / feature focus | E2E focus | Surface(s) |
|---|---|---|---|---|
| Identity & Enrollment | Membership state transitions, company-code validity, role/seat invariants, one-company-per-user rule. | Phone/OTP auth flows, FormRequest validation, JsonResource shape, { message, errors? } error contract, company-scope isolation, enrollment approval/rejection endpoints, broadcast/channel auth where applicable. |
Front Views onboarding and OTP flows; Fleet Dashboard login and enrollment queue/approval flow. | API, Front Views, Fleet Dashboard, Passenger app, Driver app |
| Fleet | Vehicle and Driver membership invariants, assignment/ownership rules, company-bound constraints. | Vehicle CRUD/assignment endpoints, auth and company-scope isolation, JsonResource shape, error contract, audit/event side effects. | Fleet Dashboard vehicle/driver management flows. | API, Fleet Dashboard, Driver app |
| Trips & Booking | Seat availability, reservation deadline, trip-group consistency, booking state rules, car-request/passenger linkage invariants. | Route/trip/booking endpoint contracts, deadline rejection, duplicate/extra-car flows, company-scope isolation, broadcast payloads for booking changes. | Fleet Dashboard trip/booking management; Passenger app booking flow when app CI is available. | API, Fleet Dashboard, Passenger app, Driver app |
| Live Ops | Boarding state transitions, tracking/feedback domain rules, trip visibility constraints. | GPS publish/subscribe authorization, realtime channel auth, boarding endpoint contracts, company/assignment isolation, event/broadcast fixtures. | Fleet Dashboard live operations views; Driver/Passenger realtime flows when app E2E is available. | API, Fleet Dashboard, Passenger app, Driver app |
| D2D | Detour limit checks, D2D eligibility rules, pickup/drop-off point validation, route-plan leg invariants. | D2D eligibility and booking endpoint contracts, detour rejection errors, company/member isolation, Directions/external routing fakes at boundary. | Passenger D2D booking flow when app E2E is available; Dashboard/operator visibility where exposed. | API, Passenger app, Fleet Dashboard |
| Billing & Tiers | Seat-limit calculations, tier boundary rules, company subscription status transitions, suspension invariants. | Tier/seat-limit enforcement endpoints, suspension blocking on protected surfaces, upgrade-message error contracts, company-scope isolation. | Front Views pricing/onboarding plan selection where applicable; Fleet Dashboard seat/tier limit feedback. | API, Front Views, Fleet Dashboard, Platform Admin |
| Reviews & Analytics | Rating bounds, review eligibility/timing rules, trip-analysis metric calculations. | Review submission/query contracts, analytics computation triggers/jobs, JsonResource shape, company/passenger isolation, frozen clocks for time-dependent metrics. | Passenger post-trip review flow when app E2E is available; Fleet Dashboard analytics views. | API, Passenger app, Fleet Dashboard |
2. Surface commands¶
Reuse the commands defined by each surface; do not invent new test runners in this document.
| Surface | Commands | Notes |
|---|---|---|
| API | php artisan test |
Run feature/unit suites for the affected slice; include error-shape and tenant-isolation coverage. |
| Front Views | pnpm test, Playwright |
Use RHF/Zod unit tests, API-mocked integration tests, and Playwright flow coverage. |
| Fleet Dashboard | pnpm test, Playwright |
Use query-hook/pure utility tests, MSW contract handlers, realtime fixtures, and Playwright page flows. |
| Passenger / Driver apps | Jest + React Native Testing Library | Detox/E2E comes later; CI lives in the app repo. Do not fetch or populate app submodules on this host. |
3. Cross-cutting rules¶
- The error-shape contract (
{ "message": string, "errors"?: Record<string, string[]> }) is mandatory for every new endpoint group. - Tenant isolation is explicit: a manager of company A must not read or mutate company B.
- Time-dependent rules (deadlines, ETA, analytics windows) use a frozen clock.
- External services (Directions, SMS, and other third-party boundaries) are faked at the boundary; no live network in tests.
- Passengers pay nothing. Tests must not introduce payment, wallet, top-up, or split-payment behavior.