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()
@@ -41,6 +41,12 @@ function Page({
>
<div data-editor-workspace>
<EditorTabs active={active} tier="small" onSelect={setActive} />
<div
id={`editor-panel-${active}`}
role="tabpanel"
tabIndex={-1}
aria-label={active}
/>
<button type="button">outside</button>
</div>
<button type="button" onClick={() => setActive('general')}>
@@ -91,6 +97,35 @@ describe('the overlay', () => {
})
})
describe('the panel takes the focus after a pick', () => {
it('Enter on an entry focuses the panel of that tab once the list is gone', async () => {
const { user } = mount()
await user.click(more())
screen.getByRole('button', { name: 'Constats' }).focus()
await user.keyboard('{Enter}')
await gone()
expect(document.activeElement).toBe(
document.getElementById('editor-panel-findings'),
)
})
it('a pointer pick does the same', async () => {
const { user } = mount()
await user.click(more())
await user.click(screen.getByRole('button', { name: 'Constats' }))
expect(document.activeElement).toBe(
document.getElementById('editor-panel-findings'),
)
})
it('Escape still returns the focus to « Plus »', async () => {
const { user } = mount()
await user.click(more())
await user.keyboard('{Escape}')
expect(document.activeElement).toBe(more())
})
})
describe('the render-time reset', () => {
it('a new active tab closes the open menu with no click in the row', async () => {
const { user, force } = mount()
@@ -143,6 +143,7 @@ describe('tabs', () => {
expect(screen.getByTestId('editor-tab-findings')).toBeInTheDocument()
expect(screen.getByTestId('editor-tab-annotations')).not.toBeVisible()
expect(screen.getByRole('tabpanel')).toHaveAccessibleName('Constats')
expect(screen.getByRole('tabpanel')).toHaveAttribute('tabindex', '-1')
})
it('640 to 1 023 px: the five tabs, no « Plus », the row may wrap', async () => {