From b67f4cd82b1291e7b7342804416eb45eb1c255e1 Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Wed, 20 May 2026 03:49:11 +0200 Subject: [PATCH] feat(editor): findings tree picker + scope disclaimer + PDF render MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the flat PathologyPicker with FindingsTreePicker — breadcrumb navigation, drill into intermediate categories, toggle leaves, optional vet-referral badge, optional description rendering. One picker per zone that has a catalog entry; zones without a tree fall back to the free-text input (renamed FreeTextFindingInput to match the new vocabulary). EditorRoute now loads SpeciesFindings instead of a Pathology[] and shows the scope_disclaimer once per session via a sessionStorage flag so the practitioner is reminded of the legal perimeter the first time. PDF observationPage renders findings via the snapshotted FR label and prefixes ⚠ on vet-referral items, keeping the existing layout pipeline intact (LRN-007/008/009 still apply). Also drops the unused Toast and ZoneTooltip stubs, refreshes the CLAUDE.md folder map, and adds a FindingsTreePicker test covering navigation, leaf toggle, vet-referral flag, and back-out. Co-Authored-By: Claude Opus 4.7 (1M context) --- CLAUDE.md | 14 +- src/app/routes/EditorRoute.tsx | 42 +++- src/components/canvas/ZoneTooltip.tsx | 3 - .../observation/FindingsTreePicker.tsx | 208 ++++++++++++++++++ ...logyInput.tsx => FreeTextFindingInput.tsx} | 24 +- .../observation/ObservationCard.tsx | 81 ++++--- .../observation/ObservationList.tsx | 11 +- .../observation/PathologyPicker.tsx | 65 ------ src/components/ui/Toast.tsx | 3 - src/pdf/render/observationPage.ts | 14 +- .../components.FindingsTreePicker.test.tsx | 137 ++++++++++++ .../unit/components.PathologyPicker.test.tsx | 57 ----- 12 files changed, 473 insertions(+), 186 deletions(-) delete mode 100644 src/components/canvas/ZoneTooltip.tsx create mode 100644 src/components/observation/FindingsTreePicker.tsx rename src/components/observation/{FreeTextPathologyInput.tsx => FreeTextFindingInput.tsx} (73%) delete mode 100644 src/components/observation/PathologyPicker.tsx delete mode 100644 src/components/ui/Toast.tsx create mode 100644 tests/unit/components.FindingsTreePicker.test.tsx delete mode 100644 tests/unit/components.PathologyPicker.test.tsx diff --git a/CLAUDE.md b/CLAUDE.md index d3f57e8f..f8e3070c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -121,11 +121,11 @@ osteo/ │ │ │ ├─ observation.ts │ │ │ ├─ practitioner.ts │ │ │ ├─ animal.ts -│ │ │ └─ pathology.ts +│ │ │ └─ findings.ts │ │ └─ species/ │ │ ├─ types.ts ← SpeciesManifest interface │ │ ├─ registry.ts ← getSpecies(), getAllSpecies() -│ │ └─ equine/{index,vertebrae,pathologies}.ts +│ │ └─ equine/{index,vertebrae,pathologies}.{ts,json} │ ├─ state/ │ │ ├─ reportStore.ts ← Zustand store │ │ └─ practitionerCache.ts ← localStorage prefill @@ -134,11 +134,11 @@ osteo/ │ │ ├─ svgConvention.ts ← parseSvgBones() │ │ └─ svgLoader.ts ← loadSvg(), svgToPngDataUrl() │ ├─ components/ -│ │ ├─ ui/{Button,Card,Dialog,Input,Label,Select,Textarea,Badge,Chip,Toast}.tsx -│ │ ├─ canvas/{AnatomyCanvas,DetailModal,ZoneTooltip}.tsx -│ │ ├─ observation/{ObservationList,ObservationCard,ObservationEditor, -│ │ │ PathologyPicker,VertebraPicker,SeveritySelector, -│ │ │ FreeTextPathologyInput}.tsx +│ │ ├─ ui/{Button,Card,Dialog,Input,Label,Select,Textarea,Badge,Chip}.tsx +│ │ ├─ canvas/{AnatomyCanvas,DetailModal}.tsx +│ │ ├─ observation/{ObservationList,ObservationCard,FindingsTreePicker, +│ │ │ VertebraPicker,SeveritySelector, +│ │ │ FreeTextFindingInput}.tsx │ │ ├─ report/{ReportHeader,PractitionerForm,AnimalForm, │ │ │ ConclusionPanel,NextAppointmentPicker}.tsx │ │ └─ brand/Brand.tsx diff --git a/src/app/routes/EditorRoute.tsx b/src/app/routes/EditorRoute.tsx index fcc56144..5403bf65 100644 --- a/src/app/routes/EditorRoute.tsx +++ b/src/app/routes/EditorRoute.tsx @@ -19,11 +19,13 @@ import { loadSvg } from '@/anatomy/svgLoader' import { parseSvgBones } from '@/anatomy/svgConvention' import type { Bone, BoneState } from '@/anatomy/types' import type { Observation, ObservationZone } from '@/domain/schema/observation' -import type { Pathology } from '@/domain/schema/pathology' +import type { SpeciesFindings } from '@/domain/schema/findings' import type { Practitioner } from '@/domain/schema/practitioner' import type { Animal, Owner } from '@/domain/schema/animal' import { exportReportToPdf } from '@/pdf/export' +const DISCLAIMER_FLAG = 'osteo:disclaimer-shown' + export default function EditorRoute() { const navigate = useNavigate() const report = useReportStore((s) => s.report) @@ -43,7 +45,8 @@ export default function EditorRoute() { const [bones, setBones] = useState>(new Map()) const [detailBones, setDetailBones] = useState>(new Map()) - const [pathologies, setPathologies] = useState([]) + const [findings, setFindings] = useState(null) + const [disclaimer, setDisclaimer] = useState(null) const [detail, setDetail] = useState<{ id: string src: string @@ -86,6 +89,13 @@ export default function EditorRoute() { closeEditInfos() } + function acknowledgeDisclaimer() { + if (typeof sessionStorage !== 'undefined') { + sessionStorage.setItem(DISCLAIMER_FLAG, '1') + } + setDisclaimer(null) + } + useEffect(() => { if (!report) navigate('/') }, [report, navigate]) @@ -98,9 +108,16 @@ export default function EditorRoute() { useEffect(() => { if (!species) return loadSvg(species.mainSvg).then((root) => setBones(parseSvgBones(root))) - species.pathologies().then((m) => setPathologies(m.default)) + species.findings().then((m) => setFindings(m.default)) }, [species]) + useEffect(() => { + if (!findings) return + if (typeof sessionStorage === 'undefined') return + if (sessionStorage.getItem(DISCLAIMER_FLAG)) return + setDisclaimer(findings.scope_disclaimer) + }, [findings]) + useEffect(() => { if (!detail) return let cancelled = false @@ -248,8 +265,7 @@ export default function EditorRoute() { onMoveUp={moveObservationUp} onMoveDown={moveObservationDown} bones={allBones} - speciesId={species.id} - pathologyPool={pathologies} + findings={findings} onChange={(i, next: Observation) => updateObservation(i, next)} onOpenVertebraPicker={(_i, zoneIndex) => setVertebraTarget(zoneIndex) @@ -332,6 +348,22 @@ export default function EditorRoute() { )} + {disclaimer && ( + +
+

{disclaimer}

+
+ +
+
+
+ )} + {vertebraTarget !== null && activeObs && activeObs.zones[vertebraTarget] && ( diff --git a/src/components/canvas/ZoneTooltip.tsx b/src/components/canvas/ZoneTooltip.tsx deleted file mode 100644 index af5de753..00000000 --- a/src/components/canvas/ZoneTooltip.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function ZoneTooltip() { - return
ZoneTooltip placeholder
-} diff --git a/src/components/observation/FindingsTreePicker.tsx b/src/components/observation/FindingsTreePicker.tsx new file mode 100644 index 00000000..125cccbd --- /dev/null +++ b/src/components/observation/FindingsTreePicker.tsx @@ -0,0 +1,208 @@ +import { useMemo, useState } from 'react' +import type { + FindingNode, + ZoneFindings, +} from '@/domain/schema/findings' +import type { Finding } from '@/domain/schema/observation' +import Button from '@/components/ui/Button' + +export interface FindingsTreePickerProps { + zoneId: string + tree: ZoneFindings + selected: Finding[] + onChange: (next: Finding[]) => void +} + +function isLeaf(node: FindingNode): boolean { + return !node.children || node.children.length === 0 +} + +function samePath(a: string[], b: string[]): boolean { + if (a.length !== b.length) return false + for (let i = 0; i < a.length; i += 1) { + if (a[i] !== b[i]) return false + } + return true +} + +function findNode( + categories: FindingNode[], + path: string[], +): FindingNode | undefined { + let nodes: FindingNode[] = categories + let node: FindingNode | undefined + for (const segment of path) { + node = nodes.find((n) => n.id === segment) + if (!node) return undefined + nodes = node.children ?? [] + } + return node +} + +export default function FindingsTreePicker({ + zoneId, + tree, + selected, + onChange, +}: FindingsTreePickerProps) { + const [path, setPath] = useState([]) + + const currentNodes = useMemo(() => { + if (path.length === 0) return tree.categories + const node = findNode(tree.categories, path) + return node?.children ?? [] + }, [tree, path]) + + const focusedNode = useMemo( + () => (path.length === 0 ? undefined : findNode(tree.categories, path)), + [tree, path], + ) + + const breadcrumb = useMemo<{ label: string; depth: number }[]>(() => { + const crumbs: { label: string; depth: number }[] = [ + { label: tree.name_fr, depth: 0 }, + ] + let nodes: FindingNode[] = tree.categories + path.forEach((seg, i) => { + const n = nodes.find((x) => x.id === seg) + if (n) { + crumbs.push({ label: n.name_fr, depth: i + 1 }) + nodes = n.children ?? [] + } + }) + return crumbs + }, [tree, path]) + + function isLeafSelected(leafPath: string[]): boolean { + return selected.some( + (f) => f.zoneId === zoneId && samePath(f.path, leafPath), + ) + } + + function toggleLeaf(leafPath: string[], leaf: FindingNode) { + if (isLeafSelected(leafPath)) { + onChange( + selected.filter( + (f) => !(f.zoneId === zoneId && samePath(f.path, leafPath)), + ), + ) + return + } + const next: Finding = { + zoneId, + path: leafPath, + labelFrSnapshot: leaf.name_fr, + labelEnSnapshot: leaf.name_en, + } + if (leaf.requires_vet_referral) next.requiresVetReferral = true + onChange([...selected, next]) + } + + return ( +
+
+ {breadcrumb.map((c, i) => { + const isLast = i === breadcrumb.length - 1 + return ( + + + {!isLast && } + + ) + })} +
+ + {focusedNode?.description_fr && ( +

+ {focusedNode.description_fr} +

+ )} + + {path.length > 0 && ( + + )} + +
    + {currentNodes.length === 0 ? ( +
  • + Aucune option disponible à ce niveau. +
  • + ) : ( + currentNodes.map((node) => { + const nodePath = [...path, node.id] + if (isLeaf(node)) { + const checked = isLeafSelected(nodePath) + return ( +
  • + +
  • + ) + } + return ( +
  • + +
  • + ) + }) + )} +
+
+ ) +} diff --git a/src/components/observation/FreeTextPathologyInput.tsx b/src/components/observation/FreeTextFindingInput.tsx similarity index 73% rename from src/components/observation/FreeTextPathologyInput.tsx rename to src/components/observation/FreeTextFindingInput.tsx index b70324d8..fadd2b4f 100644 --- a/src/components/observation/FreeTextPathologyInput.tsx +++ b/src/components/observation/FreeTextFindingInput.tsx @@ -3,36 +3,46 @@ import Input from '@/components/ui/Input' import Button from '@/components/ui/Button' import Badge from '@/components/ui/Badge' -export interface FreeTextPathologyInputProps { +export interface FreeTextFindingInputProps { items: string[] onChange: (next: string[]) => void } -export default function FreeTextPathologyInput({ +export default function FreeTextFindingInput({ items, onChange, -}: FreeTextPathologyInputProps) { +}: FreeTextFindingInputProps) { const [v, setV] = useState('') + function add() { const trimmed = v.trim() if (!trimmed) return onChange([...items, trimmed]) setV('') } + function remove(i: number) { onChange(items.filter((_, k) => k !== i)) } + return (
setV(e.target.value)} - placeholder="Pathologie additionnelle (texte libre)" - onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); add() } }} - aria-label="Pathologie libre" + placeholder="Observation additionnelle (texte libre)" + onKeyDown={(e) => { + if (e.key === 'Enter') { + e.preventDefault() + add() + } + }} + aria-label="Observation libre" /> - +
{items.length > 0 && (
    diff --git a/src/components/observation/ObservationCard.tsx b/src/components/observation/ObservationCard.tsx index a17b3044..f709b405 100644 --- a/src/components/observation/ObservationCard.tsx +++ b/src/components/observation/ObservationCard.tsx @@ -1,5 +1,9 @@ -import type { Observation, ObservationZone, Vertebra } from '@/domain/schema/observation' -import type { Pathology } from '@/domain/schema/pathology' +import type { + Observation, + ObservationZone, + Vertebra, +} from '@/domain/schema/observation' +import type { SpeciesFindings } from '@/domain/schema/findings' import type { Bone } from '@/anatomy/types' import { AnimatePresence, motion } from 'motion/react' import Card from '@/components/ui/Card' @@ -7,8 +11,8 @@ import Badge from '@/components/ui/Badge' import Button from '@/components/ui/Button' import Label from '@/components/ui/Label' import Textarea from '@/components/ui/Textarea' -import PathologyPicker from './PathologyPicker' -import FreeTextPathologyInput from './FreeTextPathologyInput' +import FindingsTreePicker from './FindingsTreePicker' +import FreeTextFindingInput from './FreeTextFindingInput' import SeveritySelector from './SeveritySelector' export interface ObservationCardProps { @@ -23,8 +27,7 @@ export interface ObservationCardProps { canMoveDown: boolean // Editor body props (used only when expanded) bones: Map - speciesId: string - pathologyPool: Pathology[] + findings: SpeciesFindings | null onChange: (next: Observation) => void onOpenVertebraPicker: (zoneIndex: number) => void onRemoveZone: (zoneIndex: number) => void @@ -53,15 +56,14 @@ export default function ObservationCard({ canMoveUp, canMoveDown, bones, - speciesId, - pathologyPool, + findings, onChange, onOpenVertebraPicker, onRemoveZone, }: ObservationCardProps) { const zoneCount = observation.zones.length - const patCount = - observation.pathologyIds.length + observation.freeTextPathologies.length + const findingCount = + observation.findings.length + observation.freeTextFindings.length function onHeaderKey(event: React.KeyboardEvent) { if (event.key === 'Enter' || event.key === ' ') { @@ -77,7 +79,13 @@ export default function ObservationCard({ } } - const zoneBoneIds = observation.zones.map((z) => z.boneId) + // Deduplicate zones by boneId so we don't render the same picker tree twice. + const uniqueZoneIds = Array.from(new Set(observation.zones.map((z) => z.boneId))) + const zonesWithTree = uniqueZoneIds + .map((id) => ({ id, tree: findings?.zones[id] })) + .filter((z): z is { id: string; tree: NonNullable } => + Boolean(z.tree), + ) return (
    - {zoneCount} zone{zoneCount > 1 ? 's' : ''} · {patCount} pathologie - {patCount > 1 ? 's' : ''} + {zoneCount} zone{zoneCount > 1 ? 's' : ''} · {findingCount} constat + {findingCount > 1 ? 's' : ''}
    {!expanded && observation.comment && (

    @@ -220,24 +228,43 @@ export default function ObservationCard({

    - - - onChange({ ...observation, pathologyIds: ids }) - } - /> + + {zonesWithTree.length === 0 ? ( +

    + {observation.zones.length === 0 + ? 'Sélectionnez une zone pour accéder au référentiel.' + : 'Aucun référentiel disponible pour ces zones. Utilisez le texte libre ci-dessous.'} +

    + ) : ( +
    + {zonesWithTree.map(({ id, tree }) => ( +
    +
    + {tree.name_fr} +
    + + onChange({ ...observation, findings: next }) + } + /> +
    + ))} +
    + )}
    - - Constats (texte libre) + - onChange({ ...observation, freeTextPathologies: items }) + onChange({ ...observation, freeTextFindings: items }) } />
    diff --git a/src/components/observation/ObservationList.tsx b/src/components/observation/ObservationList.tsx index a4e73363..6ef3d797 100644 --- a/src/components/observation/ObservationList.tsx +++ b/src/components/observation/ObservationList.tsx @@ -1,5 +1,5 @@ import type { Observation } from '@/domain/schema/observation' -import type { Pathology } from '@/domain/schema/pathology' +import type { SpeciesFindings } from '@/domain/schema/findings' import type { Bone } from '@/anatomy/types' import ObservationCard from './ObservationCard' import Button from '@/components/ui/Button' @@ -14,8 +14,7 @@ export interface ObservationListProps { onMoveDown: (i: number) => void // Editor body props forwarded to each card bones: Map - speciesId: string - pathologyPool: Pathology[] + findings: SpeciesFindings | null onChange: (i: number, next: Observation) => void onOpenVertebraPicker: (i: number, zoneIndex: number) => void onRemoveZone: (i: number, zoneIndex: number) => void @@ -30,8 +29,7 @@ export default function ObservationList({ onMoveUp, onMoveDown, bones, - speciesId, - pathologyPool, + findings, onChange, onOpenVertebraPicker, onRemoveZone, @@ -66,8 +64,7 @@ export default function ObservationList({ canMoveUp={i > 0} canMoveDown={i < observations.length - 1} bones={bones} - speciesId={speciesId} - pathologyPool={pathologyPool} + findings={findings} onChange={(next) => onChange(i, next)} onOpenVertebraPicker={(zoneIndex) => onOpenVertebraPicker(i, zoneIndex) diff --git a/src/components/observation/PathologyPicker.tsx b/src/components/observation/PathologyPicker.tsx deleted file mode 100644 index 4477b2f9..00000000 --- a/src/components/observation/PathologyPicker.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { useMemo } from 'react' -import type { Pathology } from '@/domain/schema/pathology' - -export interface PathologyPickerProps { - pool: Pathology[] - speciesId: string - boneIds: string[] - selected: string[] - onChange: (next: string[]) => void -} - -function matches(p: Pathology, speciesId: string, boneIds: string[]): boolean { - const speciesOk = p.speciesIds.length === 0 || p.speciesIds.includes(speciesId) - if (!speciesOk) return false - if (boneIds.length === 0) return true - if (p.boneIds.length === 0) return true - return p.boneIds.some((b) => boneIds.includes(b)) -} - -export default function PathologyPicker({ - pool, - speciesId, - boneIds, - selected, - onChange, -}: PathologyPickerProps) { - const filtered = useMemo( - () => pool.filter((p) => matches(p, speciesId, boneIds)), - [pool, speciesId, boneIds], - ) - - function toggle(id: string) { - onChange(selected.includes(id) ? selected.filter((x) => x !== id) : [...selected, id]) - } - - if (filtered.length === 0) { - return ( -

    - Aucune pathologie de référence pour ces zones. Ajoutez-en une en texte libre ci-dessous. -

    - ) - } - - return ( -
      - {filtered.map((p) => ( -
    • - -
    • - ))} -
    - ) -} diff --git a/src/components/ui/Toast.tsx b/src/components/ui/Toast.tsx deleted file mode 100644 index b8b88760..00000000 --- a/src/components/ui/Toast.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function Toast() { - return
    Toast placeholder
    -} diff --git a/src/pdf/render/observationPage.ts b/src/pdf/render/observationPage.ts index 5894161f..a03e1985 100644 --- a/src/pdf/render/observationPage.ts +++ b/src/pdf/render/observationPage.ts @@ -195,12 +195,16 @@ export async function addObservationPage( const sections: Array<{ label: string; value: string }> = [ { label: 'ZONES', value: zonesText || '—' }, ] - const pathologies = [ - ...observation.pathologyIds, - ...observation.freeTextPathologies, + const findingLabels = [ + ...observation.findings.map((f) => + f.requiresVetReferral + ? `⚠ ${f.labelFrSnapshot}` + : f.labelFrSnapshot, + ), + ...observation.freeTextFindings, ] - if (pathologies.length) { - sections.push({ label: 'PATHOLOGIES', value: pathologies.join(' · ') }) + if (findingLabels.length) { + sections.push({ label: 'CONSTATS', value: findingLabels.join(' · ') }) } if (observation.severity) { sections.push({ label: 'SÉVÉRITÉ', value: observation.severity }) diff --git a/tests/unit/components.FindingsTreePicker.test.tsx b/tests/unit/components.FindingsTreePicker.test.tsx new file mode 100644 index 00000000..605ff328 --- /dev/null +++ b/tests/unit/components.FindingsTreePicker.test.tsx @@ -0,0 +1,137 @@ +import { describe, it, expect, vi } from 'vitest' +import { render, screen } from '@testing-library/react' +import userEvent from '@testing-library/user-event' +import FindingsTreePicker from '@/components/observation/FindingsTreePicker' +import type { ZoneFindings } from '@/domain/schema/findings' +import type { Finding } from '@/domain/schema/observation' + +const TREE: ZoneFindings = { + id: 'sphenoid', + name_fr: 'Sphénoïde', + name_en: 'Sphenoid', + categories: [ + { + id: 'dysfunctions', + name_fr: 'Dysfonctions', + name_en: 'Dysfunctions', + children: [ + { + id: 'flexion', + name_fr: 'Flexion', + name_en: 'Flexion', + description_fr: 'Description test', + }, + { + id: 'extension', + name_fr: 'Extension', + name_en: 'Extension', + requires_vet_referral: true, + }, + ], + }, + ], +} + +describe('FindingsTreePicker', () => { + it('renders the zone name in the initial breadcrumb', () => { + render( + {}} + />, + ) + expect(screen.getByText('Sphénoïde')).toBeInTheDocument() + }) + + it('drills into a category and shows leaves', async () => { + render( + {}} + />, + ) + await userEvent.click(screen.getByLabelText('Ouvrir Dysfonctions')) + expect(screen.getByLabelText('Flexion')).toBeInTheDocument() + expect(screen.getByLabelText('Extension')).toBeInTheDocument() + }) + + it('emits a Finding with snapshot labels on leaf select', async () => { + const onChange = vi.fn<(next: Finding[]) => void>() + render( + , + ) + await userEvent.click(screen.getByLabelText('Ouvrir Dysfonctions')) + await userEvent.click(screen.getByLabelText('Flexion')) + expect(onChange).toHaveBeenCalledTimes(1) + expect(onChange.mock.calls[0][0]).toEqual([ + { + zoneId: 'sphenoid', + path: ['dysfunctions', 'flexion'], + labelFrSnapshot: 'Flexion', + labelEnSnapshot: 'Flexion', + }, + ]) + }) + + it('flags vet-referral leaves with requiresVetReferral on selection', async () => { + const onChange = vi.fn<(next: Finding[]) => void>() + render( + , + ) + await userEvent.click(screen.getByLabelText('Ouvrir Dysfonctions')) + await userEvent.click(screen.getByLabelText('Extension')) + expect(onChange.mock.calls[0][0][0].requiresVetReferral).toBe(true) + }) + + it('deselects a previously selected leaf', async () => { + const onChange = vi.fn<(next: Finding[]) => void>() + const selected: Finding[] = [ + { + zoneId: 'sphenoid', + path: ['dysfunctions', 'flexion'], + labelFrSnapshot: 'Flexion', + labelEnSnapshot: 'Flexion', + }, + ] + render( + , + ) + await userEvent.click(screen.getByLabelText('Ouvrir Dysfonctions')) + await userEvent.click(screen.getByLabelText('Flexion')) + expect(onChange).toHaveBeenCalledWith([]) + }) + + it('navigates back to parent via the Retour button', async () => { + render( + {}} + />, + ) + await userEvent.click(screen.getByLabelText('Ouvrir Dysfonctions')) + expect(screen.getByLabelText('Flexion')).toBeInTheDocument() + await userEvent.click(screen.getByLabelText('Retour au niveau précédent')) + expect(screen.getByLabelText('Ouvrir Dysfonctions')).toBeInTheDocument() + }) +}) diff --git a/tests/unit/components.PathologyPicker.test.tsx b/tests/unit/components.PathologyPicker.test.tsx deleted file mode 100644 index acc73421..00000000 --- a/tests/unit/components.PathologyPicker.test.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { describe, it, expect, vi } from 'vitest' -import { render, screen } from '@testing-library/react' -import userEvent from '@testing-library/user-event' -import PathologyPicker from '@/components/observation/PathologyPicker' -import type { Pathology } from '@/domain/schema/pathology' - -const POOL: Pathology[] = [ - { - id: 'a', - labelFr: 'Aïe', - description: '', - category: 'osseux', - speciesIds: ['equine'], - boneIds: ['epaule'], - sources: [{ type: 'manual', citation: 'X' }], - }, - { - id: 'b', - labelFr: 'Aïe-aïe', - description: '', - category: 'osseux', - speciesIds: ['equine'], - boneIds: ['hanche'], - sources: [{ type: 'manual', citation: 'X' }], - }, -] - -describe('PathologyPicker', () => { - it('shows only pathologies matching zones', () => { - render( - {}} - />, - ) - expect(screen.getByLabelText('Aïe')).toBeInTheDocument() - expect(screen.queryByLabelText('Aïe-aïe')).toBeNull() - }) - - it('toggles selection', async () => { - const onChange = vi.fn() - render( - , - ) - await userEvent.click(screen.getByLabelText('Aïe')) - expect(onChange).toHaveBeenCalledWith(['a']) - }) -})