This commit is contained in:
2026-10-24 16:34:02 +08:00
parent 99e5687ce0
commit 7119e04a65
24 changed files with 553 additions and 39 deletions
+14
View File
@@ -25,6 +25,20 @@ describe('Profiles Store', () => {
vi.clearAllMocks()
})
it('shares an in-flight profile request and allows later refreshes', async () => {
let resolve!: (value: any[]) => void
mockProfilesApi.fetchProfiles.mockReturnValue(new Promise(done => { resolve = done }))
const store = useProfilesStore()
const first = store.fetchProfiles()
const second = store.fetchProfiles()
expect(mockProfilesApi.fetchProfiles).toHaveBeenCalledOnce()
resolve([])
await Promise.all([first, second])
mockProfilesApi.fetchProfiles.mockResolvedValue([])
await store.fetchProfiles()
expect(mockProfilesApi.fetchProfiles).toHaveBeenCalledTimes(2)
})
it('fetchProfiles loads profiles and sets active', async () => {
const profiles = [
{ name: 'default', active: true, model: 'gpt-4', alias: '' },