- env.ts: supabase: SupabaseConnection | null resolved from env.js (supabaseUrl/supabaseAnonKey), VITE_SUPABASE_*, else null; half config refused - lib/supabase.ts: getSupabaseClient() null when unconfigured, one client per URL - entrypoint.sh writes the two public values; .env.example placeholders - Dockerfile copies packages/supabase manifest for the install layer - no UI change; 7 new tests (278 app)
30 lines
890 B
TypeScript
30 lines
890 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { getSupabaseClient, isSupabaseConfigured } from '@/lib/supabase'
|
|
import type { AppConfig } from '@/config/env'
|
|
|
|
const base: AppConfig = {
|
|
siteName: 'S',
|
|
brandName: 'B',
|
|
footerName: 'F',
|
|
tagline: 'T',
|
|
supabase: null,
|
|
}
|
|
|
|
describe('getSupabaseClient', () => {
|
|
it('returns null when no backend is configured (current default)', () => {
|
|
expect(getSupabaseClient(base)).toBeNull()
|
|
expect(isSupabaseConfigured(base)).toBe(false)
|
|
})
|
|
|
|
it('creates one client per connection and reuses it', () => {
|
|
const configured: AppConfig = {
|
|
...base,
|
|
supabase: { url: 'http://127.0.0.1:54321', anonKey: 'anon' },
|
|
}
|
|
const first = getSupabaseClient(configured)
|
|
expect(first).not.toBeNull()
|
|
expect(getSupabaseClient(configured)).toBe(first)
|
|
expect(isSupabaseConfigured(configured)).toBe(true)
|
|
})
|
|
})
|