feat: domain core — schemas, store, equine data, PDF roundtrip
Phase A — Domain & schemas (15 tests): - Zod schemas: ReportSchema, FindingSchema, PractitionerSchema, SeveritySchema - Types derived via z.infer (single source of truth) - newId() helper with optional prefix Phase B — Equine anatomy + pathology DB (7 tests): - 26 macro zones, axial subzones C1-7/T1-18/L1-6/S1-5 - 31 pathologies, each citing Merck Vet Manual, PubMed, IMAIOS or LCAO - Placeholder SVGs (lateral L/R + dorsal) with data-zone convention - Species registry: equine registered, 8 others remain stubs Phase C — Zustand store (8 tests): - Single source of truth with persist middleware (localStorage key osteo-report-draft) - Actions: hydrate, reset, toggleZone, addFinding, updateFinding, removeFinding, setConclusion/Recommendations/NextAppointment Phase H/I — PDF export + import roundtrip (2 tests): - A4 portrait, pdf-lib StandardFonts - Header (practitioner + animal), anatomy pages (per used view), findings table, conclusion/recommendations/RDV page, page footer with date+page# - Attachment: base64 data URI workaround (pdf-lib treats raw string as base64 input, and rejects cross-realm Uint8Array in jsdom tests) - Import: walks Catalog→Names→EmbeddedFiles→Names array→F stream; inflates via pako directly (bypasses pdf-lib's reference-equality FlateDecode check which fails across module realms in vitest); validates with ReportSchema Tooling: - Add pako 2.x + @types/pako (already transitive of pdf-lib) - Switch vitest 2 → 3 (already done in prior commit) - Add 8 test files (34 tests total green)
This commit is contained in:
1 parent
4c465a5743
commit
b5b2e163c9
20 files changed
+1383
-41
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { ReportSchema, SCHEMA_VERSION } from '@/schema/report';
|
||||
|
||||
const sample = {
|
||||
version: 1 as const,
|
||||
id: 'r_abc123',
|
||||
createdAt: '2026-05-17T10:00:00.000Z',
|
||||
species: 'equine' as const,
|
||||
practitioner: {
|
||||
fullName: 'Dr. Doe',
|
||||
},
|
||||
animal: { name: 'Pégase', owner: 'Famille Martin' },
|
||||
sessionDate: '2026-05-17',
|
||||
findings: [],
|
||||
conclusion: '',
|
||||
recommendations: '',
|
||||
};
|
||||
|
||||
describe('ReportSchema', () => {
|
||||
it('exposes schema version 1', () => {
|
||||
expect(SCHEMA_VERSION).toBe(1);
|
||||
});
|
||||
|
||||
it('parses a valid sample', () => {
|
||||
const result = ReportSchema.safeParse(sample);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('rejects missing version', () => {
|
||||
const { version: _v, ...withoutVersion } = sample;
|
||||
const result = ReportSchema.safeParse(withoutVersion);
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects unknown species', () => {
|
||||
const bad = { ...sample, species: 'dinosaur' };
|
||||
const result = ReportSchema.safeParse(bad);
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects empty animal name', () => {
|
||||
const bad = { ...sample, animal: { name: '', owner: 'X' } };
|
||||
const result = ReportSchema.safeParse(bad);
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it('accepts optional nextAppointment', () => {
|
||||
const withNext = { ...sample, nextAppointment: '2026-06-01' };
|
||||
const result = ReportSchema.safeParse(withNext);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user