fix(editor): Task 12 review minors, delete hint and cite label

This commit is contained in:
bchanot committed 2026-11-15 16:58:50 +01:00
1 parent 8c420d4b53
commit 11c2b0c5ee
12 files changed
+113 -47

No files matched your search

@@ -182,10 +182,13 @@ const removeRow = (user: User, citation: RegExp) =>
}),
)
const cite = (user: User, id: string) =>
user.selectOptions(inCitations().getByLabelText('Citer une référence'), id)
user.selectOptions(
inCitations().getByLabelText('Citer une référence existante'),
id,
)
describe('the « Modifier » of the references dialog', () => {
it('switches to the edit mode: no history entry, no « Tout afficher », no « Aller à »', async () => {
it('edit mode: no history entry, no « Tout afficher », no « Aller à »', async () => {
const user = await mount()
await openCitations(user)
const before = written()!.id
@@ -243,6 +246,17 @@ describe('the draft', () => {
expect(inCitations().queryByText('Modifications enregistrées')).toBeNull()
})
it('the draft list is named; an empty draft shows no list', async () => {
const user = await mount(1280, sheetText([]))
await editCitations(user, '0 référence')
expect(inCitations().queryByRole('list')).toBeNull()
expect(inCitations().getByText('Aucune référence citée.')).toBeVisible()
await cite(user, 'ref-b')
expect(
inCitations().getByRole('list', { name: 'Références citées' }),
).toBeVisible()
})
it('a dangling id is named and removable', async () => {
const user = await mount(1280, sheetText(['ref-a', 'ref-x']))
await editCitations(user)
@@ -252,7 +266,7 @@ describe('the draft', () => {
expect(nodeA().reference_ids).toEqual(['ref-a'])
})
it('a save keeps citations changed elsewhere: removals and additions on the current list', async () => {
it('a save applies the draft to the current list (changes made elsewhere stay)', async () => {
const user = await mount()
await editCitations(user)
await removeRow(user, /Barone/)
@@ -331,7 +345,9 @@ describe('leaving the edit mode with changes', () => {
expect(button(/^Retirer/)).toBeDisabled()
expect(button(/^Modifier la référence/)).toBeDisabled()
expect(button('Nouvelle référence')).toBeDisabled()
expect(inCitations().queryByLabelText('Citer une référence')).toBeNull()
expect(
inCitations().queryByLabelText('Citer une référence existante'),
).toBeNull()
expect(inCitations().queryByRole('button', { name: 'Annuler' })).toBeNull()
await user.click(button('Abandonner'))
await waitFor(() =>
@@ -512,7 +528,7 @@ describe('a reference over the references dialog of a dirty finding (criterion 2
await user.type(inReference().getByLabelText('Citation'), ' x')
}
it('the finding asks next with the references dialog closed, focused; the jump goes after it', async () => {
it('the finding asks next, references dialog closed, focused; then the jump goes', async () => {
const user = await mount()
await stacked(user)
expect(jump().defaultPrevented).toBe(true)
@@ -543,7 +559,7 @@ describe('a reference over the references dialog of a dirty finding (criterion 2
expect(api.traverseTo).not.toHaveBeenCalled()
})
it('a citations draft under a clean reference dialog asks once the reference is closed', async () => {
it('a citations draft under a clean reference dialog asks once it is closed', async () => {
const user = await mount()
await editCitations(user)
await removeRow(user, /Code rural/)
@@ -140,6 +140,16 @@ describe('closeCitations', () => {
expect(closed).toBe(true)
expect(nav.state.finding).toMatchObject({ citations: false })
})
it('a forced close of a draft says it was dropped', async () => {
cited()
register('citations')
act(() => {
nav.closeCitations(true)
})
await act(async () => undefined)
expect(nav.live).toContain('dropped')
})
})
describe('a creation started over the citations dialog', () => {
@@ -158,6 +168,19 @@ describe('a creation started over the citations dialog', () => {
expect(nav.state.finding).toMatchObject({ citations: true })
})
it('a creation closed or replaced forgets its citing form', async () => {
cited()
const cite = vi.fn()
act(() => nav.references.start(null, cite))
act(() => nav.references.close(true))
await act(async () => nav.references.created('ref-x'))
expect(cite).not.toHaveBeenCalled()
act(() => nav.references.start(null, cite))
act(() => nav.references.replace(null))
await act(async () => nav.references.created('ref-y'))
expect(cite).not.toHaveBeenCalled()
})
it('a later creation from the library sets the notice, cites nothing', async () => {
cited()
const cite = vi.fn()
@@ -857,7 +857,9 @@ describe('the finding dialog holds no citation control (Rev 5, owner item 1)', (
await openFinding(user, /Node A/)
expect(inDialog().getByText('Références citées')).toBeVisible()
expect(inDialog().queryByText('Alpha')).toBeNull()
expect(inDialog().queryByLabelText('Citer une référence')).toBeNull()
expect(
inDialog().queryByLabelText('Citer une référence existante'),
).toBeNull()
expect(inDialog().queryByRole('button', { name: /^Retirer/ })).toBeNull()
expect(
inDialog().getByRole('button', { name: '1 référence' }),
@@ -895,7 +897,9 @@ describe('the finding dialog holds no citation control (Rev 5, owner item 1)', (
expect(
inDialog().getByRole('button', { name: '0 référence' }),
).toBeVisible()
expect(inDialog().queryByLabelText('Citer une référence')).toBeNull()
expect(
inDialog().queryByLabelText('Citer une référence existante'),
).toBeNull()
expect(inDialog().queryByRole('button', { name: /^Retirer/ })).toBeNull()
})
+8 -4
View File
@@ -630,9 +630,13 @@ describe('Constats tab', () => {
await save()
expect(node().description).toEqual({})
// Neither mode cites: the references dialog holds the citations (Rev 5).
expect(inFindingDialog().queryByLabelText('Citer une référence')).toBeNull()
expect(
inFindingDialog().queryByLabelText('Citer une référence existante'),
).toBeNull()
await startEdit(user)
expect(inFindingDialog().queryByLabelText('Citer une référence')).toBeNull()
expect(
inFindingDialog().queryByLabelText('Citer une référence existante'),
).toBeNull()
act(() => {
store.getState().commit({
op: 'update',
@@ -706,7 +710,7 @@ describe('Constats tab', () => {
expect(all.filter((item) => item.kind === 'node')).toHaveLength(2)
})
it('the trigger reads « expanded » while the references dialog of its finding is open', async () => {
it('the trigger opens the references dialog of its finding, focus back on close', async () => {
let text = insert(treeText(), {
kind: 'reference',
value: { id: 'ref-a', type: 'book', citation: 'A', url: null, doi: null },
@@ -750,7 +754,7 @@ describe('Constats tab', () => {
expect(screen.queryByLabelText('Renvoi vers un vétérinaire')).toBeNull()
expect(screen.getByLabelText('Description (FR)')).toBeInTheDocument()
rerender(<FindingsHost readOnly />)
expect(screen.queryByLabelText('Citer une référence')).toBeNull()
expect(screen.queryByLabelText('Citer une référence existante')).toBeNull()
// the open form is kept, its fields read-only, « Enregistrer » disabled
expect(screen.getByLabelText('Nom (FR)')).toHaveAttribute('readonly')
expect(screen.getByRole('button', { name: 'Enregistrer' })).toBeDisabled()
@@ -223,7 +223,7 @@ describe('opening', () => {
expect(panel()).not.toHaveTextContent('Denoix')
})
it('view mode: an open tile marks the current finding, « Aller à » only; « Modifier » is the dialog’s', async () => {
it('a tile marks the finding, « Aller à » only; « Modifier » on the dialog', async () => {
const user = await mount()
await openFromFinding(user)
await user.click(within(panel()).getByRole('button', { name: /^Barone/ }))
+3 -2
View File
@@ -18,12 +18,13 @@ describe('i18n dicts', () => {
})
describe('the delete hint of a cited reference (final review rev 4, item 2)', () => {
it('names the buttons of each step: « Aller à », « Modifier », « Retirer »', () => {
it('names each step: « Aller à », « X références », « Modifier », « Retirer »', () => {
for (const dict of [fr, en]) {
const hint = dict['editor.references.delete_hint']
const labels = [
dict['editor.references.go_to'],
dict['editor.findings.edit'],
dict['editor.findings.references_open_other'].replace('{count}', 'X'),
dict['editor.citations.edit'],
dict['editor.action.remove'],
]
const at = labels.map((label) => hint.indexOf(label))