fix(editor): citation notices, literal citation text, local limits
This commit is contained in:
1 parent
c93787c947
commit
3e94f732c7
5 files changed
+152
-61
No files matched your search
@@ -583,9 +583,11 @@ describe('the reference dialog over the edit mode', () => {
|
||||
const row = pendingRow()
|
||||
expect(within(row).getByText('Neuf')).toBeVisible()
|
||||
expect(within(row).getByText('Nouvelle')).toBeVisible()
|
||||
expect(status()).toBe(
|
||||
'Nouvelle référence citée dans le brouillon : Neuf. ' +
|
||||
'Elle sera enregistrée avec les citations.',
|
||||
await waitFor(() =>
|
||||
expect(status()).toBe(
|
||||
'Nouvelle référence citée dans le brouillon : Neuf. ' +
|
||||
'Elle sera enregistrée avec les citations.',
|
||||
),
|
||||
)
|
||||
expect(live()).not.toContain('sera enregistrée')
|
||||
expect(undos()).toBe(0)
|
||||
@@ -775,6 +777,68 @@ describe('the reference dialog over the edit mode', () => {
|
||||
observer.disconnect()
|
||||
expect(seen.filter((text) => text !== '')).toEqual([])
|
||||
})
|
||||
|
||||
it('a notice still waiting when the edit mode ends is dropped, not shown later', async () => {
|
||||
const user = await mount()
|
||||
await editCitations(user)
|
||||
await user.click(button('Nouvelle référence'))
|
||||
await waitFor(() => expect(referenceDialog()).toBeDefined())
|
||||
await user.selectOptions(inReference().getByLabelText('Type'), 'book')
|
||||
await user.type(inReference().getByLabelText('Citation'), 'Neuf')
|
||||
// The focus never comes back into the dialog: the notice keeps waiting.
|
||||
const focus = vi
|
||||
.spyOn(HTMLElement.prototype, 'focus')
|
||||
.mockImplementation(() => undefined)
|
||||
await user.click(
|
||||
inReference().getByRole('button', { name: 'Ajouter la référence' }),
|
||||
)
|
||||
await waitFor(() => expect(referenceDialog()).toBeUndefined())
|
||||
expect(status()).toBe('')
|
||||
fireEvent.click(button('Enregistrer'))
|
||||
await waitFor(() => expect(button('Modifier')).toBeVisible())
|
||||
focus.mockRestore()
|
||||
fireEvent.click(button('Modifier'))
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
document.activeElement?.closest('form[data-draft-form]'),
|
||||
).not.toBeNull(),
|
||||
)
|
||||
expect(status()).not.toContain('Nouvelle référence')
|
||||
})
|
||||
|
||||
it('the draft notice goes with the next draft action: cite, remove, new', async () => {
|
||||
const user = await mount()
|
||||
await editCitations(user)
|
||||
await user.click(button('Nouvelle référence'))
|
||||
await createPending(user, 'Neuf')
|
||||
await waitFor(() => expect(status()).toContain('Neuf'))
|
||||
await cite(user, 'ref-b')
|
||||
expect(status()).toBe('')
|
||||
await user.click(button('Nouvelle référence'))
|
||||
await createPending(user, 'Vieux')
|
||||
await waitFor(() => expect(status()).toContain('Vieux'))
|
||||
await removeRow(user, /Code rural/)
|
||||
expect(status()).toBe('')
|
||||
await user.click(button('Nouvelle référence'))
|
||||
await waitFor(() => expect(referenceDialog()).toBeDefined())
|
||||
expect(status()).toBe('')
|
||||
})
|
||||
|
||||
it('a citation holding « $& » reaches every notice as typed', async () => {
|
||||
const user = await mount()
|
||||
await editCitations(user)
|
||||
await user.click(button('Nouvelle référence'))
|
||||
await createPending(user, 'A$&B')
|
||||
await waitFor(() => expect(status()).toContain('A$&B'))
|
||||
expect(status()).not.toContain('{citation}')
|
||||
minted.push('ref-a', 'ref-c')
|
||||
await user.click(button('Enregistrer'))
|
||||
expect(inCitations().getByRole('alert')).toHaveTextContent('A$&B')
|
||||
expect(inCitations().getByRole('alert')).not.toHaveTextContent('{citation}')
|
||||
await removeRow(user, /A\$&B/)
|
||||
expect(status()).toContain('A$&B')
|
||||
expect(status()).not.toContain('{citation}')
|
||||
})
|
||||
})
|
||||
|
||||
describe('a save of the edit form when its element is unreadable', () => {
|
||||
|
||||
Reference in new issue
Block a user