feat(editor): cite references from the finding edit form only

This commit is contained in:
bchanot committed 2026-11-14 14:11:13 +01:00
1 parent afc1051313
commit f0e49fd447
16 files changed
+519 -395

No files matched your search

+23 -9
View File
@@ -590,7 +590,7 @@ describe('Constats tab', () => {
)
})
it('edits descriptions (blank side omitted) and the vet flag in one save, cites at once', async () => {
it('edits descriptions (blank side omitted), the vet flag and the citations in one save', async () => {
let text = treeText()
text = insert(text, {
kind: 'reference',
@@ -628,22 +628,22 @@ describe('Constats tab', () => {
await user.clear(inFindingDialog().getByLabelText('Description (FR)'))
await save()
expect(node().description).toEqual({})
// « Citer une référence » is no part of the form: it acts at once, in view mode
// the view cites nothing: « Citer une référence » is the edit form's
expect(inFindingDialog().queryByLabelText('Citer une référence')).toBeNull()
await startEdit(user)
await user.selectOptions(
inFindingDialog().getByLabelText('Citer une référence'),
'ref-a',
)
expect(node().reference_ids).toEqual([])
await save()
expect(node().reference_ids).toEqual(['ref-a'])
// a finding node lists its citations in the sheet, not inline
expect(
inFindingDialog().queryByRole('button', { name: /Retirer Alpha/ }),
).toBeNull()
expect(
inFindingDialog().getByRole('button', { name: '1 référence' }),
).toBeInTheDocument()
})
it('a family keeps its inline list of citations with « Retirer »', async () => {
it('a family cites and removes in its edit form, one save writes both', async () => {
let text = treeText()
text = insert(text, {
kind: 'reference',
@@ -660,18 +660,32 @@ describe('Constats tab', () => {
render(<FindingsHost />)
await user.click(items()[1])
const family = () => doc().finding_zones[0].categories[0]
await startEdit(user)
await user.selectOptions(
inFindingDialog().getByLabelText('Citer une référence'),
'ref-a',
)
expect(family().reference_ids).toEqual(['ref-a'])
expect(
inFindingDialog().getByRole('button', { name: /Retirer Alpha/ }),
).toBeInTheDocument()
await user.click(
inFindingDialog().getByRole('button', { name: /Retirer Alpha/ }),
)
expect(family().reference_ids).toEqual([])
expect(
inFindingDialog().getByText('Aucune référence citée.'),
).toBeInTheDocument()
await user.selectOptions(
inFindingDialog().getByLabelText('Citer une référence'),
'ref-a',
)
expect(family().reference_ids).toEqual([])
await user.click(
inFindingDialog().getByRole('button', { name: 'Enregistrer' }),
)
expect(family().reference_ids).toEqual(['ref-a'])
expect(
inFindingDialog().queryByRole('button', { name: /Retirer/ }),
).toBeNull()
})
it('the trigger shows exactly for the keys open_citations accepts', async () => {