d3ro-voice/apps/desktop/tests/main/sync/meeting-recording-pull.test.ts
Yun Chan 69c4307eee fix(sync): don't let a pull wipe the checkpointed transcript of a meeting this device is recording
Checkpoints stay local until stop, so a pull during recording replaced the
saved transcript with the server's empty one; a crash then recovered the
meeting as an error with nothing in it. Status, transcript, end time and
duration of a locally recording meeting are now kept on pull.
2026-10-20 16:31:08 +09:00

67 lines
2.5 KiB
TypeScript

// 녹음 중인 회의를 pull 이 덮지 않는다 — 주기 저장한 전사는 정지 때에야 올라가므로,
// 그 전에 서버의 빈 전사·'recording' 행으로 덮으면 충돌 복구 때 전사가 사라졌다.
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { eq } from 'drizzle-orm'
import { createTestDb } from '../../helpers/createTestDb'
import { bindTestDatabase, unbindTestDatabase } from '../../../src/main/db'
import { meetingSessions } from '../../../src/main/db/schema'
import { initInMemoryConfig, resetInMemoryConfig } from '../../../src/main/services/ConfigService'
import { TABLE_ADAPTERS } from '../../../src/main/services/sync/sync-adapters'
import { syncStateRecordingLedger } from '../../../src/main/services/meeting/local-recording-ledger'
const USER = '11111111-1111-4111-8111-111111111111'
let created: ReturnType<typeof createTestDb>
const meetings = TABLE_ADAPTERS.find((adapter) => adapter.entity === 'meetings')!
function seedRecording(id: string): void {
const now = Date.now()
created.db
.insert(meetingSessions)
.values({ id, title: '주간 회의', status: 'recording', startedAt: now, rawTranscript: '[00:01] 저장된 문장', createdAt: now, updatedAt: now })
.run()
}
function remoteRow(id: string): Record<string, unknown> {
return { id, title: '이름 바꾼 회의', status: 'recording', started_at: new Date().toISOString(), raw_transcript: null, updated_at: new Date().toISOString() }
}
function local(id: string) {
return created.db.select().from(meetingSessions).where(eq(meetingSessions.id, id)).get()
}
beforeEach(() => {
initInMemoryConfig()
created = createTestDb()
bindTestDatabase(created.db, USER)
})
afterEach(() => {
unbindTestDatabase()
resetInMemoryConfig()
created.close()
})
describe('meetings pull — 이 기기에서 녹음 중인 회의', () => {
it('주기 저장한 전사·상태는 지키고 다른 필드는 반영한다', async () => {
const id = crypto.randomUUID()
seedRecording(id)
syncStateRecordingLedger.mark(id)
await meetings.applyRemote(remoteRow(id), {} as never)
expect(local(id)?.rawTranscript).toBe('[00:01] 저장된 문장')
expect(local(id)?.status).toBe('recording')
expect(local(id)?.title).toBe('이름 바꾼 회의')
})
it('녹음이 끝난(표식 없는) 회의는 서버 값을 그대로 반영한다', async () => {
const id = crypto.randomUUID()
seedRecording(id)
await meetings.applyRemote(remoteRow(id), {} as never)
expect(local(id)?.rawTranscript).toBeNull()
})
})