fix(cloud-sync): finish active dictation and meeting recording before switching to another account's database
Signing in as a different account (e.g. while the previous one was still waiting on an offline restore) swapped the database under a live recording, so its final save and audio upload went into the new account. The sign-out capture shutdown now also runs whenever the open database belongs to another user.
This commit is contained in:
parent
69c4307eee
commit
c3ca95d20f
2 changed files with 59 additions and 12 deletions
|
|
@ -50,6 +50,11 @@ const h = vi.hoisted(() => {
|
|||
}
|
||||
})
|
||||
|
||||
const capture = vi.hoisted(() => ({
|
||||
meetingActive: false,
|
||||
events: [] as string[],
|
||||
}))
|
||||
|
||||
const spies = vi.hoisted(() => ({
|
||||
refreshSession: null as null | ((...args: unknown[]) => Promise<unknown>),
|
||||
signOut: null as null | ((...args: unknown[]) => Promise<unknown>),
|
||||
|
|
@ -141,7 +146,13 @@ vi.mock('../../../src/main/services/VoiceModeService', () => ({
|
|||
getVoiceModeService: () => ({ isActive: false, cancelSession: vi.fn() }),
|
||||
}))
|
||||
vi.mock('../../../src/main/services/MeetingModeService', () => ({
|
||||
getMeetingModeService: () => ({ isMeetingModeActive: () => false, stopRecording: vi.fn() }),
|
||||
getMeetingModeService: () => ({
|
||||
isMeetingModeActive: () => capture.meetingActive,
|
||||
stopRecording: vi.fn(async () => {
|
||||
capture.events.push(`meeting-stopped-in:${h.state.currentUserId}`)
|
||||
capture.meetingActive = false
|
||||
}),
|
||||
}),
|
||||
}))
|
||||
vi.mock('../../../src/main/services/CaptionService', () => ({
|
||||
getCaptionService: () => ({ stop: vi.fn(async () => null) }),
|
||||
|
|
@ -240,6 +251,31 @@ describe('CloudSyncService 세션 복원', () => {
|
|||
expect(outbox.enqueueChange).toHaveBeenCalledWith('history', 'h-offline', 'upsert')
|
||||
})
|
||||
|
||||
it('다른 계정으로 로그인되면 진행 중인 회의를 이전 계정 DB 에서 먼저 끝낸다', async () => {
|
||||
h.state.currentUserId = 'user-0'
|
||||
capture.meetingActive = true
|
||||
capture.events = []
|
||||
writeStoredToken({ rt: 'rt-1', uid: 'user-1' })
|
||||
spies.refreshSession = vi.fn(async () => ({ data: { session: session() }, error: null }))
|
||||
|
||||
await getCloudSyncService().init()
|
||||
|
||||
expect(capture.events).toEqual(['meeting-stopped-in:user-0'])
|
||||
expect(h.state.currentUserId).toBe('user-1')
|
||||
})
|
||||
|
||||
it('같은 계정 복원은 진행 중인 녹음을 건드리지 않는다', async () => {
|
||||
capture.meetingActive = true
|
||||
capture.events = []
|
||||
writeStoredToken({ rt: 'rt-1', uid: 'user-1' })
|
||||
spies.refreshSession = vi.fn(async () => ({ data: { session: session() }, error: null }))
|
||||
|
||||
await getCloudSyncService().init()
|
||||
|
||||
expect(capture.events).toEqual([])
|
||||
capture.meetingActive = false
|
||||
})
|
||||
|
||||
it('나중에 다시 시도해 복원되면 로그인 상태가 된다', async () => {
|
||||
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval'] })
|
||||
writeStoredToken({ rt: 'rt-1', uid: 'user-1' })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue