// @vitest-environment happy-dom import { describe, it, expect } from 'vitest' import BackupRunsTable from '../../src/components/settings/BackupRunsTable.vue' import { mountComponent } from '../support/mountComponent.js' const MEDIA_RUN = { id: 7, kind: 'media', status: 'ok', started_at: new Date().toISOString(), duration_seconds: 90, size_bytes: 2048, error: "3 file(s) weren't sent; the next run tries them again.", offsite: { bucket: 'curator', endpoint: 'http://archives.example', key: 'media/' }, manifest: { failed: 3, failures: [ { path: '/images/a/one.jpg', error: 'HTTP 503: busy.' }, { path: '/images/b/two.zip', error: 'OSError: gone' }, ], }, } describe('BackupRunsTable', () => { it('offers a run\'s failed files, counted in full', () => { const w = mountComponent(BackupRunsTable, { props: { runs: [MEDIA_RUN] } }) expect(w.text()).toContain('3 files failed') expect(w.text()).not.toContain('/images/a/one.jpg') }) it('lists each failed file with why once opened, and says how many more', async () => { const w = mountComponent(BackupRunsTable, { props: { runs: [MEDIA_RUN] } }) await w.find('v-btn').trigger('click') const t = w.text() expect(t).toContain('/images/a/one.jpg') expect(t).toContain('HTTP 503: busy.') expect(t).toContain('/images/b/two.zip') expect(t).toContain('and 1 more.') }) it('shows no failure button on a clean run', () => { const clean = { ...MEDIA_RUN, id: 8, error: null, manifest: { failed: 0, failures: [] } } const w = mountComponent(BackupRunsTable, { props: { runs: [clean] } }) expect(w.text()).not.toContain('failed') }) })