feat(app): Constats description, vet referral and citations, keyboard focus after collapse and delete
This commit is contained in:
1 parent
26097852ff
commit
91d06c9817
9 files changed
+374
-13
No files matched your search
@@ -355,4 +355,82 @@ describe('Constats tab', () => {
|
||||
'Cat A',
|
||||
)
|
||||
})
|
||||
|
||||
it('edits descriptions (blank side omitted), the vet flag and the cited references', async () => {
|
||||
let text = treeText()
|
||||
text = insert(text, {
|
||||
kind: 'reference',
|
||||
value: {
|
||||
id: 'ref-a',
|
||||
type: 'book',
|
||||
citation: 'Alpha',
|
||||
url: null,
|
||||
doi: null,
|
||||
},
|
||||
})
|
||||
await openReady({ text })
|
||||
const user = userEvent.setup()
|
||||
render(<FindingsTab {...props} />)
|
||||
await user.click(items()[1])
|
||||
await user.keyboard('{ArrowRight}{ArrowDown}')
|
||||
const node = () => doc().finding_zones[0].categories[0].children[0]
|
||||
const fr = screen.getByLabelText('Description (FR)')
|
||||
await user.type(fr, 'Texte')
|
||||
await user.tab()
|
||||
expect(node().description).toEqual({ fr: 'Texte' })
|
||||
await user.clear(fr)
|
||||
await user.tab()
|
||||
expect(node().description).toEqual({})
|
||||
await user.click(screen.getByLabelText('Renvoi vers un vétérinaire'))
|
||||
expect(node().requires_vet_referral).toBe(true)
|
||||
await user.selectOptions(
|
||||
screen.getByLabelText('Citer une référence'),
|
||||
'ref-a',
|
||||
)
|
||||
expect(node().reference_ids).toEqual(['ref-a'])
|
||||
await user.click(screen.getByRole('button', { name: /Retirer Alpha/ }))
|
||||
expect(node().reference_ids).toEqual([])
|
||||
})
|
||||
|
||||
it('a category has no vet flag; read-only hides the editing actions', async () => {
|
||||
await openReady({ text: treeText() })
|
||||
const user = userEvent.setup()
|
||||
const { rerender } = render(<FindingsTab {...props} />)
|
||||
await user.click(items()[1])
|
||||
expect(screen.queryByLabelText('Renvoi vers un vétérinaire')).toBeNull()
|
||||
rerender(<FindingsTab {...props} readOnly />)
|
||||
expect(screen.queryByLabelText('Citer une référence')).toBeNull()
|
||||
expect(screen.queryByRole('textbox')).toBeNull()
|
||||
})
|
||||
|
||||
it('collapsing an ancestor of the selection selects the ancestor', async () => {
|
||||
await openReady({ text: treeText() })
|
||||
const user = userEvent.setup()
|
||||
render(<FindingsTab {...props} />)
|
||||
await user.click(items()[1])
|
||||
await user.keyboard('{ArrowRight}{ArrowRight}')
|
||||
expect(items()[2]).toHaveAttribute('aria-selected', 'true')
|
||||
await user.click(items()[0].querySelector('span') as HTMLElement)
|
||||
expect(items()[0]).toHaveAttribute('aria-selected', 'true')
|
||||
expect(items()).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('after a delete the previous sibling, else the parent, is selected and focused', async () => {
|
||||
await openReady({ text: treeText() })
|
||||
const user = userEvent.setup()
|
||||
render(<FindingsTab {...props} />)
|
||||
await user.click(items()[2])
|
||||
await user.click(screen.getByRole('button', { name: 'Supprimer' }))
|
||||
const dialog = await screen.findByRole('dialog')
|
||||
await user.click(within(dialog).getByRole('button', { name: 'Supprimer' }))
|
||||
expect(doc().finding_zones.map((z) => z.id)).toEqual(['zone-a'])
|
||||
expect(items()[0]).toHaveAttribute('aria-selected', 'true')
|
||||
expect(items()[0]).toHaveFocus()
|
||||
await user.click(items()[1])
|
||||
await user.click(screen.getAllByRole('button', { name: 'Supprimer' })[0])
|
||||
const second = (await screen.findAllByRole('dialog')).at(-1) as HTMLElement
|
||||
await user.click(within(second).getByRole('button', { name: 'Supprimer' }))
|
||||
expect(items()[0]).toHaveAttribute('aria-selected', 'true')
|
||||
expect(items()[0]).toHaveFocus()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user