feat(V2-3차): pull 확장 + invite flow + Realtime + 테스트 + mobile UI 교체
묶음 E — V2-4b pull 확장:
- CloudSyncService.pullAll()에 meetings/meeting_memos/meeting_documents 추가
- meetings: LWW, 모든 컬럼 매핑 (minutes_json JSON 직렬화)
- meeting_memos: immutable INSERT-only 전략
- meeting_documents: LWW UPDATE
묶음 F — api-client types:
- interface -> type alias 전환 (11개)
- Database 타입에 TypedTable<Row, Insert, Update> 유틸 도입
(Row & Record<string, unknown> 교차로 GenericTable 제약 만족)
- @supabase/ssr 2.102는 supabase-js 버전 불일치로 제네릭 주입 불가 -
다음 사이클로 이월, api-client index.ts는 types만 재수출
묶음 G — apps/mobile UI 교체:
- login.tsx: MetalCard + PhosphorText(hero/label) + PhysicalButton
- meetings.tsx: MetalCard + Led(status) + PhosphorText(body/meta)
- record.tsx: Led + PhosphorText + PhysicalButton
- profile.tsx: MetalCard + PhysicalButton(danger) + d3roNativePalette
묶음 H — V2-7b 이메일 invite flow:
- migrations/20260410000001_team_invites.sql
- team_invites 테이블 (token, email, role, expires_at 7일)
- RLS: 같은 팀 멤버 + 초대 이메일 소유자 SELECT,
owner/admin만 INSERT/DELETE
- generate_invite_token() SECURITY DEFINER RPC (service_role)
- functions/team-invite: 권한 체크 -> 토큰 생성 -> 초대 URL 반환
- functions/team-accept: 토큰 검증 -> expires_at/accepted_at/이메일 일치 ->
team_members upsert -> 초대 accepted 표시
- config.toml에 team-invite/team-accept 함수 등록
- InviteMemberForm 재작성: 이메일 입력 + 역할 선택 -> URL 복사 UI
- /accept-invite 페이지 신규 (Suspense 내 useSearchParams + token 수락)
묶음 I — Realtime transcripts:
- apps/web/components/meetings/live-transcript-list.tsx (client)
- supabase.channel('transcripts:meeting:${id}').on('postgres_changes')
- INSERT -> 세그먼트 추가, UPDATE -> row 교체
- 중복 방지 segment_index 기준
- edited 배지 표시
- meetings/[id]/page.tsx의 transcript 섹션을 LiveTranscriptList로 교체
묶음 J — 테스트:
- packages/api-client/__tests__/client.test.ts (9 tests)
- createD3roSupabaseClient, isClientConfigured 팩토리 검증
- packages/api-client/__tests__/types.test.ts (10 tests)
- 모든 Row 타입 + 리터럴 union + Database keyof
- vitest.config.ts 신규
- apps/web/playwright.config.ts 신규 (baseURL, webServer dev 서버)
- apps/web/e2e/smoke.spec.ts 신규 (6 스모크 테스트)
- apps/web tsconfig exclude에 e2e/playwright.config.ts 추가
- package.json scripts: test, test:e2e, test:e2e:ui
검증:
- desktop typecheck OK
- web typecheck OK
- web next build OK (12 라우트, /accept-invite Suspense 적용)
- desktop build OK
- api-client test 19 passed
This commit is contained in:
parent
37f3f4d5bd
commit
c167737198
26 changed files with 1530 additions and 374 deletions
64
packages/api-client/__tests__/client.test.ts
Normal file
64
packages/api-client/__tests__/client.test.ts
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
// packages/api-client/__tests__/client.test.ts
|
||||
// createD3roSupabaseClient 팩토리 유닛 테스트
|
||||
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { createD3roSupabaseClient, isClientConfigured } from '../src/client'
|
||||
|
||||
describe('createD3roSupabaseClient', () => {
|
||||
it('URL과 key가 없으면 placeholder 클라이언트를 반환한다', () => {
|
||||
const client = createD3roSupabaseClient({ url: undefined, anonKey: undefined })
|
||||
expect(client).toBeDefined()
|
||||
// auth, from 등 메서드가 존재해야 함
|
||||
expect(typeof client.auth.getSession).toBe('function')
|
||||
expect(typeof client.from).toBe('function')
|
||||
})
|
||||
|
||||
it('URL만 있고 key가 없으면 placeholder 클라이언트를 반환한다', () => {
|
||||
const client = createD3roSupabaseClient({
|
||||
url: 'https://real.supabase.co',
|
||||
anonKey: undefined
|
||||
})
|
||||
expect(client).toBeDefined()
|
||||
})
|
||||
|
||||
it('URL과 key가 모두 있으면 실제 클라이언트를 생성한다', () => {
|
||||
const client = createD3roSupabaseClient({
|
||||
url: 'https://real.supabase.co',
|
||||
anonKey: 'real-anon-key'
|
||||
})
|
||||
expect(client).toBeDefined()
|
||||
expect(typeof client.auth.getSession).toBe('function')
|
||||
})
|
||||
|
||||
it('auth 옵션을 주입할 수 있다', () => {
|
||||
const client = createD3roSupabaseClient({
|
||||
url: 'https://real.supabase.co',
|
||||
anonKey: 'real-anon-key',
|
||||
auth: { persistSession: false, autoRefreshToken: false }
|
||||
})
|
||||
expect(client).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('isClientConfigured', () => {
|
||||
it('URL과 key가 모두 있으면 true', () => {
|
||||
expect(isClientConfigured({ url: 'https://x.supabase.co', anonKey: 'k' })).toBe(true)
|
||||
})
|
||||
|
||||
it('URL만 있으면 false', () => {
|
||||
expect(isClientConfigured({ url: 'https://x.supabase.co', anonKey: undefined })).toBe(false)
|
||||
})
|
||||
|
||||
it('key만 있으면 false', () => {
|
||||
expect(isClientConfigured({ url: undefined, anonKey: 'k' })).toBe(false)
|
||||
})
|
||||
|
||||
it('둘 다 없으면 false', () => {
|
||||
expect(isClientConfigured({ url: undefined, anonKey: undefined })).toBe(false)
|
||||
})
|
||||
|
||||
it('빈 문자열은 false로 처리된다', () => {
|
||||
expect(isClientConfigured({ url: '', anonKey: 'k' })).toBe(false)
|
||||
expect(isClientConfigured({ url: 'https://x.supabase.co', anonKey: '' })).toBe(false)
|
||||
})
|
||||
})
|
||||
128
packages/api-client/__tests__/types.test.ts
Normal file
128
packages/api-client/__tests__/types.test.ts
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
// packages/api-client/__tests__/types.test.ts
|
||||
// Database/Profile/Meeting 등 타입이 올바르게 export되는지 확인 (컴파일 체크)
|
||||
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import type {
|
||||
Database,
|
||||
Profile,
|
||||
Meeting,
|
||||
MeetingMemo,
|
||||
MeetingDocument,
|
||||
Transcript,
|
||||
HistoryEntry,
|
||||
DictionaryEntry,
|
||||
Team,
|
||||
TeamMember,
|
||||
Subscription,
|
||||
SubscriptionTier,
|
||||
TeamRole,
|
||||
MeetingStatus,
|
||||
DocumentTemplateType,
|
||||
HistoryMode,
|
||||
HistoryStatus
|
||||
} from '../src/types'
|
||||
|
||||
describe('api-client types', () => {
|
||||
it('SubscriptionTier 리터럴 union', () => {
|
||||
const tiers: SubscriptionTier[] = ['free', 'pro', 'team']
|
||||
expect(tiers).toHaveLength(3)
|
||||
})
|
||||
|
||||
it('TeamRole 리터럴 union', () => {
|
||||
const roles: TeamRole[] = ['owner', 'admin', 'member']
|
||||
expect(roles).toHaveLength(3)
|
||||
})
|
||||
|
||||
it('MeetingStatus 리터럴 union', () => {
|
||||
const statuses: MeetingStatus[] = ['recording', 'processing', 'completed', 'error']
|
||||
expect(statuses).toHaveLength(4)
|
||||
})
|
||||
|
||||
it('DocumentTemplateType 리터럴 union', () => {
|
||||
const templates: DocumentTemplateType[] = [
|
||||
'minutes',
|
||||
'report',
|
||||
'idea-note',
|
||||
'custom',
|
||||
'mindmap'
|
||||
]
|
||||
expect(templates).toHaveLength(5)
|
||||
})
|
||||
|
||||
it('HistoryMode 리터럴 union', () => {
|
||||
const modes: HistoryMode[] = [
|
||||
'dictation',
|
||||
'translate',
|
||||
'command',
|
||||
'caption',
|
||||
'file-transcription'
|
||||
]
|
||||
expect(modes).toHaveLength(5)
|
||||
})
|
||||
|
||||
it('HistoryStatus 리터럴 union', () => {
|
||||
const statuses: HistoryStatus[] = ['completed', 'cancelled', 'error']
|
||||
expect(statuses).toHaveLength(3)
|
||||
})
|
||||
|
||||
it('Profile 구조', () => {
|
||||
const profile: Profile = {
|
||||
id: 'uuid',
|
||||
name: 'Alice',
|
||||
avatar_url: null,
|
||||
locale: 'ko',
|
||||
tier: 'free',
|
||||
created_at: '2026-01-01T00:00:00Z',
|
||||
updated_at: '2026-01-01T00:00:00Z'
|
||||
}
|
||||
expect(profile.id).toBe('uuid')
|
||||
expect(profile.tier).toBe('free')
|
||||
})
|
||||
|
||||
it('Meeting 구조', () => {
|
||||
const meeting: Meeting = {
|
||||
id: 'uuid',
|
||||
user_id: 'user-uuid',
|
||||
team_id: null,
|
||||
title: 'Test Meeting',
|
||||
status: 'completed',
|
||||
started_at: '2026-01-01T00:00:00Z',
|
||||
ended_at: null,
|
||||
duration_ms: 120000,
|
||||
raw_transcript: null,
|
||||
edited_transcript: null,
|
||||
minutes_markdown: null,
|
||||
minutes_json: null,
|
||||
stt_model: null,
|
||||
llm_model: null,
|
||||
stt_latency_ms: null,
|
||||
llm_latency_ms: null,
|
||||
error_message: null,
|
||||
audio_storage_key: null,
|
||||
created_at: '2026-01-01T00:00:00Z',
|
||||
updated_at: '2026-01-01T00:00:00Z'
|
||||
}
|
||||
expect(meeting.status).toBe('completed')
|
||||
})
|
||||
|
||||
it('Database 타입이 존재한다', () => {
|
||||
// 컴파일 타임 체크 — Database가 export 되지 않으면 이 줄이 에러
|
||||
const check: keyof Database = 'public'
|
||||
expect(check).toBe('public')
|
||||
})
|
||||
|
||||
// 미사용 import 방지용
|
||||
it('모든 타입 import 검증', () => {
|
||||
const _unused: [
|
||||
MeetingMemo?,
|
||||
MeetingDocument?,
|
||||
Transcript?,
|
||||
HistoryEntry?,
|
||||
DictionaryEntry?,
|
||||
Team?,
|
||||
TeamMember?,
|
||||
Subscription?
|
||||
] = []
|
||||
expect(_unused).toBeDefined()
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue