fix(editor): stale cite choice reset, pending line under the add row

This commit is contained in:
bchanot committed 2026-11-15 20:00:28 +01:00
1 parent 70eb2fcbb4
commit 1d119c3684
6 files changed
+91 -29

No files matched your search

@@ -344,6 +344,8 @@ describe('« Citer » (Rev 6)', () => {
await editCitations(user)
expect(citeButton()).toBeDisabled()
await user.selectOptions(select(), 'ref-b')
// happy-dom moves nothing on a key: this covers the change event only. The real
// ArrowDown is proven in Chromium (e2e/shell/editor-citations.spec.ts, keyboard test).
fireEvent.keyDown(select(), { key: 'ArrowDown' })
fireEvent.change(select(), { target: { value: 'ref-b' } })
expect(rows()).toEqual(['ref-a', 'ref-c'])
@@ -387,6 +389,32 @@ describe('« Citer » (Rev 6)', () => {
expect(citeButton()).toBeDisabled()
})
it('a vanished choice stays reset when its reference comes back by an undo', async () => {
const user = await mount()
await editCitations(user)
await user.selectOptions(select(), 'ref-b')
await user.click(button('Enregistrer'))
expect(inCitations().getByRole('alert')).toBeInTheDocument()
act(() => {
store.getState().commit({
op: 'remove',
key: { kind: 'reference', id: 'ref-b' },
})
})
await waitFor(() => expect(select()).toHaveValue(''))
act(() => {
store.getState().undoStep()
})
await waitFor(() =>
expect(
inCitations().getByRole('option', { name: 'Denoix' }),
).toBeInTheDocument(),
)
expect(select()).toHaveValue('')
expect(citeButton()).toBeDisabled()
expect(inCitations().queryByRole('alert')).toBeNull()
})
it('« Enregistrer » with a choice not cited refuses: the line, focus on « Citer »', async () => {
const user = await mount()
await editCitations(user)