import { describe, expect, it } from 'vitest' import { decideRefresh } from './session-health' describe('decideRefresh', () => { it('clears the expiry note when the session refreshed', () => { expect(decideRefresh('ok', true)).toBe('clear-expiry') }) it('marks the session expired only when the client said it is gone', () => { expect(decideRefresh('expired', true)).toBe('mark-expired') }) // The distinction this whole policy exists for: a network failure is not a // sign-out, and dropping the session for one loses the two-week window. it('keeps the session when the PDS could not be reached', () => { expect(decideRefresh('unreachable', true)).toBe('retry-later') }) it('never acts on an outcome produced while offline', () => { expect(decideRefresh('expired', false)).toBe('retry-later') expect(decideRefresh('ok', false)).toBe('retry-later') }) })