fix(cloud-sync): drop the previous account's cached tier when signing in as someone else
Switching accounts without a sign-out skipped resetToFree, and if the subscription lookup then failed the new account kept the old one's Pro badge and ad decision, persisted across restarts.
This commit is contained in:
parent
6fef05a39f
commit
9cf3fd7317
2 changed files with 31 additions and 2 deletions
|
|
@ -53,6 +53,7 @@ const h = vi.hoisted(() => {
|
|||
const capture = vi.hoisted(() => ({
|
||||
meetingActive: false,
|
||||
events: [] as string[],
|
||||
license: [] as string[],
|
||||
}))
|
||||
|
||||
const spies = vi.hoisted(() => ({
|
||||
|
|
@ -140,7 +141,10 @@ vi.mock('../../../src/main/services/sync/settings-sync', () => ({
|
|||
vi.mock('../../../src/main/services/sync/audio-sync', () => ({ AUDIO_BUCKET: 'audio', listLocalAudioOwners: () => [] }))
|
||||
vi.mock('../../../src/main/windows/web-contents-hardening', () => ({ openExternalSafe: vi.fn(async () => true) }))
|
||||
vi.mock('../../../src/main/services/LicenseService', () => ({
|
||||
getLicenseService: () => ({ syncFromCloud: vi.fn(), resetToFree: vi.fn() }),
|
||||
getLicenseService: () => ({
|
||||
syncFromCloud: vi.fn(() => capture.license.push('sync')),
|
||||
resetToFree: vi.fn(() => capture.license.push('reset')),
|
||||
}),
|
||||
}))
|
||||
vi.mock('../../../src/main/services/VoiceModeService', () => ({
|
||||
getVoiceModeService: () => ({ isActive: false, cancelSession: vi.fn() }),
|
||||
|
|
@ -264,6 +268,27 @@ describe('CloudSyncService 세션 복원', () => {
|
|||
expect(h.state.currentUserId).toBe('user-1')
|
||||
})
|
||||
|
||||
it('다른 계정으로 로그인되면 티어 조회 전에 이전 계정의 캐시 티어를 버린다', async () => {
|
||||
h.state.currentUserId = 'user-0'
|
||||
capture.license = []
|
||||
writeStoredToken({ rt: 'rt-1', uid: 'user-1' })
|
||||
spies.refreshSession = vi.fn(async () => ({ data: { session: session() }, error: null }))
|
||||
|
||||
await getCloudSyncService().init()
|
||||
|
||||
expect(capture.license[0]).toBe('reset')
|
||||
})
|
||||
|
||||
it('같은 계정 복원은 캐시 티어를 버리지 않는다(오프라인이면 그대로 쓴다)', async () => {
|
||||
capture.license = []
|
||||
writeStoredToken({ rt: 'rt-1', uid: 'user-1' })
|
||||
spies.refreshSession = vi.fn(async () => ({ data: { session: session() }, error: null }))
|
||||
|
||||
await getCloudSyncService().init()
|
||||
|
||||
expect(capture.license).not.toContain('reset')
|
||||
})
|
||||
|
||||
it('같은 계정 복원은 진행 중인 녹음을 건드리지 않는다', async () => {
|
||||
capture.meetingActive = true
|
||||
capture.events = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue