fix(editor): gesture line alerts, focus after « Défaire », hit area

Final review M-3, M-4, M-5, M-8.
- M-3: the line and the strip render a refusal's role="alert" beside
  their always-mounted role="status" region, never inside it; every
  shown message carries a serial that keys its pill, so a repeated
  identical refusal is a new pill and is announced again.
- M-4: after the line's « Défaire » the focus goes to the canvas box.
- M-5: « Défaire » gets a transparent ::before, 44 px tall below xl
  (36 px from xl), within the row's reserved 44 px: the pill keeps
  its 36 px. The A14 e2e checks the hit area at 1024, 1180, 1280 px.
- M-8: the « swallows the click on a marker » test fired a click the
  canvas ignores since T2; the inert click is dropped, the title says
  what the taps prove.

Tests rewritten: « the message sits on its own row »: role="status" on
the row → a role="status" region inside the row, empty at rest.
« a mouse tap deselects … swallows the click »: the final
fireEvent.click on the marker removed (inert), its isDeselected
assertion kept after the second tap.
This commit is contained in:
bchanot committed 2026-11-18 13:00:22 +01:00
1 parent e299c3d4f6
commit 13e2503e6a
5 files changed
+143 -28

No files matched your search

@@ -1552,13 +1552,14 @@ describe('a tap on the drawing (D6b)', () => {
expect(isDeselected()).toBe(false)
})
it('a mouse tap deselects at the pointer-up and swallows the click on a marker', async () => {
// Final review M-8: since T2 a `click` on the canvas does nothing, so the click this test
// fired on a marker could not change the outcome; it is gone, the taps are the test.
it('a mouse tap deselects at the pointer-up; another tap on the empty drawing keeps it so', async () => {
await selected({ text: insert(text(), named('anno-b', 90, 90, 3)) })
tap(rect(), { upOn: rect() })
expect(isDeselected()).toBe(true)
fireEvent.pointerDown(rect(), { ...init(), clientX: 10, clientY: 10 })
fireEvent.pointerUp(rect(), { ...init(), clientX: 10, clientY: 10 })
fireEvent.click(marker('anno-b'))
expect(isDeselected()).toBe(true)
})
@@ -1841,7 +1842,55 @@ describe('the strip', () => {
const add = screen.getByRole('button', { name: 'Ajouter un point' })
expect(line()).not.toContainElement(add)
expect(line()).toHaveClass('h-11', 'overflow-hidden')
expect(line()).toHaveAttribute('role', 'status')
// M-3: the polite region is inside the row, always mounted, empty at rest.
expect(within(line()).getByRole('status')).toBeEmptyDOMElement()
})
it('M-3: a refusal is an alert outside any status region, in the line and the strip', async () => {
await mount()
await selectFromList()
drag(marker('anno-a'), [98, 50])
const alert = within(line()).getByRole('alert')
expect(alert.closest('[role="status"]')).toBeNull()
render(
<EditStrip
lead={{ title: 'T', detail: 'Zone', icon: 'zone' }}
notice={{ tone: 'error', text: 'Problème' }}
commands={null}
/>,
)
const strip = screen.getAllByTestId('edit-strip-notice').at(-1)!
const issue = within(strip).getByRole('alert')
expect(issue.closest('[role="status"]')).toBeNull()
expect(within(strip).getByRole('status')).toBeEmptyDOMElement()
})
it('M-3: the same refusal twice is a new pill, announced again', async () => {
await mount()
await selectFromList()
drag(marker('anno-a'), [98, 50])
const first = within(line()).getByRole('alert')
drag(marker('anno-a'), [98, 50])
const second = within(line()).getByRole('alert')
expect(second).toHaveTextContent(first.textContent!)
expect(second).not.toBe(first)
})
it("M-4: after the line's « Défaire » the focus is on the drawing, not lost", async () => {
await mount()
await selectFromList()
drag(marker('anno-a'), [60, 40])
const undo = within(line()).getByRole('button', {
name: 'Défaire la dernière modification',
})
await userEvent.setup().click(undo)
expect(line()).not.toHaveTextContent('Point déplacé')
expect(document.activeElement).toBe(
document.querySelector(
'[data-place="annotations.drawing"] [role="group"][tabindex="0"]',
),
)
expect(document.activeElement).not.toBe(document.body)
})
it('an undo then a redo never brings the message back', async () => {