feat(editor): references dialog over the finding, view mode
A modal Dialog replaces the citations side sheet; families open it too (isCitable). The finding dialog shows only « Références citées » and « X références », also at zero; its edit form no longer carries reference_ids. A dirty form refusing « Aller à » or « Tout afficher » closes the clean references dialog first.
This commit is contained in:
1 parent
ff21b0315e
commit
abc781df52
29 files changed
+432
-858
No files matched your search
@@ -1,6 +1,7 @@
|
||||
/** Lot I: the Constats tree. */
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
act,
|
||||
cleanup,
|
||||
render,
|
||||
screen,
|
||||
@@ -590,7 +591,7 @@ describe('Constats tab', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('edits descriptions (blank side omitted), the vet flag and the citations in one save', async () => {
|
||||
it('edits descriptions (blank side omitted) and the vet flag in one save, citations kept', async () => {
|
||||
let text = treeText()
|
||||
text = insert(text, {
|
||||
kind: 'reference',
|
||||
@@ -628,66 +629,29 @@ describe('Constats tab', () => {
|
||||
await user.clear(inFindingDialog().getByLabelText('Description (FR)'))
|
||||
await save()
|
||||
expect(node().description).toEqual({})
|
||||
// the view cites nothing: « Citer une référence » is the edit form's
|
||||
// Neither mode cites: the references dialog holds the citations (Rev 5).
|
||||
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([])
|
||||
expect(inFindingDialog().queryByLabelText('Citer une référence')).toBeNull()
|
||||
act(() => {
|
||||
store.getState().commit({
|
||||
op: 'update',
|
||||
key: { kind: 'finding', zone_id: 'zone-a', path: ['fcat-a', 'node-a'] },
|
||||
element: {
|
||||
kind: 'finding_node',
|
||||
value: { ...node(), reference_ids: ['ref-a'] },
|
||||
},
|
||||
})
|
||||
})
|
||||
await user.type(inFindingDialog().getByLabelText('Description (FR)'), 'B')
|
||||
await save()
|
||||
expect(node().description).toEqual({ fr: 'B' })
|
||||
expect(node().reference_ids).toEqual(['ref-a'])
|
||||
expect(
|
||||
inFindingDialog().getByRole('button', { name: '1 référence' }),
|
||||
).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('a family cites and removes in its edit form, one save writes both', 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(<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(
|
||||
inFindingDialog().getByRole('button', { name: /Retirer Alpha/ }),
|
||||
).toBeInTheDocument()
|
||||
await user.click(
|
||||
inFindingDialog().getByRole('button', { name: /Retirer Alpha/ }),
|
||||
)
|
||||
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 () => {
|
||||
let text = insert(treeText(), {
|
||||
kind: 'reference',
|
||||
@@ -733,7 +697,7 @@ describe('Constats tab', () => {
|
||||
}
|
||||
expect(truth).toEqual([
|
||||
['zone', false],
|
||||
['category', false],
|
||||
['category', true],
|
||||
['node', true],
|
||||
['node', true],
|
||||
['zone', false],
|
||||
@@ -742,7 +706,7 @@ describe('Constats tab', () => {
|
||||
expect(all.filter((item) => item.kind === 'node')).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('the trigger reads « expanded » while the sheet of its finding is open', async () => {
|
||||
it('the trigger reads « expanded » while the references dialog of its finding is open', async () => {
|
||||
let text = insert(treeText(), {
|
||||
kind: 'reference',
|
||||
value: { id: 'ref-a', type: 'book', citation: 'A', url: null, doi: null },
|
||||
@@ -771,9 +735,10 @@ describe('Constats tab', () => {
|
||||
expect(trigger()).toHaveAttribute('aria-controls', 'editor-citations-panel')
|
||||
await user.click(trigger())
|
||||
expect(trigger()).toHaveAttribute('aria-expanded', 'true')
|
||||
await user.click(
|
||||
screen.getByRole('button', { name: 'Fermer les références' }),
|
||||
)
|
||||
const citations = screen
|
||||
.getByTestId('editor-citations-panel')
|
||||
.closest('dialog')!
|
||||
await user.click(within(citations).getByRole('button', { name: 'Fermer' }))
|
||||
await waitFor(() =>
|
||||
expect(trigger()).toHaveAttribute('aria-expanded', 'false'),
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user