ObservationSchema now carries a hierarchical Finding (zoneId + path + labelFrSnapshot + labelEnSnapshot + requiresVetReferral?) plus a renamed freeTextFindings list, replacing the flat pathologyIds / freeTextPathologies pair. Snapshot labels keep already-exported reports readable if the catalog is later edited. ReportSchema.version bumped from 1 → 2. PDF import surfaces a distinct, French-language error message on legacy v1 attachments instead of the generic "not an osteo PDF" line, via a new IncompatibleReportVersionError detected before the strict Zod parse runs. Store seed and tests updated for the new shape. The standalone Pathology Zod schema and its test are removed — the new findings tree is the single source of truth for what an observation can carry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { ReportSchema } from '@/domain/schema/report'
|
|
import { generateId } from '@/lib/id'
|
|
import { todayIso, nowIso } from '@/lib/dates'
|
|
import { assert } from '@/lib/assert'
|
|
|
|
describe('skeleton smoke test', () => {
|
|
it('generates a non-empty id', () => {
|
|
const id = generateId()
|
|
expect(typeof id).toBe('string')
|
|
expect(id.length).toBeGreaterThan(0)
|
|
})
|
|
|
|
it('todayIso returns an ISO date string', () => {
|
|
const today = todayIso()
|
|
expect(today).toMatch(/^\d{4}-\d{2}-\d{2}$/)
|
|
})
|
|
|
|
it('nowIso returns an ISO timestamp string', () => {
|
|
const now = nowIso()
|
|
expect(now).toMatch(/^\d{4}-\d{2}-\d{2}T/)
|
|
})
|
|
|
|
it('ReportSchema parses a valid minimal report', () => {
|
|
const validReport = {
|
|
version: 2 as const,
|
|
id: generateId(),
|
|
createdAt: nowIso(),
|
|
date: todayIso(),
|
|
practitioner: { name: 'Dr. Dupont' },
|
|
animal: { speciesId: 'equine', name: 'Mistral' },
|
|
owner: { name: 'Jean Martin' },
|
|
observations: [],
|
|
conclusion: '',
|
|
recommendations: '',
|
|
}
|
|
|
|
const result = ReportSchema.safeParse(validReport)
|
|
expect(result.success).toBe(true)
|
|
})
|
|
|
|
it('ReportSchema rejects a report missing required fields', () => {
|
|
const invalid = { version: 1, id: '' }
|
|
const result = ReportSchema.safeParse(invalid)
|
|
expect(result.success).toBe(false)
|
|
})
|
|
|
|
it('assert passes when condition is truthy', () => {
|
|
expect(() => assert(true, 'should not throw')).not.toThrow()
|
|
})
|
|
|
|
it('assert throws when condition is falsy', () => {
|
|
expect(() => assert(false, 'boom')).toThrow('Assertion failed: boom')
|
|
})
|
|
})
|