Enables in-place edit of report identity blocks from the editor. Mirrors existing setConclusion/setRecommendations pattern; no-op when no report is loaded. Co-Authored-By: Claude <noreply@anthropic.com>
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
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()
|
|
})
|
|
})
|