Skip to content

Add unit tests for supabase module #73

@tomusdrw

Description

@tomusdrw

Context

The lib/supabase/ module currently has zero test coverage. All hooks, components, and utilities need tests.

What to test

Hooks (unit tests with mocked context)

  • useUser, useSession, useSignOut — throw outside SupabaseProvider, return correct values from context
  • useSubscription — returns free/pro status correctly, handles expired subscriptions
  • useQuota — returns correct canUse/remaining for free vs pro users, increment updates count
  • useUserData — fetch, save, remove operations, app-scoped vs shared data

Components (render tests)

  • AuthFlow — renders login/register tabs, switches between them, clears passwords, handles duplicate email detection
  • UserMenu — renders login button when logged out, email dropdown when logged in, compact variant
  • Settings — renders theme selector
  • PricingCard — renders plan info, disables button for active subscribers
  • QuotaGate — shows content when under limit, shows pricing card when over, shows progress bar
  • SubscriptionStatus — shows free/pro badge, manage/upgrade buttons

Mocking strategy

Use the MockSupabaseProvider from StorybookProvider.tsx (already exists for Storybook) to provide mock context values. For Supabase client calls (.from().select() etc.), mock the client methods.

Acceptance criteria

  • All hooks have tests for happy path and error cases
  • All components render correctly in both auth states
  • Coverage target: 80%+ for lib/supabase/

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions