feat(app): application on the canonical sheet — report v3 store with v2 draft migration, bundled SheetProvider (SHEET_BUNDLE), annotation layer rendered from the document, zone interaction service, pickers and cards on the sheet index, PDF v3 export with v2 archive import; legacy registry, matchers, editors and assets removed
This commit is contained in:
1 parent
0a17e390cf
commit
ce2ec26112
114 files changed
+3560
-14637
No files matched your search
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* Replaces anatomy.horse / char.svgCatalogLink: the bundled reference sheet
|
||||
* loads, validates, and indexes as the canonical document says.
|
||||
*/
|
||||
import { beforeAll, describe, expect, it } from 'vitest'
|
||||
import { bundledSheetProvider } from '@/sheets/provider'
|
||||
import {
|
||||
buildSheetIndex,
|
||||
isObservable,
|
||||
pickLabel,
|
||||
type SheetIndex,
|
||||
} from '@/services/sheetIndex'
|
||||
import { loadTestSheet } from '../helpers/sheet'
|
||||
|
||||
let sheet: SheetIndex
|
||||
beforeAll(async () => {
|
||||
sheet = await loadTestSheet()
|
||||
})
|
||||
|
||||
describe('bundled sheet provider', () => {
|
||||
it('returns the equine draft with its reference, assets and migration map', async () => {
|
||||
const loaded = await bundledSheetProvider.getReferenceSheet('equine')
|
||||
expect(loaded).not.toBeNull()
|
||||
expect(loaded!.status).toBe('draft')
|
||||
expect(loaded!.speciesId).toBe('equine')
|
||||
expect(loaded!.ref.documentSha256).toMatch(/^[0-9a-f]{64}$/)
|
||||
expect(loaded!.ref.versionId).toBeNull()
|
||||
expect(loaded!.migrationMap.sheet).toEqual(loaded!.ref)
|
||||
expect(Object.keys(loaded!.assets)).toHaveLength(1)
|
||||
expect(loaded!.assets[loaded!.document.views[0]!.svg_asset_id!]).toContain(
|
||||
'<svg',
|
||||
)
|
||||
expect(await bundledSheetProvider.getReferenceSheet('canine')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('sheet index', () => {
|
||||
it('exposes the views, 28 annotations (27 observable), 27 finding zones and 5 regions', () => {
|
||||
const { document } = sheet.sheet
|
||||
expect(sheet.mainView.id).toBe('main')
|
||||
expect(sheet.view('head')).toMatchObject({
|
||||
kind: 'detail',
|
||||
parent_view_id: 'main',
|
||||
svg_asset_id: null,
|
||||
})
|
||||
expect(document.annotations).toHaveLength(28)
|
||||
expect(document.annotations.filter(isObservable)).toHaveLength(27)
|
||||
expect(sheet.annotationsOfView('head')).toHaveLength(9)
|
||||
expect(sheet.annotationsOfView('main')).toHaveLength(19)
|
||||
expect(document.finding_zones).toHaveLength(27)
|
||||
expect(sheet.regions().map((r) => r.code)).toEqual([
|
||||
'C',
|
||||
'T',
|
||||
'L',
|
||||
'S',
|
||||
'Cd',
|
||||
])
|
||||
expect(sheet.region('Cd')).toMatchObject({
|
||||
count: 18,
|
||||
count_range: { min: 15, max: 21 },
|
||||
})
|
||||
})
|
||||
|
||||
it('links every observable annotation to an existing finding zone, the trigger to the head view', () => {
|
||||
for (const a of sheet.sheet.document.annotations) {
|
||||
if (!isObservable(a)) {
|
||||
expect(a.opens_view_id).toBe('head')
|
||||
continue
|
||||
}
|
||||
expect(a.finding_zone_id, a.id).not.toBeNull()
|
||||
expect(sheet.findingZone(a.finding_zone_id!), a.id).toBeDefined()
|
||||
}
|
||||
expect(sheet.spineAnnotation('C', 'main')?.id).toBe('cervical')
|
||||
expect(sheet.spineAnnotation('C', 'head')).toBeUndefined()
|
||||
expect(sheet.isSpine('cervical')).toBe(true)
|
||||
expect(sheet.isSpine('hip')).toBe(false)
|
||||
expect(sheet.isSpine('head-trigger')).toBe(false)
|
||||
})
|
||||
|
||||
it('resolves finding paths and reports absent ones', () => {
|
||||
expect(
|
||||
sheet.nodeAt('hip', [
|
||||
'hip-dysfunctions',
|
||||
'articular',
|
||||
'restriction-flexion',
|
||||
])?.name.fr,
|
||||
).toBe('Restriction en flexion')
|
||||
expect(sheet.nodeAt('hip', ['hip-dysfunctions'])?.name.fr).toBe(
|
||||
'Dysfonctions ostéopathiques',
|
||||
)
|
||||
expect(
|
||||
sheet.nodeAt('cervical', [
|
||||
'cervical-observations',
|
||||
'stumbling-proprioceptive',
|
||||
]),
|
||||
).toBeUndefined()
|
||||
expect(sheet.nodeAt('nowhere', ['x'])).toBeUndefined()
|
||||
expect(sheet.nodeAt('hip', [])).toBeUndefined()
|
||||
})
|
||||
|
||||
it('names annotations and triggers in both locales', () => {
|
||||
expect(pickLabel(sheet.name(sheet.annotation('hip')!), 'fr')).toBe(
|
||||
'Hanche (coxo-fémorale)',
|
||||
)
|
||||
expect(pickLabel(sheet.name(sheet.annotation('hip')!), 'en')).toBe(
|
||||
'Hip joint',
|
||||
)
|
||||
expect(pickLabel(sheet.name(sheet.annotation('head-trigger')!), 'en')).toBe(
|
||||
'Head (left lateral view)',
|
||||
)
|
||||
expect(buildSheetIndex(sheet.sheet).mainView).toEqual(sheet.mainView)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user