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)
@@ -235,6 +235,25 @@ test.describe('editor geometry (adversarial)', () => {
await expect(shownShape(page)).toHaveAttribute('cx', '110')
await expect(verification).toContainText(String(errorsBefore))
// M-3: the same refusal again is a new pill, announced again; nothing moves (A14).
const pill = page.getByTestId('gesture-message')
await pill.evaluate((element) => element.setAttribute('data-first', ''))
await expectNoShift(page, () => move.click())
await dragInMode(page, { x: 250, y: 250 }, { x: 260, y: 260 })
await expectNoShift(page, async () => {
await confirm.click()
await expect(
page.locator('[data-testid="gesture-message"]:not([data-first])'),
).toBeVisible()
})
await expect(pill).toHaveCount(1)
await expect(page.getByRole('alert').filter({ has: pill })).toHaveCount(0)
await expect(pill).toHaveAttribute('role', 'alert')
await expect(pill).toContainText(
dict['editor.annotations.message.move_refused'].split(' :')[0],
)
await expect(shownShape(page)).toHaveAttribute('cx', '110')
// Far enough inside, from the page's end: kept, the issue gone, one error less. The
// issue leaving no longer shortens the page (it lives in the strip and the dialog, the
// side column keeps the overview, U2 Task 6), so the scroll clamp moves nothing. The
+28
View File
@@ -217,6 +217,8 @@ test.describe('editor zones on the drawing (U2 Task 5)', () => {
dict['editor.annotations.message.redrawn.zone'],
)
})
// M-6: the focus is back on « Redessiner », which started the redraw.
await expect(button(page, 'editor.annotations.redraw')).toBeFocused()
await expect(selectionTag(page)).toContainText('Vertèbres thoraciques')
expect(await count(page)).toBe(4)
await undoTo(page, () => shownPoints(page), stored)
@@ -242,6 +244,32 @@ test.describe('editor zones on the drawing (U2 Task 5)', () => {
button(page, 'editor.annotations.trace_cancel').click(),
)
await expect.poll(() => shownPoints(page)).toEqual(stored)
await expect(button(page, 'editor.annotations.redraw')).toBeFocused()
// M-6: the strip out of view, the focus on body, the close pressed in place (no scroll
// into view): the focus goes back to « Redessiner » without a scroll (A14).
await expectNoShift(page, () =>
button(page, 'editor.annotations.redraw').click(),
)
for (const [x, y] of [
[850, 440],
[1100, 470],
[1100, 560],
[850, 545],
])
await expectNoShift(page, () => clickAt(page, x, y))
const strip = (await page.getByTestId('edit-strip').boundingBox())!
await page.evaluate((by) => window.scrollBy(0, by), strip.y + strip.height)
await page.evaluate(() => (document.activeElement as HTMLElement).blur())
await expectNoShift(page, async () => {
await button(page, 'editor.annotations.trace_close').dispatchEvent(
'click',
)
await expect(line(page)).toContainText(
dict['editor.annotations.message.redrawn.zone'],
)
})
await expect(button(page, 'editor.annotations.redraw')).toBeFocused()
})
test('a click inside Thoraciques on C7-T1 selects the point drawn on top', async ({