test: replacement coverage for the deleted legacy suites (v3 schema rejections, appointment kinds, i18n keys and placeholders, pickLocaleLabel, region mapping, new report route); importer comment
This commit is contained in:
1 parent
09d8b01a54
commit
06a2e86f3c
5 files changed
+242
-1
No files matched your search
@@ -0,0 +1,118 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
AnimalSchema,
|
||||
FindingSchema,
|
||||
LateralSideSchema,
|
||||
ObservationSchema,
|
||||
PractitionerSchema,
|
||||
ReportSchema,
|
||||
ReportZoneSchema,
|
||||
SeveritySchema,
|
||||
VertebraSchema,
|
||||
} from '../src'
|
||||
|
||||
const finding = {
|
||||
findingZoneId: 'z',
|
||||
path: ['a'],
|
||||
labelFrSnapshot: 'a',
|
||||
labelEnSnapshot: 'a',
|
||||
}
|
||||
const observation = {
|
||||
id: 'o1',
|
||||
zones: [],
|
||||
findings: [],
|
||||
freeTextFindings: [],
|
||||
comment: '',
|
||||
}
|
||||
const report = {
|
||||
version: 3,
|
||||
id: 'r1',
|
||||
createdAt: '2026-10-01T00:00:00Z',
|
||||
date: '2026-10-01',
|
||||
practitioner: { name: 'P' },
|
||||
animal: { speciesId: 'equine', name: 'A' },
|
||||
owner: { name: 'O' },
|
||||
sheet: { sheetId: 's', versionId: null, documentSha256: 'a'.repeat(64) },
|
||||
observations: [],
|
||||
conclusion: '',
|
||||
recommendations: '',
|
||||
}
|
||||
|
||||
describe('report v3 leaf schemas', () => {
|
||||
it('FindingSchema rejects empty path and empty findingZoneId', () => {
|
||||
expect(FindingSchema.safeParse(finding).success).toBe(true)
|
||||
expect(FindingSchema.safeParse({ ...finding, path: [] }).success).toBe(
|
||||
false,
|
||||
)
|
||||
expect(
|
||||
FindingSchema.safeParse({ ...finding, findingZoneId: '' }).success,
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('LateralSideSchema rejects both and empty', () => {
|
||||
expect(LateralSideSchema.safeParse('left').success).toBe(true)
|
||||
expect(LateralSideSchema.safeParse('both').success).toBe(false)
|
||||
expect(LateralSideSchema.safeParse('').success).toBe(false)
|
||||
})
|
||||
|
||||
it('VertebraSchema rejects index 0 and non-integer index', () => {
|
||||
expect(VertebraSchema.safeParse({ region: 'C', index: 1 }).success).toBe(
|
||||
true,
|
||||
)
|
||||
expect(VertebraSchema.safeParse({ region: 'C', index: 0 }).success).toBe(
|
||||
false,
|
||||
)
|
||||
expect(VertebraSchema.safeParse({ region: 'C', index: 1.5 }).success).toBe(
|
||||
false,
|
||||
)
|
||||
})
|
||||
|
||||
it('ObservationSchema rejects an empty id', () => {
|
||||
expect(ObservationSchema.safeParse(observation).success).toBe(true)
|
||||
expect(ObservationSchema.safeParse({ ...observation, id: '' }).success).toBe(
|
||||
false,
|
||||
)
|
||||
})
|
||||
|
||||
it('SeveritySchema accepts the three codes only', () => {
|
||||
for (const c of ['mild', 'moderate', 'severe'])
|
||||
expect(SeveritySchema.safeParse(c).success).toBe(true)
|
||||
expect(SeveritySchema.safeParse('légère').success).toBe(false)
|
||||
expect(SeveritySchema.safeParse('unknown').success).toBe(false)
|
||||
})
|
||||
|
||||
it('ReportZoneSchema rejects an empty annotationId', () => {
|
||||
const zone = { annotationId: 'a', viewId: 'main' }
|
||||
expect(ReportZoneSchema.safeParse(zone).success).toBe(true)
|
||||
expect(
|
||||
ReportZoneSchema.safeParse({ ...zone, annotationId: '' }).success,
|
||||
).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('report v3 document and identity', () => {
|
||||
it('ReportSchema validates nextAppointment variants', () => {
|
||||
const date = { kind: 'date', date: '2026-11-01' }
|
||||
const period = { kind: 'period', text: 'dans 3 semaines' }
|
||||
expect(
|
||||
ReportSchema.safeParse({ ...report, nextAppointment: date }).success,
|
||||
).toBe(true)
|
||||
expect(
|
||||
ReportSchema.safeParse({ ...report, nextAppointment: period }).success,
|
||||
).toBe(true)
|
||||
expect(
|
||||
ReportSchema.safeParse({ ...report, nextAppointment: { kind: 'other' } })
|
||||
.success,
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('PractitionerSchema rejects an empty name', () => {
|
||||
expect(PractitionerSchema.safeParse({ name: '' }).success).toBe(false)
|
||||
})
|
||||
|
||||
it('AnimalSchema rejects an empty speciesId', () => {
|
||||
expect(AnimalSchema.safeParse({ speciesId: '', name: 'A' }).success).toBe(
|
||||
false,
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user