CI and images / lint (push) Successful in 2s
CI and images / extension-version (push) Successful in 2s
CI and images / frontend-build (push) Successful in 20s
CI and images / backend-lint-and-test (push) Successful in 30s
CI and images / integration (push) Successful in 2m18s
CI and images / sign-extension (push) Successful in 3s
CI and images / build-agent (push) Successful in 6s
CI and images / build-web (push) Successful in 1m44s
CI and images / smoke-web (push) Successful in 56s
CI and images / promote (push) Skipped
tests/factories.py holds image_row/make_image/make_image_async/make_tag. The 17 byte-identical _img/_tag helpers (15 modules) now import them under their old names, so no call site changed. frontend/test/support/stubFetch.js replaces 15 copies that differed only in formatting. Copies whose bodies differ (other defaults, other columns, a url-only stub) are left as they are; folding those needs a look at each caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjrnpQjRgHdvq95rASoiR
66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
import { setActivePinia, createPinia } from 'pinia'
|
|
import { useDownloadsStore } from '../src/stores/downloads.js'
|
|
import { stubFetch } from './support/stubFetch.js'
|
|
|
|
describe('downloads store', () => {
|
|
beforeEach(() => setActivePinia(createPinia()))
|
|
afterEach(() => vi.restoreAllMocks())
|
|
|
|
it('loadFirst populates events and cursor', async () => {
|
|
const s = useDownloadsStore()
|
|
stubFetch(() => ({
|
|
status: 200,
|
|
body: [
|
|
{ id: 10, status: 'ok', summary: {} },
|
|
{ id: 9, status: 'error', summary: {} },
|
|
],
|
|
}))
|
|
await s.loadFirst()
|
|
expect(s.events.map(e => e.id)).toEqual([10, 9])
|
|
expect(s.cursor).toBe(9)
|
|
expect(s.hasMore).toBe(false)
|
|
})
|
|
|
|
it('loadMore appends and updates cursor', async () => {
|
|
const s = useDownloadsStore()
|
|
s.events = [{ id: 10, summary: {} }, { id: 9, summary: {} }]
|
|
s.cursor = 9
|
|
s.hasMore = true
|
|
stubFetch(() => ({
|
|
status: 200,
|
|
body: [{ id: 8, status: 'ok', summary: {} }],
|
|
}))
|
|
await s.loadMore()
|
|
expect(s.events.map(e => e.id)).toEqual([10, 9, 8])
|
|
expect(s.cursor).toBe(8)
|
|
})
|
|
|
|
it('applyFilter merges and reloads', async () => {
|
|
const s = useDownloadsStore()
|
|
const urls = []
|
|
stubFetch((url) => {
|
|
urls.push(url)
|
|
return { status: 200, body: [] }
|
|
})
|
|
await s.applyFilter({ status: 'error' })
|
|
expect(s.filter.status).toBe('error')
|
|
expect(urls[0]).toContain('status=error')
|
|
})
|
|
|
|
it('loadOne populates selected', async () => {
|
|
const s = useDownloadsStore()
|
|
stubFetch(() => ({ status: 200, body: { id: 42, metadata: { run_stats: {} } } }))
|
|
const out = await s.loadOne(42)
|
|
expect(s.selected.id).toBe(42)
|
|
expect(out.id).toBe(42)
|
|
})
|
|
|
|
it('closeDetail clears selected', async () => {
|
|
const s = useDownloadsStore()
|
|
s.selected = { id: 1 }
|
|
s.closeDetail()
|
|
expect(s.selected).toBe(null)
|
|
})
|
|
})
|