Fair Supply LogoFair Supply - Docs

Guiding Interface Principles

Guidelines for working with the platform app.

Design System

  • Use the luz design system for all components - it provides the "lego blocks" built on Tailwind
  • Components should be reusable and composable
  • Do not write Tailwind CSS directly in web application components

Layout

Components

Server Components (Default)

Client Components

  • Use only when small state updates are necessary

Data Fetching

  • Use use() and <Suspense> for data fetching where possible
  • Use Promise.all() to fetch data in parallel for better performance

State Management

ToolUse Case
React QueryMutations, error handling, optimistic updates
ZustandSmall pieces of client state where useState isn't appropriate

Prop drilling should never be necessary. If you find yourself prop drilling, revisit your component composition.

Testing

Unit Testing

  • Use Vitest for unit tests
  • Use React Testing Library for component tests
  • Test behavior, not implementation details
  • Co-locate test files with components (component.test.tsx)

What to Test

Test TypeExamples
User interactionsClick handlers, form submissions, keyboard navigation
Conditional renderingLoading states, error states, empty states
Data transformationsFormatting functions, filters, calculations
AccessibilityARIA attributes, keyboard support, screen reader text

Snapshot Tests

Use snapshots only for:

  • Serialized data structures - API responses, configuration objects, GraphQL queries
  • Generated output - Email templates, exported data formats, structured logs

Do not use snapshots for:

  • UI components (too brittle, changes are hard to review meaningfully)
  • Large objects (diffs become unreadable)

What NOT to Do

  • Don't test implementation details - Avoid testing internal state, private methods, or component internals
  • Don't test third-party libraries - Trust that React Query, Zustand, etc. work correctly
  • Don't mock everything - Over-mocking leads to tests that pass but don't catch real bugs
  • Don't test trivial code - Simple pass-through components or obvious logic don't need tests
  • Don't use getByTestId as a first choice - Prefer accessible queries: getByRole, getByLabelText, getByText

Integration Testing

  • Use Playwright for end-to-end tests
  • Test critical user flows (authentication, core features)
  • Run against a real or realistic test environment