Skip to content

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

StatusMeaningCount
🟢 CoveredHas integration or E2E test19
🟡 PartialHas unit tests only, no flow test8
🔴 MissingNo tests5

1. Guest Booking

Owner: Core Platform Risk Level: HIGH (user-facing, revenue path) Test Files: 4 files, 162 cases

Business Flows

IDFlowDescriptionStatusTest Files
B1Public booking page loadGuest visits /{podcast}/{link} → sees availability🟢booking-flow.spec.ts
B2Availability calculationDate selected → Google Calendar checked → free slots shown🟢availability/index.test.ts
B3Booking submissionForm submit → booking created → confirmation page🟢bookings/index.test.ts, booking-flow.spec.ts
B4Host confirmationHost confirms → calendar event created → guest notified🟢bookings/index.test.ts
B5Booking declineHost declines → guest notified → booking closed🟢bookings/index.test.ts
B6Booking cancellationCancel → calendar event deleted → automations stopped🟡bookings/index.test.ts (unit only)
B7Booking rescheduleGuest/host reschedules → calendar updated → notifications sent🔴

Service Dependencies

ServicePurposeTested
SupabaseBooking, episode, guest records🟢 Mocked
Google CalendarBusy times, event creation🟢 Mocked
ResendConfirmation emails🟢 Mocked

Test File Details

FileCasesCoverage
src/api/routes/bookings/__tests__/index.test.ts49CRUD, confirm, decline, cancel
src/api/routes/availability/__tests__/index.test.ts41Slot calculation, busy time merge
src/api/routes/guests/__tests__/index.test.ts1POST /send-verification rate-limit wiring
tests/booking-flow.spec.ts~20Full E2E journey

2. Automation Engine

Owner: Core Platform Risk Level: HIGH (core value proposition) Test Files: 6 files, 168 cases

Business Flows

IDFlowDescriptionStatusTest Files
A1Event-based triggerBooking confirmed → matching rules found → executions created🟢events.test.ts, automation-integration.test.ts
A2Time-based schedulingRule with "24h before" → scheduled job created🟢scheduler.test.ts
A3Action executionQueue message → action executed (email/webhook)🟡Worker tests needed
A4Delay handlingAction has 5min delay → continuation job scheduled🔴
A5Rule CRUDCreate/edit/delete automation rules via API🟢automations/rules.test.ts
A6Magic tag replacementTemplate with {guest_name} → replaced with actual value🟢tag-parser.test.ts, magic-tags.test.ts
A7IdempotencySame event emitted twice → only one execution🟢events.test.ts
A8Graceful degradationAutomation fails → booking still succeeds🟢automation-integration.test.ts

Service Dependencies

ServicePurposeTested
SupabaseRules, executions, scheduled jobs🟢 Mocked
Cloudflare QueueAsync execution🟡 Partially
ResendEmail actions🟢 Mocked

Test File Details

FileCasesCoverage
src/lib/automation/__tests__/events.test.ts24Event emission, rule matching
src/lib/automation/__tests__/scheduler.test.ts32Time-based job creation
src/lib/automation/__tests__/magic-tags.test.ts20Tag definitions, categories
src/lib/automation/__tests__/tag-parser.test.ts47Extraction, validation, replacement
src/api/routes/bookings/__tests__/automation-integration.test.ts20Booking → automation integration
src/api/routes/automations/__tests__/rules.test.ts24CRUD, 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

IDFlowDescriptionStatusTest Files
P1Checkout sessionUser selects plan → Stripe checkout created → redirect🟢checkout.test.ts
P2Webhook: checkout.completedStripe event → subscription created → DB updated🟢stripe.test.ts, subscription-flow.integration.test.ts
P3Webhook: subscription.updatedPlan change → tier updated in DB🟢stripe.test.ts
P4Webhook: subscription.deletedCancellation → access revoked🟢stripe.test.ts
P5Customer portalUser clicks "Manage" → portal session created🟢portal.test.ts
P6Plan upgrade/downgradeChange plan → proration calculated → subscription updated🟡stripe.test.ts (webhook only)
P7Failed payment handlingPayment fails → grace period → access suspended🔴

Service Dependencies

ServicePurposeTested
StripeCheckout, webhooks, portal🟢 Mocked
SupabaseUser profiles, subscription status🟢 Mocked

Test File Details

FileCasesCoverage
src/api/routes/stripe/__tests__/checkout.test.ts13Session creation, tier mapping
src/api/routes/stripe/__tests__/portal.test.ts12Portal session creation
src/api/routes/webhooks/__tests__/stripe.test.ts21All webhook event types
src/api/routes/__tests__/subscription-flow.integration.test.ts19Full checkout → webhook → DB flow

