feat(observation): PathologyPicker filtered by species + zones
This commit is contained in:
1 parent
b3e1a87690
commit
4c67c900b9
2 files changed
+121
-2
No files matched your search
@@ -0,0 +1,57 @@
|
||||
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(
|
||||
<PathologyPicker
|
||||
pool={POOL}
|
||||
speciesId="equine"
|
||||
boneIds={['epaule']}
|
||||
selected={[]}
|
||||
onChange={() => {}}
|
||||
/>,
|
||||
)
|
||||
expect(screen.getByLabelText('Aïe')).toBeInTheDocument()
|
||||
expect(screen.queryByLabelText('Aïe-aïe')).toBeNull()
|
||||
})
|
||||
|
||||
it('toggles selection', async () => {
|
||||
const onChange = vi.fn()
|
||||
render(
|
||||
<PathologyPicker
|
||||
pool={POOL}
|
||||
speciesId="equine"
|
||||
boneIds={['epaule']}
|
||||
selected={[]}
|
||||
onChange={onChange}
|
||||
/>,
|
||||
)
|
||||
await userEvent.click(screen.getByLabelText('Aïe'))
|
||||
expect(onChange).toHaveBeenCalledWith(['a'])
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user