FluffyLabs / FluffyLabs/shared-ui

Add unit tests for supabase module

Open
#73 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## 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/`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.