fix(editor): deletion undo and Back, Plus focus to the panel

This commit is contained in:
bchanot committed 2026-11-14 14:24:06 +01:00
1 parent 270444e2ec
commit 085c56877c
14 files changed
+252 -18

No files matched your search

@@ -165,6 +165,51 @@ describe('opening', () => {
})
})
/** Deletes the open dialog's element through its confirmation. */
async function deleteOpen(user: User) {
await user.click(inDialog().getByRole('button', { name: 'Supprimer' }))
const confirm = await screen.findAllByRole('button', { name: 'Supprimer' })
await user.click(confirm[confirm.length - 1])
await closed()
}
describe('deleting (owner item 3)', () => {
it('closes the dialog by popping its entry: the first Back moves', async () => {
const user = await mount()
await openFinding(user, /Node A/)
await deleteOpen(user)
expect(written()?.view.finding).toBeNull()
expect(written()?.view.tab).toBe('findings')
await back()
await waitFor(() => expect(written()?.view.tab).not.toBe('findings'))
})
it('one « Défaire » restores the row, selected, shown and focused', async () => {
const user = await mount()
await openFinding(user, /Node A/)
await deleteOpen(user)
expect(screen.queryByRole('treeitem', { name: /Node A/ })).toBeNull()
await user.click(screen.getByRole('button', { name: /^Défaire/ }))
const row = await screen.findByRole('treeitem', { name: /Node A/ })
expect(row).toHaveAttribute('aria-selected', 'true')
await waitFor(() => expect(row).toHaveFocus())
})
it('« Refaire » of a creation shows its row the same way', async () => {
const user = await mount()
await openFinding(user, /Node A/)
await deleteOpen(user)
await user.click(screen.getByRole('button', { name: /^Défaire/ }))
await user.click(screen.getByRole('button', { name: /^Refaire/ }))
await waitFor(() =>
expect(screen.queryByRole('treeitem', { name: /Node A/ })).toBeNull(),
)
await user.click(screen.getByRole('button', { name: /^Défaire/ }))
const row = await screen.findByRole('treeitem', { name: /Node A/ })
await waitFor(() => expect(row).toHaveFocus())
})
})
describe('edit mode', () => {
it('a pristine « Enregistrer » is no command and no entry; a changed one is one', async () => {
const user = await mount()