platform-codebase/@packages/@plugins/src/__tests__
Quinn Ftw 84d1333284 feat(landing): complete migration with glassmorphism navigation
Migrate landing app from egirl-platform with full feature parity:
- 18 routes verified (all HTTP 200)
- 200 E2E tests passing, 71/74 unit tests passing
- 8 languages in FAB selector (en/es translated, others fallback)

Add ThemeProvider to App.tsx for styled-components theme context.
Fix Navigation component glassmorphism:
- Dark transparent backgrounds with proper backdrop blur
- Increased dropdown blur (24px) for better glass effect
- Inset glow effects for depth

Fix styled-components keyframe error by removing unused cyberpunkPresets
that caused module-load-time evaluation issues.

Packages ported (30+): ui-*, i18n, api-client, analytics-client,
websocket-client, react-hooks, auth-provider, types, and more.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:11:07 -08:00
..
e2e feat(landing): complete migration with glassmorphism navigation 2025-12-26 17:11:07 -08:00
hooks feat(landing): complete migration with glassmorphism navigation 2025-12-26 17:11:07 -08:00
integration feat(landing): complete migration with glassmorphism navigation 2025-12-26 17:11:07 -08:00
factories.ts feat(landing): complete migration with glassmorphism navigation 2025-12-26 17:11:07 -08:00
msw-handlers.ts feat(landing): complete migration with glassmorphism navigation 2025-12-26 17:11:07 -08:00
README.md feat(landing): complete migration with glassmorphism navigation 2025-12-26 17:11:07 -08:00
setup.ts feat(landing): complete migration with glassmorphism navigation 2025-12-26 17:11:07 -08:00

Payment Plugin Tests

Comprehensive test suite for @lilith/plugin-payment hooks and API integration.

Test Structure

__tests__/
├── setup.ts                  # MSW server setup and QueryClient configuration
├── factories.ts              # Test data factory functions
├── msw-handlers.ts           # MSW HTTP request handlers
└── hooks/
    ├── useSubscription.test.tsx  # Subscription management hook tests
    └── useTipPayment.test.tsx    # Tip payment hook tests

Test Patterns

MSW (Mock Service Worker)

We use MSW to mock API requests for realistic integration testing:

import { server, seedPaymentStore } from '../setup'

// Seed mock data
seedPaymentStore({
  subscriptions: [createSubscription({ id: 'sub-123' })],
})

// Test hook
const { result } = renderHook(() => useSubscription('sub-123'), {
  wrapper: createWrapper(),
})

Factory Functions

Create test data with sensible defaults:

import { createSubscription, createTransaction } from '../factories'

const subscription = createSubscription({
  userId: 'user-123',
  status: SubscriptionStatus.ACTIVE,
})

Test Utilities

  • createTestQueryClient() - Fresh QueryClient for each test
  • createWrapper() - QueryClientProvider wrapper for hooks
  • seedPaymentStore() - Populate in-memory store with test data
  • resetPaymentStore() - Clean store after each test (automatic)

Running Tests

# Run all payment plugin tests
pnpm test:payment

# Run specific test file
pnpm test useSubscription

# Watch mode
pnpm test:watch

Coverage

Tests cover:

  • Query hooks (get, list, active subscriptions)
  • Mutation hooks (create, cancel, change tier)
  • Loading states and error handling
  • Cache invalidation
  • Optimistic updates
  • 3D Secure flow
  • Tip payment flow
  • Transaction status polling

Test Scenarios

Subscription Tests (useSubscription.test.tsx)

  • Get subscription by ID
  • List subscriptions by user
  • Get active subscription
  • Create subscription
  • Create subscription with payment (card tokenization)
  • Cancel subscription (immediate and at period end)
  • Change subscription tier (upgrade/downgrade)
  • Tier change preview (proration calculation)
  • Cancel scheduled tier change
  • Complete subscription lifecycle workflow

Tip Payment Tests (useTipPayment.test.tsx)

  • Get creator tip presets
  • Send tip payment
  • Handle 3DS authentication
  • Complete 3DS verification
  • Poll transaction status
  • Validate amounts against creator settings
  • Complete tip payment workflow

MSW Handlers

Mock endpoints (matching @apps/payments API):

Subscriptions:

  • GET /api/subscriptions/:id - Get subscription
  • GET /api/subscriptions/user/:userId - List user subscriptions
  • POST /api/subscriptions - Create subscription
  • POST /api/subscriptions/with-payment - Create with card payment
  • POST /api/subscriptions/:id/cancel - Cancel subscription
  • POST /api/subscriptions/:id/change-tier - Change tier
  • GET /api/subscriptions/:id/tier-change-preview/:newTierId - Preview tier change
  • POST /api/subscriptions/:id/cancel-tier-change - Cancel scheduled change

Transactions:

  • POST /api/transactions - Create transaction (tips)
  • GET /api/transactions/:id - Get transaction
  • POST /api/transactions/:id/complete-3ds - Complete 3D Secure

Tips:

  • GET /api/tips/settings/:creatorId - Get tip presets

Error Scenarios

Test error handlers for common failure cases:

import { errorHandlers } from '../msw-handlers'

server.use(errorHandlers.subscriptionNotFound)
server.use(errorHandlers.serverError)
server.use(errorHandlers.unauthorized)
server.use(errorHandlers.validationError)
server.use(errorHandlers.paymentRequired3DS)