clean all

This commit is contained in:
Bastien Chanot committed 2026-05-18 19:40:08 +02:00
1 parent f57d6ec3d3
commit 27afb719f5
101 files changed
+45 -14426

No files matched your search

-75
View File
@@ -1,75 +0,0 @@
import { describe, expect, it } from 'vitest';
import { exportReportBytes, type AnatomyAssets } from '@/pdf/export';
import { importReport } from '@/pdf/import';
import { EQUINE_ANATOMY } from '@/species/equine/anatomy';
// 1×1 transparent PNG as Uint8Array
const TINY_PNG = Uint8Array.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4,
0x89, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
0x42, 0x60, 0x82,
]);
const assets: AnatomyAssets = {
anatomy: EQUINE_ANATOMY,
rasters: {
lateral_left: TINY_PNG,
lateral_right: TINY_PNG,
dorsal: TINY_PNG,
},
};
const sampleReport = {
version: 1 as const,
id: 'r_roundtrip',
createdAt: '2026-05-17T10:00:00.000Z',
species: 'equine' as const,
practitioner: {
fullName: 'Dr. Test',
phone: '0102030405',
email: 'test@example.com',
},
animal: { name: 'Pégase', owner: 'Famille Martin' },
sessionDate: '2026-05-17',
findings: [
{
id: 'finding_1',
zones: ['thoracic-back'],
linkedZones: ['lumbar'],
pathologies: [{ id: 'eq_kissing_spines', label: 'Kissing spines', free: false }],
severity: 'moderate' as const,
comment: 'Sensibilité marquée en flexion latérale.',
},
],
conclusion: 'Tableau de dysfonction dorsale.',
recommendations: 'Repos 7 jours, séance de contrôle à 3 semaines.',
nextAppointment: '2026-06-07',
};
describe('PDF roundtrip', () => {
it('exports then imports back equal report', async () => {
const bytes = await exportReportBytes(sampleReport, assets);
expect(bytes.byteLength).toBeGreaterThan(0);
expect(new TextDecoder().decode(bytes.slice(0, 5))).toBe('%PDF-');
const result = await importReport(bytes);
expect(result.ok).toBe(true);
if (result.ok) {
expect(result.report).toEqual(sampleReport);
}
});
it('rejects a PDF without our attachment', async () => {
// Build a tiny PDF with no attachment using pdf-lib
const { PDFDocument } = await import('pdf-lib');
const pdf = await PDFDocument.create();
pdf.addPage();
const bytes = await pdf.save();
const result = await importReport(bytes);
expect(result.ok).toBe(false);
if (!result.ok) expect(result.reason).toBe('NO_ATTACHMENT');
});
});