// @vitest-environment happy-dom import { describe, it, expect } from 'vitest' import BackupTestSection from '../../src/components/settings/BackupTestSection.vue' import { useBackupStore } from '../../src/stores/backup.js' import { mountWithStore } from '../support/mountComponent.js' const FINISHED = { id: 9, kind: 'test', status: 'error', started_at: new Date().toISOString(), finished_at: new Date().toISOString(), duration_seconds: 300, size_bytes: 2048, error: '1 table(s) came back different: post (7 in the dump, 6 restored).', offsite: null, manifest: { phase: 'done', dump: { ts: '20261107T030000Z' }, summary: '1 table(s) came back different: post (7 in the dump, 6 restored).', counted: true, mismatched: ['post'], alembic_dump: '0120', alembic_now: '0121', tables: [ { table: 'artist', dump: 10, restored: 10, live: 12 }, { table: 'post', dump: 7, restored: 6, live: 7 }, ], }, } function mount(runs) { return mountWithStore(BackupTestSection, () => { useBackupStore().testRuns = runs }, { props: { bucket: 'curator' } }) } describe('BackupTestSection', () => { it('leads with the last test\'s verdict and how its schema was brought up', () => { const t = mount([FINISHED]).text() expect(t).toContain('Last test') expect(t).toContain('post (7 in the dump, 6 restored)') expect(t).toContain('brought up from 0120 to 0121') expect(t).not.toContain('artist') }) it('lists every table on request, with the dump, restored and live counts', async () => { const w = mount([FINISHED]) const btn = w.findAll('v-btn').find((b) => b.text().includes('each table')) await btn.trigger('click') const rows = w.findAll('tr').filter((r) => r.text().includes('post')) expect(rows.some((r) => r.classes().includes('text-error'))).toBe(true) expect(w.text()).toContain('artist') }) it('says what a running test is doing', () => { const running = { ...FINISHED, id: 10, status: 'running', finished_at: null, error: null, manifest: { phase: 'loading', dump: { ts: '20261107T030000Z' } }, } const t = mount([running, FINISHED]).text() expect(t).toContain('loading it into a temporary database') }) })