test(tests): prove the line and redraw fixes without a shift

Final review M-3, M-4, M-5, M-6 in the sandbox suites:
- editor-annotations (A14 at 1024, 1180, 1280 px): « Défaire » on the
  line hit-tested 44 px tall below xl and 36 px from xl, its pill 36
  px; pressed under expectNoShift, the drawing then has the focus.
- editor-geometry: the same refused move twice under expectNoShift is
  a new alert pill.
- editor-zones: « Redessiner » takes the focus back after a close and
  a cancel; with the strip scrolled out and the focus on body, the
  close returns it with no scroll.

Tests: no assertion removed.
This commit is contained in:
bchanot committed 2026-11-18 13:21:32 +01:00
1 parent a6685a04e0
commit f2bf442ecd
3 files changed
+91 -17

No files matched your search

+44 -17
View File
@@ -417,29 +417,56 @@ test.describe('editor annotations (A3)', () => {
.evaluate((span) => span.scrollWidth > span.clientWidth)
expect(cut, 'the message is cut short').toBe(false)
// M-5: « Défaire » answers 44 px tall below xl (36 px from xl), the pill unchanged.
// In view first: a point outside the viewport hits nothing. The scroll is put back
// after « Défaire » below, so the steps after it press their buttons in place.
const scrolled = await page.evaluate(() => window.scrollY)
const undoOnLine = line(page).getByRole('button', {
name: dict['editor.history.undo_title'],
})
await undoOnLine.evaluate((button) =>
button.scrollIntoView({ block: 'center' }),
)
const reach = width < 1280 ? 44 : 36
const hit = await line(page)
.getByRole('button', { name: dict['editor.history.undo_title'] })
.evaluate(
(button, half) => {
const box = button.getBoundingClientRect()
const x = box.left + box.width / 2
const mid = box.top + box.height / 2
const at = (dy: number) => document.elementFromPoint(x, mid + dy)
const pill = button.closest('[data-testid="gesture-message"]')!
return {
top: at(-half) === button,
bottom: at(half) === button,
pill: pill.getBoundingClientRect().height,
}
},
reach / 2 - 1,
)
const hit = await undoOnLine.evaluate(
(button, half) => {
const box = button.getBoundingClientRect()
const x = box.left + box.width / 2
const mid = box.top + box.height / 2
const at = (dy: number) => document.elementFromPoint(x, mid + dy)
const pill = button.closest('[data-testid="gesture-message"]')!
return {
top: at(-half) === button,
bottom: at(half) === button,
pill: pill.getBoundingClientRect().height,
}
},
reach / 2 - 1,
)
expect(hit, `a ${reach} px hit area at ${width} px`).toEqual({
top: true,
bottom: true,
pill: 36,
})
// M-4: the line's « Défaire »: the drawing takes the focus, nothing moves or scrolls.
await expectNoShift(page, async () => {
await undoOnLine.click()
await expect(line(page)).not.toContainText(
dict['editor.annotations.message.moved.point'],
)
})
await expect(
page.locator(
'[data-place="annotations.drawing"] [role="group"][tabindex="0"]',
),
).toBeFocused()
// Moved again: the message whose expiry is checked next.
await expectNoShift(page, async () => {
await dragPoint(page, { x: 560, y: 330 })
await expect(line(page)).toContainText(
dict['editor.annotations.message.moved.point'],
)
})
await page.evaluate((y) => window.scrollTo(0, y), scrolled)
// Its expiry, 6 s later.
await expectNoShift(page, async () => {
await page.clock.fastForward(6_100)