++
This commit is contained in:
@@ -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: '' },
|
||||
|
||||
Reference in New Issue
Block a user