fix(editor): « − » press follows Delete, discriminating focus tests

This commit is contained in:
bchanot committed 2026-11-19 12:00:48 +01:00
1 parent 03e85a7c67
commit 62b400e876
9 files changed
+131 -45

No files matched your search

+45 -17
View File
@@ -750,16 +750,30 @@ describe('Safari: « Déplacer le point » clicked with the focus left on the sl
})
describe('Safari: the focus after a press that commits a pending change', () => {
const tapDrag = (el: Element) => {
const init = {
pointerId: 1,
isPrimary: true,
button: 0,
buttons: 1,
pointerType: 'mouse',
}
fireEvent.pointerDown(el, { ...init, clientX: 50, clientY: 50 })
fireEvent.pointerMove(el, { ...init, clientX: 80, clientY: 80 })
const init = {
pointerId: 1,
isPrimary: true,
button: 0,
buttons: 1,
pointerType: 'mouse',
}
const hit = () => handle().querySelector('[data-handle]')!
/** A finger on the handle that moves past the slop and lets go: a drag and its drop. */
const dragHandle = () => {
fireEvent.pointerDown(hit(), { ...init, clientX: 50, clientY: 50 })
fireEvent.pointerMove(hit(), { ...init, clientX: 80, clientY: 80 })
fireEvent.pointerUp(hit(), {
...init,
buttons: 0,
clientX: 80,
clientY: 80,
})
}
/** The focus seen by every document change: at the commit, not after a later move. */
function watchCommitFocus(): Array<Element | null> {
const seen: Array<Element | null> = []
store.subscribe(() => seen.push(document.activeElement))
return seen
}
it('a press on the point handle commits the slider change and focuses the handle', async () => {
@@ -768,8 +782,10 @@ describe('Safari: the focus after a press that commits a pending change', () =>
act(() => slider().focus())
fireEvent.keyDown(slider(), { key: 'PageUp' })
const before = depth()
tapDrag(handle().querySelector('[data-handle]')!)
expect(depth()).toBe(before + 1)
const seen = watchCommitFocus()
dragHandle()
expect(depth()).toBe(before + 2)
expect(seen[0]).toBe(slider())
expect(document.activeElement).toBe(handle())
})
@@ -779,17 +795,29 @@ describe('Safari: the focus after a press that commits a pending change', () =>
act(() => handle().focus())
fireEvent.keyDown(handle(), { key: 'ArrowRight' })
const before = depth()
tapDrag(handle().querySelector('[data-handle]')!)
expect(depth()).toBe(before + 1)
const seen = watchCommitFocus()
dragHandle()
expect(depth()).toBe(before + 2)
expect(seen[0]).toBe(handle())
expect(document.activeElement).toBe(handle())
})
it('« Redessiner » and « Désélectionner » never leave the focus on body', async () => {
await mount(withPoints(point('a', 50, 50, 5)))
it('« Déplacer le point » focuses the first arrow', async () => {
await mount(withPoints(point('a', 50, 50, 5), point('b', 20, 20, 8)))
await select()
act(() => slider().focus())
fireEvent.keyDown(slider(), { key: 'PageUp' })
fireEvent.click(moveButton())
expect(document.activeElement).toBe(within(bar()).getAllByRole('button')[0])
})
it('« Désélectionner » focuses the row', async () => {
await mount(withPoints(point('a', 50, 50, 5), point('b', 20, 20, 8)))
await select()
act(() => slider().focus())
fireEvent.keyDown(slider(), { key: 'PageUp' })
fireEvent.click(screen.getByRole('button', { name: 'Désélectionner' }))
expect(document.activeElement).not.toBe(document.body)
const list = screen.getByRole('list', { name: 'Annotations de la vue' })
expect(document.activeElement).toBe(within(list).getAllByRole('button')[0])
})
})