4. Media & Storage

Owner: Core Platform Risk Level: MEDIUM (user content) Test Files: 2 files, 105 cases

Business Flows

IDFlowDescriptionStatusTest Files
M1Image presigned URLRequest presigned URL → upload to R2 → confirm🟢presigned.test.ts
M2Audio presigned URLRequest for episode audio → presigned URL generated🟢audio.test.ts
M3Direct uploadSmall file → upload directly through API🟢presigned.test.ts
M4Artwork importImport from URL → download → store in R2🟢presigned.test.ts
M5Media deletionDelete artwork/audio → R2 object removed🟢presigned.test.ts, audio.test.ts
M6Audio metadata extractionUpload complete → duration/bitrate extracted🟡audio.test.ts (partial)

Service Dependencies

ServicePurposeTested
Cloudflare R2Object storage🟢 Mocked
SupabasePodcast/episode records🟢 Mocked

Test File Details

FileCasesCoverage
src/api/routes/media/__tests__/presigned.test.ts57Images: presigned, upload, delete, import
src/api/routes/media/__tests__/audio.test.ts48Audio: presigned, upload, delete

5. Calendar Integration

Owner: Core Platform Risk Level: MEDIUM (external dependency) Test Files: 3 files, 111 cases

Business Flows

IDFlowDescriptionStatusTest Files
C1OAuth connectionUser clicks Connect → Google OAuth → tokens stored🟢auth.test.ts
C2Token refreshAccess token expired → refresh token used → new access token🟢auth.test.ts
C3List calendarsFetch user's calendars from Google🟢calendar.test.ts
C4Get busy timesQuery free/busy API → merge overlapping periods🟢calendar.test.ts
C5Create calendar eventBooking confirmed → event created in Google Calendar🟢calendar.test.ts
C6Update calendar eventBooking rescheduled → event updated🟢calendar.test.ts
C7Delete calendar eventBooking cancelled → event removed🟢calendar.test.ts
C8Calendar preferencesUser sets which calendars to check for conflicts🟢calendars/index.test.ts
C9Disconnect calendarUser removes connection → tokens revoked🟢calendars/index.test.ts

Service Dependencies

ServicePurposeTested
Google Calendar APICalendar operations🟢 Mocked
SupabaseCalendar connections, tokens🟢 Mocked

Test File Details

FileCasesCoverage
src/lib/google-calendar/__tests__/auth.test.ts38OAuth URL, token exchange, refresh, revoke
src/lib/google-calendar/__tests__/calendar.test.ts38List, busy times, CRUD events
src/api/routes/calendars/__tests__/index.test.ts35Connection management API

6. Email & Notifications

Owner: Core Platform Risk Level: MEDIUM (user communication) Test Files: 7 files, 256 cases

Business Flows

IDFlowDescriptionStatusTest Files
E1Booking request emailGuest submits → confirmation email sent🟢index.test.ts, booking-request.test.ts
E2Host notificationNew booking → host notified via email🟢index.test.ts, host-notification.test.ts
E3Booking confirmed emailHost confirms → guest receives confirmation🟢booking-confirmed.test.ts
E4Booking declined emailHost declines → guest receives decline notice🟢booking-declined.test.ts
E5Email template renderingTemplate + data → HTML + plain text output🟢base.test.ts, all template tests
E6Automation email actionAutomation triggers → email sent via template🟡Unit tests only
E7Contact managementAdd/update/delete contacts🟢contacts.test.ts

Service Dependencies

ServicePurposeTested
ResendEmail delivery🟢 Mocked
SupabaseTemplates, contacts🟢 Mocked

Test File Details

FileCasesCoverage
src/lib/email/__tests__/index.test.ts23Client creation, send function
src/lib/email/__tests__/contacts.test.ts23Contact CRUD
src/lib/email/templates/__tests__/base.test.ts24Base template structure
src/lib/email/templates/__tests__/booking-request.test.ts36Request email content
src/lib/email/templates/__tests__/booking-confirmed.test.ts38Confirmation email content
src/lib/email/templates/__tests__/booking-declined.test.ts42Declined email content
src/lib/email/templates/__tests__/host-notification.test.ts37Host notification content

7. Search & Discovery

Owner: Core Platform Risk Level: LOW (enhancement feature) Test Files: 1 file, 65 cases

Business Flows

IDFlowDescriptionStatusTest Files
S1Episode FTS searchQuery → PostgreSQL FTS → ranked results🟢fts-search.test.ts
S2Automation rule searchSearch rules by name/description🟢fts-search.test.ts
S3Template searchSearch notification templates🟢fts-search.test.ts
S4Query escapingSpecial characters escaped properly🟢fts-search.test.ts
S5Fuzzy search (client)Fuse.js instant search🟡No tests
S6Command paletteCmd+K global search🟡No tests

