63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
// packages/api-client/__tests__/public-surface-r2-35.test.ts
|
|
// 루트 barrel은 공유 계약(타입 + 클라이언트 팩토리)만 공개해야 한다.
|
|
// 앱마다 따로 소유하는 저장소·쿼터·STT 호출 헬퍼가 '정본처럼' 다시 노출되지 않도록 고정한다.
|
|
|
|
import { describe, expect, expectTypeOf, it, vi } from 'vitest'
|
|
import * as apiClient from '../src/index'
|
|
import type { TranscribeAudioResult } from '../src/index'
|
|
|
|
describe('@d3ro/api-client root surface', () => {
|
|
it('exposes only the client factory runtime values', () => {
|
|
expect(Object.keys(apiClient).sort()).toEqual([
|
|
'SupabaseConfigurationError',
|
|
'createD3roSupabaseClient',
|
|
'isClientConfigured',
|
|
'requireSupabasePublicConfig',
|
|
])
|
|
})
|
|
|
|
it('does not re-export repository, quota, auth or STT call helpers', () => {
|
|
const exported = apiClient as Record<string, unknown>
|
|
for (const name of [
|
|
'listHistory',
|
|
'createHistoryEntry',
|
|
'deleteHistoryEntry',
|
|
'getTodayUsage',
|
|
'listUsageLastDays',
|
|
'getSubscription',
|
|
'listMeetings',
|
|
'updateMeeting',
|
|
'appendTranscript',
|
|
'signInWithOAuth',
|
|
'getSession',
|
|
'transcribeAudio',
|
|
'getSupabaseBrowserClient',
|
|
'createSupabaseServerClient',
|
|
]) {
|
|
expect(exported[name], name).toBeUndefined()
|
|
}
|
|
})
|
|
|
|
it('keeps the STT result contract available as a type', () => {
|
|
expectTypeOf<TranscribeAudioResult>().toHaveProperty('text').toEqualTypeOf<string>()
|
|
expectTypeOf<TranscribeAudioResult>().toHaveProperty('durationSeconds').toEqualTypeOf<number>()
|
|
})
|
|
})
|
|
|
|
describe('transcribeAudio reference client', () => {
|
|
it('does not fall back to process.env for gateway configuration', async () => {
|
|
vi.stubEnv('NEXT_PUBLIC_SUPABASE_URL', 'https://env.supabase.co')
|
|
vi.stubEnv('NEXT_PUBLIC_SUPABASE_ANON_KEY', 'env-anon-key')
|
|
const fetchMock = vi.fn()
|
|
vi.stubGlobal('fetch', fetchMock)
|
|
try {
|
|
const { transcribeAudio } = await import('../src/transcribe')
|
|
await expect(transcribeAudio({ token: 'user-token', audio: new Blob(['x']) }))
|
|
.rejects.toThrow('authenticated Supabase session')
|
|
expect(fetchMock).not.toHaveBeenCalled()
|
|
} finally {
|
|
vi.unstubAllEnvs()
|
|
vi.unstubAllGlobals()
|
|
}
|
|
})
|
|
})
|