mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 06:09:08 +03:00
Introduces the test infrastructure needed to write component and full-page integration tests against the service registry. tests/lib/service-mocks.ts - Per-service mock factories for all six registry services: projects, organizations, profile, permissions, auth, and featureFlags. - Each factory accepts Partial<Service> overrides so individual methods can be replaced with vi.fn() returning custom data, errors, or never-resolving promises without re-specifying the entire service. - createMockRegistry(overrides?) assembles a complete ServiceRegistry from the factories, accepting per-service overrides at the registry level. tests/lib/render-app.tsx - renderApp(PageComponent, opts): full-page render that sets the router URL via routerMock, wraps the page in its layout chain via PageComponent.getLayout?.(page) ?? page, and renders inside AppProviders with a mock registry. Layouts receive mock data from the registry so the full DefaultLayout → ProjectLayout → ... chain renders without HTTP. - renderWithRegistry(ui, opts): component-level render inside AppProviders + mock registry, for tests that don't need layout wrapping. - renderHookWithRegistry(hook, opts): hook render inside AppProviders + mock registry, for unit-testing hooks that call useService(). - All three helpers accept services?: Partial<ServiceRegistry> and an optional queryClient (defaults to retry: false for test ergonomics). - Uses AppProviders (the production provider tree) rather than a lightweight stub so test behaviour matches production exactly.