Skip to content

test: Add error case coverage for critical paths #123

@claude

Description

@claude

Description

While the codebase has good test coverage (46 test files, 456+ validation tests), there are critical gaps in error case testing and edge case coverage for key user flows.

High-Priority Test Gaps

1. Onboarding Flow Error Cases

File: app/onboarding.tsx

Missing tests for:

  • Supabase upsert failures (network errors, constraint violations)
  • Profile refresh failures after form submission
  • Race condition when profile update takes > 10 seconds (timeout handling)
  • Apple Sign In metadata extraction edge cases

2. useDaysSober Hook Edge Cases

File: hooks/useDaysSober.ts

Missing tests for:

  • Supabase query failures when fetching slip-ups
  • DST (Daylight Saving Time) transition handling
  • Midnight timer calculation edge cases
  • Timezone change during app runtime

3. OAuth Token Extraction

File: contexts/AuthContext.tsx

Missing tests for:

  • Malformed OAuth URLs
  • Deep link URL processing with missing tokens
  • Both hash and query params containing tokens (precedence)
  • Concurrent OAuth flow race conditions

4. TaskCreationModal Error Scenarios

File: components/TaskCreationModal.tsx

Missing tests for:

  • Template fetch failures
  • Task insertion failures with specific error messages
  • Invalid date range validation
  • Empty sponsee list handling

5. Supabase Client Initialization

File: lib/supabase.ts

Missing tests for:

  • Lazy initialization race conditions
  • Storage adapter behavior verification
  • Session persistence with malformed JSON

Mock Improvements Needed

Current Supabase mocks don't simulate:

  • Row-level security (RLS) permission failures
  • Constraint violations (unique email, foreign key)
  • Rate limiting responses
  • Connection timeout behaviors

Acceptance Criteria

  • Add error case tests for onboarding flow
  • Add timezone/DST edge case tests for useDaysSober
  • Add OAuth error path tests for AuthContext
  • Add error scenario tests for TaskCreationModal
  • Improve Supabase mock to simulate failures
  • Maintain 80% coverage threshold

Related


🤖 Generated by Daily Codebase Review Workflow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions