refactor(anatomy): adapt parser to new SVG convention (categories + single-element)
User dropped new Horse.svg / Horse_head.svg that follow a simpler
convention:
- Categories renamed to longer human strings:
articulation → articulations
charniere → charni-res-vert-brales
spine-zone → zone-colonne
cadran-crane → cadrans-du-cr-ne
head, os-overlay → dropped (head zone is now category="os" + data-anno-opens-detail)
os → unchanged
- No more hitbox / visible class split; multiple elements may still share
the same data-anno-id but they all carry the same role.
- Trigger-only zones (`data-anno-opens-detail="head"`) may omit
`data-anno-name-fr/en`.
Changes:
- `Bone` now exposes a single `els: Element[]` instead of `hitboxEls +
visibleEls`.
- `parseSvgBones` accepts annotations without fr/en labels (defaults to
empty string) but still rejects unknown or missing categories.
- The "interactive vs decorative" filter is gone — every parsed
annotation is interactive, since the new SVGs only annotate the
clickable zones.
- Vertebra-picker trigger: `bone.category === 'zone-colonne'`
(EditorRoute + ObservationCard).
- PDF colorisation in `observationPage.colorizedSvgString` writes the
accent fill to every `els[]` entry (no more hitbox dual-pass).
- Dead `src/components/observation/ObservationEditor.tsx` removed (its
body lives inside ObservationCard since the accordion refactor).
- Tests rewritten for the new vocabulary; synthetic fixture uses the new
categories, real-SVG test asserts 18 + 9 unique zones.
92/92 tests pass, lint clean, build clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1109e33383
commit
cad94a49db
10 files changed
+325
-428
No files matched your search
@@ -18,41 +18,55 @@ function loadSvg(path: string): SVGSVGElement {
|
||||
describe('real Horse.svg', () => {
|
||||
const map = parseSvgBones(loadSvg(HORSE_PATH))
|
||||
|
||||
it('parses without throwing', () => {
|
||||
expect(map.size).toBeGreaterThan(10)
|
||||
it('parses 18 unique annotations', () => {
|
||||
expect(map.size).toBe(18)
|
||||
})
|
||||
|
||||
it('contains all 5 spine-zone bones', () => {
|
||||
const spine = [...map.values()].filter((b) => b.category === 'spine-zone')
|
||||
it('contains 5 zone-colonne annotations (cervical / thoracic / lumbar / sacral / caudal)', () => {
|
||||
const spine = [...map.values()].filter(
|
||||
(b) => b.category === 'zone-colonne',
|
||||
)
|
||||
expect(spine.length).toBe(5)
|
||||
})
|
||||
|
||||
it('contains the head zone with opensDetail=head', () => {
|
||||
const head = [...map.values()].find((b) => b.category === 'head')
|
||||
expect(head?.opensDetail).toBe('head')
|
||||
it('contains exactly one opens-detail trigger pointing at the head SVG', () => {
|
||||
const triggers = [...map.values()].filter((b) => b.opensDetail === 'head')
|
||||
expect(triggers.length).toBe(1)
|
||||
})
|
||||
|
||||
it('contains the 3 vertebral hinges', () => {
|
||||
const charn = [...map.values()].filter((b) => b.category === 'charniere')
|
||||
expect(charn.map((b) => b.id).sort()).toEqual(['c7-t1', 'l6-s1', 't18-l1'])
|
||||
it('contains 9 articulations', () => {
|
||||
const arts = [...map.values()].filter(
|
||||
(b) => b.category === 'articulations',
|
||||
)
|
||||
expect(arts.length).toBe(9)
|
||||
})
|
||||
|
||||
it('contains main joint articulations', () => {
|
||||
for (const id of ['epaule', 'coude', 'hanche', 'grasset', 'jarret']) {
|
||||
expect(map.get(id)?.category).toBe('articulation')
|
||||
}
|
||||
it('contains 3 vertebral hinges', () => {
|
||||
const ch = [...map.values()].filter(
|
||||
(b) => b.category === 'charni-res-vert-brales',
|
||||
)
|
||||
expect(ch.length).toBe(3)
|
||||
})
|
||||
})
|
||||
|
||||
describe('real Horse_head.svg', () => {
|
||||
const map = parseSvgBones(loadSvg(HEAD_PATH))
|
||||
|
||||
it('parses without throwing', () => {
|
||||
expect(map.size).toBeGreaterThan(5)
|
||||
it('parses 9 unique annotations', () => {
|
||||
expect(map.size).toBe(9)
|
||||
})
|
||||
|
||||
it('contains cadran-crane categories', () => {
|
||||
const cadran = [...map.values()].filter((b) => b.category === 'cadran-crane')
|
||||
expect(cadran.length).toBeGreaterThan(0)
|
||||
it('contains 5 cadrans-du-cr-ne annotations', () => {
|
||||
const cadrans = [...map.values()].filter(
|
||||
(b) => b.category === 'cadrans-du-cr-ne',
|
||||
)
|
||||
expect(cadrans.length).toBe(5)
|
||||
})
|
||||
|
||||
it('contains 2 articulations (ATM + SSB equivalents)', () => {
|
||||
const arts = [...map.values()].filter(
|
||||
(b) => b.category === 'articulations',
|
||||
)
|
||||
expect(arts.length).toBe(2)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user