import { describe, it, expect, beforeEach } from 'vitest' import { useReportStore } from '@/state/reportStore' const draft = { date: '2026-05-18', practitioner: { name: 'Dr. Dupont' }, animal: { speciesId: 'equine', name: 'Mistral' }, owner: { name: 'Jean Martin' }, observations: [], conclusion: '', recommendations: '', } beforeEach(() => { useReportStore.getState().reset() }) describe('reportStore identity setters', () => { it('setPractitioner replaces the practitioner block', () => { useReportStore.getState().initReport(draft) useReportStore.getState().setPractitioner({ name: 'Dr. Curie', cabinet: 'Clinique du Pré', contact: 'contact@example.test', }) const p = useReportStore.getState().report!.practitioner expect(p.name).toBe('Dr. Curie') expect(p.cabinet).toBe('Clinique du Pré') expect(p.contact).toBe('contact@example.test') }) it('setAnimal replaces the animal block', () => { useReportStore.getState().initReport(draft) useReportStore.getState().setAnimal({ speciesId: 'equine', name: 'Tempête', breed: 'Pur-sang', }) const a = useReportStore.getState().report!.animal expect(a.name).toBe('Tempête') expect(a.breed).toBe('Pur-sang') }) it('setOwner replaces the owner block', () => { useReportStore.getState().initReport(draft) useReportStore.getState().setOwner({ name: 'Marie Petit' }) expect(useReportStore.getState().report!.owner.name).toBe('Marie Petit') }) it('setters are no-ops when no report is loaded', () => { useReportStore.getState().setPractitioner({ name: 'Ghost' }) useReportStore.getState().setAnimal({ speciesId: 'equine', name: 'Ghost' }) useReportStore.getState().setOwner({ name: 'Ghost' }) expect(useReportStore.getState().report).toBeNull() }) })