feat: typed API client (useApi) and session store (useSession) with the global 401, unverified-403, 429 and offline handling from states.md

This commit is contained in:
fsylvain committed 2026-09-25 17:33:40 +02:00
1 parent eed661bb24
commit 12faab7f92
6 files changed
+488 -6

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import { beforeEach, describe, expect, it } from 'vitest'
import { createPinia, setActivePinia } from 'pinia'
import { useSessionStore } from '@/stores/session'
beforeEach(() => {
setActivePinia(createPinia())
})
describe('session store clear action', () => {
it('resets the session to null and the status to ready regardless of the previous state', () => {
const session = useSessionStore()
session.session = { verified: true }
session.status = 'checking'
session.clear()
expect(session.session).toBeNull()
expect(session.status).toBe('ready')
})
})
+6 -1
View File
@@ -46,5 +46,10 @@ export const useSessionStore = defineStore('session', () => {
return check()
}
return { status, session, check, retry }
function clear() {
session.value = null
status.value = 'ready'
}
return { status, session, check, retry, clear }
})