Service Dependencies

ServicePurposeTested
SupabaseFTS queries🟢 Mocked

Test File Details

FileCasesCoverage
src/lib/search/__tests__/fts-search.test.ts65FTS query builder, all search functions

8. Core Infrastructure

Owner: Platform Risk Level: MEDIUM (foundation) Test Files: 6 files, 68 cases

Flows

IDFlowDescriptionStatusTest Files
I1Supabase admin clientServer-side admin operations🟢admin.test.ts
I2Supabase browser clientClient-side with auth🟢client.test.ts
I3Supabase server clientSSR with cookies🟢server.test.ts
I4Stripe clientClient initialization🟢client.test.ts
I5Infrastructure healthEnv vars, connections🟢infra-check.test.ts
I6API rate limitingShared limiter middleware contracts🟢rate-limit.test.ts

Test File Details

FileCasesCoverage
src/lib/supabase/__tests__/admin.test.ts12Admin client creation
src/lib/supabase/__tests__/client.test.ts9Browser client
src/lib/supabase/__tests__/server.test.ts14Server client with cookies
src/lib/stripe/__tests__/client.test.ts5Stripe initialization
src/lib/__tests__/infra-check.test.ts23Environment validation
src/api/middleware/__tests__/rate-limit.test.ts5Shared rate-limit middleware behavior

Priority Gaps

These flows are HIGH risk but have incomplete coverage:

PriorityFlowRiskIssueRecommended Action
1A4: Delay handlingHIGHUntested/scout-test-flow automation-delays
2B7: Booking rescheduleHIGHNo tests/scout-test-flow booking-reschedule
3P7: Failed paymentHIGHNo tests/scout-test-flow payment-failures
4A3: Worker executionHIGHPartialAdd workers/automation-executor/__tests__/

Test File Index

Quick reference for all 33 test files:

#FileCasesDomain
1src/api/routes/bookings/__tests__/index.test.ts49Booking
2src/api/routes/bookings/__tests__/automation-integration.test.ts20Booking/Automation
3src/api/routes/availability/__tests__/index.test.ts41Booking
4src/api/routes/calendars/__tests__/index.test.ts35Calendar
5src/api/routes/media/__tests__/presigned.test.ts57Media
6src/api/routes/media/__tests__/audio.test.ts48Media
7src/api/routes/stripe/__tests__/checkout.test.ts13Payments
8src/api/routes/stripe/__tests__/portal.test.ts12Payments
9src/api/routes/webhooks/__tests__/stripe.test.ts21Payments
10src/api/routes/__tests__/subscription-flow.integration.test.ts19Payments
11src/lib/automation/__tests__/events.test.ts24Automation
12src/lib/automation/__tests__/scheduler.test.ts32Automation
13src/lib/automation/__tests__/magic-tags.test.ts20Automation
14src/lib/automation/__tests__/tag-parser.test.ts47Automation
15src/lib/email/__tests__/index.test.ts23Email
16src/lib/email/__tests__/contacts.test.ts23Email
17src/lib/email/templates/__tests__/base.test.ts24Email
18src/lib/email/templates/__tests__/booking-request.test.ts36Email
19src/lib/email/templates/__tests__/booking-confirmed.test.ts38Email
20src/lib/email/templates/__tests__/booking-declined.test.ts42Email
21src/lib/email/templates/__tests__/host-notification.test.ts37Email
22src/lib/google-calendar/__tests__/auth.test.ts38Calendar
23src/lib/google-calendar/__tests__/calendar.test.ts38Calendar
24src/lib/search/__tests__/fts-search.test.ts65Search
25src/lib/stripe/__tests__/client.test.ts5Payments
26src/lib/supabase/__tests__/admin.test.ts12Infrastructure
27src/lib/supabase/__tests__/client.test.ts9Infrastructure
28src/lib/supabase/__tests__/server.test.ts14Infrastructure
29src/lib/__tests__/infra-check.test.ts23Infrastructure
30tests/booking-flow.spec.ts~20Booking (E2E)
31src/api/routes/automations/__tests__/rules.test.ts24Automation
32src/api/middleware/__tests__/rate-limit.test.ts5Infrastructure
33src/api/routes/guests/__tests__/index.test.ts1Booking

Maintenance

When to Update This Document

  1. New feature added: Add flow to relevant domain section
  2. New test file created: Add to Test File Index and update domain
  3. Flow status changed: Update status emoji
  4. Quarterly audit: Review all flows, update stats

Status Legend

EmojiMeaning
🟢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.

Internal documentation - Not for public distribution