feat(fc3c): downloads Pinia store + sources.checkNow action + vitests
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -78,4 +78,29 @@ describe('sources store', () => {
|
||||
expect(urls[0]).toContain('/api/artists/autocomplete')
|
||||
expect(urls[0]).toContain('q=al')
|
||||
})
|
||||
|
||||
it('checkNow posts to /api/sources/<id>/check', async () => {
|
||||
const s = useSourcesStore()
|
||||
const calls = []
|
||||
stubFetch((url, init) => {
|
||||
calls.push({ url, method: init?.method, body: init?.body ? JSON.parse(init.body) : null })
|
||||
return { status: 202, body: { download_event_id: 7, status: 'pending' } }
|
||||
})
|
||||
const out = await s.checkNow(5)
|
||||
expect(calls[0].url).toBe('/api/sources/5/check')
|
||||
expect(calls[0].method).toBe('POST')
|
||||
expect(out.download_event_id).toBe(7)
|
||||
})
|
||||
|
||||
it('checkNow exposes the 409 download_event_id via error.body', async () => {
|
||||
const s = useSourcesStore()
|
||||
stubFetch(() => ({ status: 409, body: { download_event_id: 12, status: 'already_running' } }))
|
||||
try {
|
||||
await s.checkNow(5)
|
||||
} catch (e) {
|
||||
expect(e.body?.download_event_id).toBe(12)
|
||||
return
|
||||
}
|
||||
throw new Error('Expected checkNow to throw on 409')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user