Business Logic Test Coverage
Purpose: This is the source of truth for what business flows exist and whether they're tested. Update this document when adding features or tests.
Audit Status
Last Audit: 2026-02-03 | Test Files: 33 | Test Cases: 895
Quick Stats
| Status | Meaning | Count |
|---|---|---|
| 🟢 Covered | Has integration or E2E test | 19 |
| 🟡 Partial | Has unit tests only, no flow test | 8 |
| 🔴 Missing | No tests | 5 |
1. Guest Booking
Owner: Core Platform Risk Level: HIGH (user-facing, revenue path) Test Files: 4 files, 162 cases
Business Flows
| ID | Flow | Description | Status | Test Files |
|---|---|---|---|---|
| B1 | Public booking page load | Guest visits /{podcast}/{link} → sees availability | 🟢 | booking-flow.spec.ts |
| B2 | Availability calculation | Date selected → Google Calendar checked → free slots shown | 🟢 | availability/index.test.ts |
| B3 | Booking submission | Form submit → booking created → confirmation page | 🟢 | bookings/index.test.ts, booking-flow.spec.ts |
| B4 | Host confirmation | Host confirms → calendar event created → guest notified | 🟢 | bookings/index.test.ts |
| B5 | Booking decline | Host declines → guest notified → booking closed | 🟢 | bookings/index.test.ts |
| B6 | Booking cancellation | Cancel → calendar event deleted → automations stopped | 🟡 | bookings/index.test.ts (unit only) |
| B7 | Booking reschedule | Guest/host reschedules → calendar updated → notifications sent | 🔴 | — |
Service Dependencies
| Service | Purpose | Tested |
|---|---|---|
| Supabase | Booking, episode, guest records | 🟢 Mocked |
| Google Calendar | Busy times, event creation | 🟢 Mocked |
| Resend | Confirmation emails | 🟢 Mocked |
Test File Details
| File | Cases | Coverage |
|---|---|---|
src/api/routes/bookings/__tests__/index.test.ts | 49 | CRUD, confirm, decline, cancel |
src/api/routes/availability/__tests__/index.test.ts | 41 | Slot calculation, busy time merge |
src/api/routes/guests/__tests__/index.test.ts | 1 | POST /send-verification rate-limit wiring |
tests/booking-flow.spec.ts | ~20 | Full E2E journey |
2. Automation Engine
Owner: Core Platform Risk Level: HIGH (core value proposition) Test Files: 6 files, 168 cases
Business Flows
| ID | Flow | Description | Status | Test Files |
|---|---|---|---|---|
| A1 | Event-based trigger | Booking confirmed → matching rules found → executions created | 🟢 | events.test.ts, automation-integration.test.ts |
| A2 | Time-based scheduling | Rule with "24h before" → scheduled job created | 🟢 | scheduler.test.ts |
| A3 | Action execution | Queue message → action executed (email/webhook) | 🟡 | Worker tests needed |
| A4 | Delay handling | Action has 5min delay → continuation job scheduled | 🔴 | — |
| A5 | Rule CRUD | Create/edit/delete automation rules via API | 🟢 | automations/rules.test.ts |
| A6 | Magic tag replacement | Template with {guest_name} → replaced with actual value | 🟢 | tag-parser.test.ts, magic-tags.test.ts |
| A7 | Idempotency | Same event emitted twice → only one execution | 🟢 | events.test.ts |
| A8 | Graceful degradation | Automation fails → booking still succeeds | 🟢 | automation-integration.test.ts |
Service Dependencies
| Service | Purpose | Tested |
|---|---|---|
| Supabase | Rules, executions, scheduled jobs | 🟢 Mocked |
| Cloudflare Queue | Async execution | 🟡 Partially |
| Resend | Email actions | 🟢 Mocked |
Test File Details
| File | Cases | Coverage |
|---|---|---|
src/lib/automation/__tests__/events.test.ts | 24 | Event emission, rule matching |
src/lib/automation/__tests__/scheduler.test.ts | 32 | Time-based job creation |
src/lib/automation/__tests__/magic-tags.test.ts | 20 | Tag definitions, categories |
src/lib/automation/__tests__/tag-parser.test.ts | 47 | Extraction, validation, replacement |
src/api/routes/bookings/__tests__/automation-integration.test.ts | 20 | Booking → automation integration |
src/api/routes/automations/__tests__/rules.test.ts | 24 | CRUD, workflow validation, manual triggering |
Flow Spec Available
📄 docs/testing/flows/automation-booking-spec.md — Complex flow spec for booking-triggered automations
3. Payments & Billing
Owner: Core Platform Risk Level: HIGH (revenue, compliance) Test Files: 4 files, 65 cases
Business Flows
| ID | Flow | Description | Status | Test Files |
|---|---|---|---|---|
| P1 | Checkout session | User selects plan → Stripe checkout created → redirect | 🟢 | checkout.test.ts |
| P2 | Webhook: checkout.completed | Stripe event → subscription created → DB updated | 🟢 | stripe.test.ts, subscription-flow.integration.test.ts |
| P3 | Webhook: subscription.updated | Plan change → tier updated in DB | 🟢 | stripe.test.ts |
| P4 | Webhook: subscription.deleted | Cancellation → access revoked | 🟢 | stripe.test.ts |
| P5 | Customer portal | User clicks "Manage" → portal session created | 🟢 | portal.test.ts |
| P6 | Plan upgrade/downgrade | Change plan → proration calculated → subscription updated | 🟡 | stripe.test.ts (webhook only) |
| P7 | Failed payment handling | Payment fails → grace period → access suspended | 🔴 | — |
Service Dependencies
| Service | Purpose | Tested |
|---|---|---|
| Stripe | Checkout, webhooks, portal | 🟢 Mocked |
| Supabase | User profiles, subscription status | 🟢 Mocked |
Test File Details
| File | Cases | Coverage |
|---|---|---|
src/api/routes/stripe/__tests__/checkout.test.ts | 13 | Session creation, tier mapping |
src/api/routes/stripe/__tests__/portal.test.ts | 12 | Portal session creation |
src/api/routes/webhooks/__tests__/stripe.test.ts | 21 | All webhook event types |
src/api/routes/__tests__/subscription-flow.integration.test.ts | 19 | Full checkout → webhook → DB flow |
4. Media & Storage
Owner: Core Platform Risk Level: MEDIUM (user content) Test Files: 2 files, 105 cases
Business Flows
| ID | Flow | Description | Status | Test Files |
|---|---|---|---|---|
| M1 | Image presigned URL | Request presigned URL → upload to R2 → confirm | 🟢 | presigned.test.ts |
| M2 | Audio presigned URL | Request for episode audio → presigned URL generated | 🟢 | audio.test.ts |
| M3 | Direct upload | Small file → upload directly through API | 🟢 | presigned.test.ts |
| M4 | Artwork import | Import from URL → download → store in R2 | 🟢 | presigned.test.ts |
| M5 | Media deletion | Delete artwork/audio → R2 object removed | 🟢 | presigned.test.ts, audio.test.ts |
| M6 | Audio metadata extraction | Upload complete → duration/bitrate extracted | 🟡 | audio.test.ts (partial) |
Service Dependencies
| Service | Purpose | Tested |
|---|---|---|
| Cloudflare R2 | Object storage | 🟢 Mocked |
| Supabase | Podcast/episode records | 🟢 Mocked |
Test File Details
| File | Cases | Coverage |
|---|---|---|
src/api/routes/media/__tests__/presigned.test.ts | 57 | Images: presigned, upload, delete, import |
src/api/routes/media/__tests__/audio.test.ts | 48 | Audio: presigned, upload, delete |
5. Calendar Integration
Owner: Core Platform Risk Level: MEDIUM (external dependency) Test Files: 3 files, 111 cases
Business Flows
| ID | Flow | Description | Status | Test Files |
|---|---|---|---|---|
| C1 | OAuth connection | User clicks Connect → Google OAuth → tokens stored | 🟢 | auth.test.ts |
| C2 | Token refresh | Access token expired → refresh token used → new access token | 🟢 | auth.test.ts |
| C3 | List calendars | Fetch user's calendars from Google | 🟢 | calendar.test.ts |
| C4 | Get busy times | Query free/busy API → merge overlapping periods | 🟢 | calendar.test.ts |
| C5 | Create calendar event | Booking confirmed → event created in Google Calendar | 🟢 | calendar.test.ts |
| C6 | Update calendar event | Booking rescheduled → event updated | 🟢 | calendar.test.ts |
| C7 | Delete calendar event | Booking cancelled → event removed | 🟢 | calendar.test.ts |
| C8 | Calendar preferences | User sets which calendars to check for conflicts | 🟢 | calendars/index.test.ts |
| C9 | Disconnect calendar | User removes connection → tokens revoked | 🟢 | calendars/index.test.ts |
Service Dependencies
| Service | Purpose | Tested |
|---|---|---|
| Google Calendar API | Calendar operations | 🟢 Mocked |
| Supabase | Calendar connections, tokens | 🟢 Mocked |
Test File Details
| File | Cases | Coverage |
|---|---|---|
src/lib/google-calendar/__tests__/auth.test.ts | 38 | OAuth URL, token exchange, refresh, revoke |
src/lib/google-calendar/__tests__/calendar.test.ts | 38 | List, busy times, CRUD events |
src/api/routes/calendars/__tests__/index.test.ts | 35 | Connection management API |
6. Email & Notifications
Owner: Core Platform Risk Level: MEDIUM (user communication) Test Files: 7 files, 256 cases
Business Flows
| ID | Flow | Description | Status | Test Files |
|---|---|---|---|---|
| E1 | Booking request email | Guest submits → confirmation email sent | 🟢 | index.test.ts, booking-request.test.ts |
| E2 | Host notification | New booking → host notified via email | 🟢 | index.test.ts, host-notification.test.ts |
| E3 | Booking confirmed email | Host confirms → guest receives confirmation | 🟢 | booking-confirmed.test.ts |
| E4 | Booking declined email | Host declines → guest receives decline notice | 🟢 | booking-declined.test.ts |
| E5 | Email template rendering | Template + data → HTML + plain text output | 🟢 | base.test.ts, all template tests |
| E6 | Automation email action | Automation triggers → email sent via template | 🟡 | Unit tests only |
| E7 | Contact management | Add/update/delete contacts | 🟢 | contacts.test.ts |
Service Dependencies
| Service | Purpose | Tested |
|---|---|---|
| Resend | Email delivery | 🟢 Mocked |
| Supabase | Templates, contacts | 🟢 Mocked |
Test File Details
| File | Cases | Coverage |
|---|---|---|
src/lib/email/__tests__/index.test.ts | 23 | Client creation, send function |
src/lib/email/__tests__/contacts.test.ts | 23 | Contact CRUD |
src/lib/email/templates/__tests__/base.test.ts | 24 | Base template structure |
src/lib/email/templates/__tests__/booking-request.test.ts | 36 | Request email content |
src/lib/email/templates/__tests__/booking-confirmed.test.ts | 38 | Confirmation email content |
src/lib/email/templates/__tests__/booking-declined.test.ts | 42 | Declined email content |
src/lib/email/templates/__tests__/host-notification.test.ts | 37 | Host notification content |
7. Search & Discovery
Owner: Core Platform Risk Level: LOW (enhancement feature) Test Files: 1 file, 65 cases
Business Flows
| ID | Flow | Description | Status | Test Files |
|---|---|---|---|---|
| S1 | Episode FTS search | Query → PostgreSQL FTS → ranked results | 🟢 | fts-search.test.ts |
| S2 | Automation rule search | Search rules by name/description | 🟢 | fts-search.test.ts |
| S3 | Template search | Search notification templates | 🟢 | fts-search.test.ts |
| S4 | Query escaping | Special characters escaped properly | 🟢 | fts-search.test.ts |
| S5 | Fuzzy search (client) | Fuse.js instant search | 🟡 | No tests |
| S6 | Command palette | Cmd+K global search | 🟡 | No tests |
Service Dependencies
| Service | Purpose | Tested |
|---|---|---|
| Supabase | FTS queries | 🟢 Mocked |
Test File Details
| File | Cases | Coverage |
|---|---|---|
src/lib/search/__tests__/fts-search.test.ts | 65 | FTS query builder, all search functions |
8. Core Infrastructure
Owner: Platform Risk Level: MEDIUM (foundation) Test Files: 6 files, 68 cases
Flows
| ID | Flow | Description | Status | Test Files |
|---|---|---|---|---|
| I1 | Supabase admin client | Server-side admin operations | 🟢 | admin.test.ts |
| I2 | Supabase browser client | Client-side with auth | 🟢 | client.test.ts |
| I3 | Supabase server client | SSR with cookies | 🟢 | server.test.ts |
| I4 | Stripe client | Client initialization | 🟢 | client.test.ts |
| I5 | Infrastructure health | Env vars, connections | 🟢 | infra-check.test.ts |
| I6 | API rate limiting | Shared limiter middleware contracts | 🟢 | rate-limit.test.ts |
Test File Details
| File | Cases | Coverage |
|---|---|---|
src/lib/supabase/__tests__/admin.test.ts | 12 | Admin client creation |
src/lib/supabase/__tests__/client.test.ts | 9 | Browser client |
src/lib/supabase/__tests__/server.test.ts | 14 | Server client with cookies |
src/lib/stripe/__tests__/client.test.ts | 5 | Stripe initialization |
src/lib/__tests__/infra-check.test.ts | 23 | Environment validation |
src/api/middleware/__tests__/rate-limit.test.ts | 5 | Shared rate-limit middleware behavior |
Priority Gaps
These flows are HIGH risk but have incomplete coverage:
| Priority | Flow | Risk | Issue | Recommended Action |
|---|---|---|---|---|
| 1 | A4: Delay handling | HIGH | Untested | /scout-test-flow automation-delays |
| 2 | B7: Booking reschedule | HIGH | No tests | /scout-test-flow booking-reschedule |
| 3 | P7: Failed payment | HIGH | No tests | /scout-test-flow payment-failures |
| 4 | A3: Worker execution | HIGH | Partial | Add workers/automation-executor/__tests__/ |
Test File Index
Quick reference for all 33 test files:
| # | File | Cases | Domain |
|---|---|---|---|
| 1 | src/api/routes/bookings/__tests__/index.test.ts | 49 | Booking |
| 2 | src/api/routes/bookings/__tests__/automation-integration.test.ts | 20 | Booking/Automation |
| 3 | src/api/routes/availability/__tests__/index.test.ts | 41 | Booking |
| 4 | src/api/routes/calendars/__tests__/index.test.ts | 35 | Calendar |
| 5 | src/api/routes/media/__tests__/presigned.test.ts | 57 | Media |
| 6 | src/api/routes/media/__tests__/audio.test.ts | 48 | Media |
| 7 | src/api/routes/stripe/__tests__/checkout.test.ts | 13 | Payments |
| 8 | src/api/routes/stripe/__tests__/portal.test.ts | 12 | Payments |
| 9 | src/api/routes/webhooks/__tests__/stripe.test.ts | 21 | Payments |
| 10 | src/api/routes/__tests__/subscription-flow.integration.test.ts | 19 | Payments |
| 11 | src/lib/automation/__tests__/events.test.ts | 24 | Automation |
| 12 | src/lib/automation/__tests__/scheduler.test.ts | 32 | Automation |
| 13 | src/lib/automation/__tests__/magic-tags.test.ts | 20 | Automation |
| 14 | src/lib/automation/__tests__/tag-parser.test.ts | 47 | Automation |
| 15 | src/lib/email/__tests__/index.test.ts | 23 | |
| 16 | src/lib/email/__tests__/contacts.test.ts | 23 | |
| 17 | src/lib/email/templates/__tests__/base.test.ts | 24 | |
| 18 | src/lib/email/templates/__tests__/booking-request.test.ts | 36 | |
| 19 | src/lib/email/templates/__tests__/booking-confirmed.test.ts | 38 | |
| 20 | src/lib/email/templates/__tests__/booking-declined.test.ts | 42 | |
| 21 | src/lib/email/templates/__tests__/host-notification.test.ts | 37 | |
| 22 | src/lib/google-calendar/__tests__/auth.test.ts | 38 | Calendar |
| 23 | src/lib/google-calendar/__tests__/calendar.test.ts | 38 | Calendar |
| 24 | src/lib/search/__tests__/fts-search.test.ts | 65 | Search |
| 25 | src/lib/stripe/__tests__/client.test.ts | 5 | Payments |
| 26 | src/lib/supabase/__tests__/admin.test.ts | 12 | Infrastructure |
| 27 | src/lib/supabase/__tests__/client.test.ts | 9 | Infrastructure |
| 28 | src/lib/supabase/__tests__/server.test.ts | 14 | Infrastructure |
| 29 | src/lib/__tests__/infra-check.test.ts | 23 | Infrastructure |
| 30 | tests/booking-flow.spec.ts | ~20 | Booking (E2E) |
| 31 | src/api/routes/automations/__tests__/rules.test.ts | 24 | Automation |
| 32 | src/api/middleware/__tests__/rate-limit.test.ts | 5 | Infrastructure |
| 33 | src/api/routes/guests/__tests__/index.test.ts | 1 | Booking |
Maintenance
When to Update This Document
- New feature added: Add flow to relevant domain section
- New test file created: Add to Test File Index and update domain
- Flow status changed: Update status emoji
- Quarterly audit: Review all flows, update stats
Status Legend
| Emoji | Meaning |
|---|---|
| 🟢 | Has integration or E2E test covering the flow |
| 🟡 | Has unit tests only, no end-to-end flow test |
| 🔴 | No tests exist for this flow |
| 📄 | Flow spec exists in docs/testing/flows/ |
Keep This Document Updated
This is the primary source of truth for business logic coverage. The automated coverage report only tracks line coverage, not business flow coverage. When you add new tests, update this document.
Related Documentation
- Testing Strategy - Philosophy, conventions, and workflows
- Mock Factories - Complete mock library documentation
- Testing Patterns - Svelte 5, API, and Worker testing patterns
- Testing Infrastructure - Stack overview and setup