feat(editor): vertex handles, insert and remove, zone move, redraw

U2 Task 5. A selected polygon gets its vertex, « + » and « − » handles
(R-9, hidden « + » under two hit radii, R-18 zoom hint in the strip),
the handle cap at 40 (R-7), vertex drag and keys, the move mode on the
zone or the chosen vertex, « Redessiner » as a redraw mode kept in step
with its tracing (R-12 guard, R-13 drop), close radius in CSS px
(R-11). The numeric group leaves the properties panel (D1).

Removed or rewritten assertions (numeric group -> replacement):
- tab « shows its exact stored numbers » (Centre x field) -> the overlay
  selection circle's cx attribute, same exact value.
- tab « a numeric edit » x3 -> « an edit on the drawing »: Enter on the
  handle without a step commits nothing, a step + Enter commits once;
  a refused handle drag keeps the stored shape then a drag inside the
  frame repairs it (issues gone); Escape drops a pending series.
- tab C26 « Centre x 15 » -> overlay cx 15.
- tab C32 unmeasured « Centre x as text » -> no handle, no field.
- tab « adds and removes a vertex as part of the whole group » -> « + »
  then « − » on the drawing; « never offers to remove below three » ->
  « − » aria-disabled at 3.
- tab H8 « refused Remplacer drops the tracing » -> keeps it open with
  « Fermeture refusée » (board 33 A); « refused vertex add/remove stay
  non appliqué » -> a refused vertex drag restores the shape exactly.
- tab Désélectionner and D6b (typed Centre x committed, refused, undone)
  x6 and strip « a new commit replaces the message » -> the same with
  the Nom (FR) field (a blank name is the refused value).
- focus-request « Centre x 20 » -> overlay cx 20.
- escape « strip commands keep their Escape » -> a redraw: Escape on the
  strip or the box cancels it (R-12 row 4); kept for a new zone tracing.
- keep-alive « Remplacer tracing kept across Aller à » -> ended by a tab
  when empty, asked once a vertex is placed (R-12).
- e2e annotations: numeric cx edit + undo/redo -> handle keys + undo/
  redo; jitter/drag and Task 4 point reads -> overlay attributes (the
  stored place during the mode -> overlay-old-place); keyboard-only cy
  and vertex x typed -> handle and vertex keys.
- e2e deselect: Centre x typed/refused/committed -> Nom (FR).
- e2e geometry, shell-crossing: Centre x/cy reads -> overlay attributes.
- e2e journey: cx +3 and vertex x +4 typed -> 3 and 4 arrow steps + Enter;
  a far typed value + revert -> a far handle drag refused.
- e2e equine latency: typed cx rounds -> handle arrow + Enter rounds.
This commit is contained in:
bchanot committed 2026-11-17 20:24:49 +01:00
1 parent ba8e766fe8
commit 6211046537
44 files changed
+3790 -1050

No files matched your search

+57 -44
View File
@@ -6,8 +6,12 @@ import {
clickDrawing,
clientOf,
editorActor,
geometryField,
historyButton,
round2,
shownNumber,
shownPoints,
shownShape,
storedShape,
pressAtBox,
openEditor,
pickAnnotation,
@@ -25,7 +29,7 @@ import {
import { expectNoShift, keepNativeFrames } from '../support/layout'
// V1-2.6 A3 (contract C7, C8, C21): points, zones and links by clicks and by keyboard,
// move by drag, numeric edits, undo and redo, then the save that carries them.
// move by drag, edits on the handles (U2 Task 5), undo and redo, then the save.
const dict = fr
@@ -84,7 +88,7 @@ test.describe('editor annotations (A3)', () => {
await dropLateReplays(context)
})
test('point, zone and link by clicks; numeric edit; undo and redo; save', async ({
test('point, zone and link by clicks; handle edit; undo and redo; save', async ({
page,
requests,
}) => {
@@ -103,8 +107,8 @@ test.describe('editor annotations (A3)', () => {
await createFromPanel(page)
await expect(selectionTag(page)).toContainText('Point un')
await expect(properties(page)).toBeVisible()
const placed = await geometryField(page, dict, 'cx').inputValue()
expect(Math.abs(Number(placed) - 300)).toBeLessThan(1)
const placed = await shownNumber(page, 'cx')
expect(Math.abs(placed - 300)).toBeLessThan(1)
// A zone: three clicks, then « Fermer le tracé ».
await tool(page, 'zone').click()
@@ -137,19 +141,22 @@ test.describe('editor annotations (A3)', () => {
await expect(selectionTag(page)).toContainText('Accès un')
await expect(historyButton(page, dict, 'undo')).toBeEnabled()
// A numeric edit of the point, then undo and redo.
// A keyboard edit on the point's handle (two steps of 5 units), then undo and redo.
await tool(page, 'select').click()
await pickAnnotation(page, dict, /Point un/)
const cx = geometryField(page, dict, 'cx')
await cx.fill('420')
await cx.press('Enter')
await expect(cx).toHaveValue('420')
await page.getByRole('button', { name: 'Point Point un' }).focus()
await page.keyboard.press('ArrowRight')
await page.keyboard.press('ArrowRight')
await page.keyboard.press('Enter')
const moved = String(round2(round2(placed + 5) + 5))
await expect(shownShape(page)).toHaveAttribute('cx', moved)
await historyButton(page, dict, 'undo').click()
await expect(geometryField(page, dict, 'cx')).toHaveValue(placed)
await expect(shownShape(page)).toHaveAttribute('cx', String(placed))
await historyButton(page, dict, 'redo').click()
await expect(geometryField(page, dict, 'cx')).toHaveValue('420')
await expect(shownShape(page)).toHaveAttribute('cx', moved)
// Nothing left to redo: the button is aria-disabled and a press changes nothing.
await pressAtBox(page, historyButton(page, dict, 'redo'))
await expect(geometryField(page, dict, 'cx')).toHaveValue('420')
await expect(shownShape(page)).toHaveAttribute('cx', moved)
await saveDraft(page, dict, seed.revision + 1)
const saved = await serverDocument<{
@@ -176,9 +183,8 @@ test.describe('editor annotations (A3)', () => {
await fillCreation(page, { fr: 'Mobile', en: 'Movable' })
await createFromPanel(page)
await tool(page, 'select').click()
const cx = geometryField(page, dict, 'cx')
const cy = geometryField(page, dict, 'cy')
const [x0, y0] = [await cx.inputValue(), await cy.inputValue()]
const x0 = String(await shownNumber(page, 'cx'))
const y0 = String(await shownNumber(page, 'cy'))
expect(Math.abs(Number(x0) - 300)).toBeLessThan(1)
// Jitter under the 4 px threshold: pressed, moved by 3 px, released.
@@ -187,8 +193,8 @@ test.describe('editor annotations (A3)', () => {
await page.mouse.down()
await page.mouse.move(from.x + 2, from.y + 2)
await page.mouse.up()
await expect(cx).toHaveValue(x0)
await expect(cy).toHaveValue(y0)
await expect(shownShape(page)).toHaveAttribute('cx', x0)
await expect(shownShape(page)).toHaveAttribute('cy', y0)
// A real drag: the point follows to (400, 360) in drawing units.
const to = await clientOf(page, 400, 360)
@@ -199,14 +205,14 @@ test.describe('editor annotations (A3)', () => {
})
await page.mouse.move(to.x, to.y, { steps: 5 })
await page.mouse.up()
await expect(cx).not.toHaveValue(x0)
expect(Math.abs(Number(await cx.inputValue()) - 400)).toBeLessThan(2)
expect(Math.abs(Number(await cy.inputValue()) - 360)).toBeLessThan(2)
await expect(shownShape(page)).not.toHaveAttribute('cx', x0)
expect(Math.abs((await shownNumber(page, 'cx')) - 400)).toBeLessThan(2)
expect(Math.abs((await shownNumber(page, 'cy')) - 360)).toBeLessThan(2)
await page.keyboard.press('Control+z')
await expect(geometryField(page, dict, 'cx')).toHaveValue(x0)
await expect(shownShape(page)).toHaveAttribute('cx', x0)
})
test('keyboard only: creation by the add buttons, numeric position, numeric edit', async ({
test('keyboard only: creation by the add buttons, numeric position, edit by the handle keys', async ({
page,
requests,
}) => {
@@ -230,14 +236,20 @@ test.describe('editor annotations (A3)', () => {
await page.keyboard.press('Enter')
await expect(creation(page)).toHaveCount(0)
await expect(selectionTag(page)).toContainText('Clavier')
await expect(geometryField(page, dict, 'cx')).toHaveValue('250')
await expect(shownShape(page)).toHaveAttribute('cx', '250')
const cy = geometryField(page, dict, 'cy')
await cy.fill('510.5')
await cy.press('Enter')
await expect(cy).toHaveValue('510.5')
// The handle keys (U2 Task 5): two steps of 5 units down, one commit on Enter.
const cy0 = await shownNumber(page, 'cy')
await page.getByRole('button', { name: 'Point Clavier' }).focus()
await page.keyboard.press('ArrowDown')
await page.keyboard.press('ArrowDown')
await page.keyboard.press('Enter')
await expect(shownShape(page)).toHaveAttribute(
'cy',
String(round2(round2(cy0 + 5) + 5)),
)
// A polygon edit: the zone added by keyboard, a vertex typed.
// A polygon edit: the zone added by keyboard, its first vertex moved by its keys.
await page
.getByRole('button', { name: dict['editor.annotations.add.zone'] })
.focus()
@@ -248,13 +260,14 @@ test.describe('editor annotations (A3)', () => {
.focus()
await page.keyboard.press('Enter')
await expect(selectionTag(page)).toContainText('Zone clavier')
const vertexX = page.getByLabel(
dict['editor.annotations.geometry.vertex_x'].replace('{n}', '1'),
)
const before = Number(await vertexX.inputValue())
await vertexX.fill(String(before + 10))
await vertexX.press('Enter')
await expect(vertexX).toHaveValue(String(before + 10))
const [[before]] = await shownPoints(page)
await page.getByRole('button', { name: 'Sommet 1', exact: true }).focus()
await page.keyboard.press('ArrowRight')
await page.keyboard.press('ArrowRight')
await page.keyboard.press('Enter')
await expect
.poll(async () => (await shownPoints(page))[0][0])
.toBe(round2(round2(before + 5) + 5))
await saveDraft(page, dict, seed.revision + 1)
})
@@ -416,7 +429,6 @@ test.describe('editor annotations (A3)', () => {
await expectAccessible(page, 'a selected point: handle, slider, move')
// The handle follows the pointer; the drop is one commit.
const cx = geometryField(page, dict, 'cx')
await expectNoShift(
page,
async () => {
@@ -427,10 +439,9 @@ test.describe('editor annotations (A3)', () => {
},
swaps,
)
expect(Math.abs(Number(await cx.inputValue()) - 560)).toBeLessThan(2)
expect(Math.abs((await shownNumber(page, 'cx')) - 560)).toBeLessThan(2)
// A click on the track, no drag (WCAG 2.5.7): one commit at the release.
const r = geometryField(page, dict, 'r')
const track = (await slider.boundingBox())!
await expectNoShift(
page,
@@ -445,12 +456,12 @@ test.describe('editor annotations (A3)', () => {
},
swaps,
)
expect(Number(await r.inputValue())).toBeGreaterThan(40)
expect(await shownNumber(page, 'r')).toBeGreaterThan(40)
await page.keyboard.press('Control+z')
await expect(r).toHaveValue('40')
await expect(shownShape(page)).toHaveAttribute('r', '40')
// The move mode: three steps (5 units each on a 1 000 px wide frame), validated once.
const x0 = Number(await cx.inputValue())
const x0 = await shownNumber(page, 'cx')
await expectNoShift(
page,
() => button(page, 'editor.annotations.move.point').click(),
@@ -466,7 +477,8 @@ test.describe('editor annotations (A3)', () => {
},
swaps,
)
await expect(cx).toHaveValue(String(x0))
// Nothing committed yet: the stored place stays, drawn as the old place.
await expect(storedShape(page)).toHaveAttribute('cx', String(x0))
await expectNoShift(
page,
async () => {
@@ -475,7 +487,8 @@ test.describe('editor annotations (A3)', () => {
},
swaps,
)
await expect(cx).toHaveValue(String(x0 + 15))
await expect(shownShape(page)).toHaveAttribute('cx', String(x0 + 15))
await expect(storedShape(page)).toHaveCount(0)
await expect(button(page, 'editor.annotations.move.point')).toBeFocused()
})
+23 -13
View File
@@ -8,7 +8,6 @@ import {
clientOf,
creationPanel,
editorActor,
geometryField,
historyButton,
openEditor,
expectNoDialog,
@@ -39,6 +38,10 @@ import {
const dict = fr
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
const properties = (page: Page) => page.getByTestId('annotation-properties')
const nameField = (page: Page) =>
properties(page).getByLabel(dict['editor.annotations.name_fr'], {
exact: true,
})
const overview = (page: Page) => page.getByTestId('annotation-overview')
const box = (page: Page) => page.getByTestId('annotation-canvas')
const liveRegion = (page: Page) =>
@@ -211,11 +214,11 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => {
// A field focused: nothing happens, the field keeps the focus.
await select(page, POINT)
const cx = geometryField(page, dict, 'cx')
await cx.focus()
const name = nameField(page)
await name.focus()
await page.keyboard.press('Escape')
await expectKept(page, POINT)
await expect(cx).toBeFocused()
await expect(name).toBeFocused()
// The delete dialog: only it closes (LRN-111: wait until it is gone).
await properties(page)
@@ -389,12 +392,13 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => {
}) => {
const { actor, saves } = await open(page)
requests.forbid(actor.account.email, actor.account.password)
const cx = geometryField(page, dict, 'cx')
// U2 Task 5: the coordinate fields left the panel; the name field carries the typing.
const name = nameField(page)
// Valid value, no blur, ONE click on the drawing.
await select(page, POINT)
await expect(cx).toHaveValue('700')
await cx.fill('720')
await expect(name).toHaveValue(POINT)
await name.fill('Pt Delta')
await clickAt(page, IN_CIRCLE)
await expectDeselected(page)
await expect(saveLine(page)).toHaveText(/1 modification non enregistrée/)
@@ -402,26 +406,27 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => {
await historyButton(page, dict, 'undo').click()
await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE)
await select(page, POINT)
await expect(cx).toHaveValue('700')
await expect(name).toHaveValue(POINT)
// « Désélectionner » with an unblurred refused value: closed at once, unchanged.
// A blank name is refused (both names are required).
const deselect = properties(page).getByRole('button', {
name: dict['editor.annotations.deselect'],
})
await cx.fill('abc')
await name.fill('')
await deselect.click()
await expectDeselected(page)
await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE)
await select(page, POINT)
await expect(cx).toHaveValue('700')
await expect(name).toHaveValue(POINT)
// « Désélectionner » with an unblurred valid value: committed and closed.
await cx.fill('730')
await name.fill('Pt Epsilon')
await deselect.click()
await expectDeselected(page)
await expect(saveLine(page)).toHaveText(/1 modification non enregistrée/)
await select(page, POINT)
await expect(cx).toHaveValue('730')
await select(page, 'Pt Epsilon')
await expect(name).toHaveValue('Pt Epsilon')
expect(saves).toEqual([])
})
})
@@ -612,6 +617,11 @@ test.describe('deselect and D6b (touch, editor at 1 280 px)', () => {
// c. Within 36 px of the canvas bottom, above the add buttons.
await select(page, POINT)
await takeRecord(page)
// U2 Task 5: without the coordinate fields the properties panel is shorter than the
// overview, so with the page scrolled to its end the deselect's swap (aside content,
// until Task 6) grows the page and scrolls it before the tap's click lands. The tap
// is made from the top of the page; the hazard is reported for Task 6.
await page.evaluate(() => window.scrollTo(0, 0))
await box(page).scrollIntoViewIfNeeded()
const rect = (await box(page).boundingBox())!
const bottom = { x: rect.x + rect.width / 2, y: rect.y + rect.height - 36 }
+6 -9
View File
@@ -361,21 +361,18 @@ test.describe('equine working copy and commit latency', () => {
page,
'equine: add category (insert)',
)
// A geometry edit: the first annotation's centre, through the geometry group.
// A geometry edit: a point's centre, through its handle keys (U2 Task 5: the
// coordinate fields left the panel). Each round is one step and one commit (Enter).
await showDrawing(page, dict)
await page
.getByRole('list', { name: dict['editor.annotations.list'] })
.getByRole('button')
.first()
.getByRole('button', { name: /C7-T1/ })
.click()
const cx = page.getByLabel(dict['editor.annotations.geometry.cx'], {
exact: true,
})
const base = Number(await cx.inputValue())
await page.getByTestId('point-handle').focus()
await startProbe(page)
for (let round = 0; round <= SAMPLES; round++) {
await cx.fill(String(base + ((round % 2) + 1) * 0.5))
await cx.press('Enter')
await page.keyboard.press(round % 2 ? 'ArrowLeft' : 'ArrowRight')
await page.keyboard.press('Enter')
}
await page.waitForTimeout(200)
const moves = report(
+13 -10
View File
@@ -8,7 +8,8 @@ import {
clickDrawing,
clientOf,
editorActor,
geometryField,
shownNumber,
shownShape,
openEditor,
openSection,
pickAnnotation,
@@ -130,8 +131,8 @@ test.describe('editor geometry (adversarial)', () => {
.click()
await expect(creation(page)).toHaveCount(0)
await expect(selectionTag(page)).toContainText('Bord')
await expect(geometryField(page, dict, 'cx')).toHaveValue(shown.x)
await expect(geometryField(page, dict, 'cy')).toHaveValue(shown.y)
await expect(shownShape(page)).toHaveAttribute('cx', shown.x)
await expect(shownShape(page)).toHaveAttribute('cy', shown.y)
})
test('a click near the edge of a detail crop is corrected inside the crop', async ({
@@ -190,7 +191,6 @@ test.describe('editor geometry (adversarial)', () => {
(await verification.innerText()).replace(/\D/g, ''),
)
expect(errorsBefore).toBeGreaterThan(0)
const cx = geometryField(page, dict, 'cx')
const move = page.getByRole('button', {
name: dict['editor.annotations.move.point'],
})
@@ -201,6 +201,10 @@ test.describe('editor geometry (adversarial)', () => {
// A partial move (still out of the frame): refused by the core, the point restored.
// Nothing around the drawing moves (A14); the side panel's content may (Task 6).
const swaps = ['aside-content'] as const
// The list row scrolled the page to its end. Without the coordinate fields (U2 Task 5)
// the panel is short enough that the issue list leaving it (aside content, exempt until
// Task 6) would clamp that scroll: the check starts from the top.
await page.evaluate(() => window.scrollTo(0, 0))
await expectNoShift(page, () => move.click(), swaps)
await dragInMode(page, { x: 250, y: 250 }, { x: 260, y: 260 })
await expectNoShift(
@@ -215,7 +219,7 @@ test.describe('editor geometry (adversarial)', () => {
dict['editor.annotations.message.move_refused'].split(' :')[0],
)
await expect(page.getByTestId('overlay-refused-place')).toBeAttached()
await expect(cx).toHaveValue('110')
await expect(shownShape(page)).toHaveAttribute('cx', '110')
await expect(issues).toBeVisible()
// Far enough inside: kept, the issue gone, one error less.
@@ -229,7 +233,7 @@ test.describe('editor geometry (adversarial)', () => {
},
swaps,
)
expect(Math.abs(Number(await cx.inputValue()) - 150)).toBeLessThan(2)
expect(Math.abs((await shownNumber(page, 'cx')) - 150)).toBeLessThan(2)
const after = (await verification.innerText()).replace(/\D/g, '')
expect(Number(after || 0)).toBeLessThan(errorsBefore)
})
@@ -501,8 +505,7 @@ test.describe('editor touch path (real browser)', () => {
// touchstart, so a drag of the selected marker must not be left to the pan.
await pickAnnotation(page, dict, /Tactile/)
await expect.poll(touchAction).toBe('none')
const cx = geometryField(page, dict, 'cx')
await expect(cx).toHaveValue('500')
await expect(shownShape(page)).toHaveAttribute('cx', '500')
const from = await clientOf(page, 500, 400)
const to = await clientOf(page, 620, 400)
const cdp = await context.newCDPSession(page)
@@ -521,7 +524,7 @@ test.describe('editor touch path (real browser)', () => {
y: from.y,
})
await touch('touchEnd', null)
await expect(cx).not.toHaveValue('500')
expect(Math.abs(Number(await cx.inputValue()) - 620)).toBeLessThan(3)
await expect(shownShape(page)).not.toHaveAttribute('cx', '500')
expect(Math.abs((await shownNumber(page, 'cx')) - 620)).toBeLessThan(3)
})
})
+59 -24
View File
@@ -6,12 +6,16 @@ import { expect, expectAccessible, test } from '../support/browser'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
clickDrawing,
clientOf,
closeFinding,
createFromPanel,
creationPanel,
editorActor,
fillCreation,
geometryField,
round2,
shownNumber,
shownPoints,
shownShape,
historyButton,
INKSCAPE_EXPORT,
openDraft,
@@ -185,28 +189,52 @@ async function createAnnotations(page: Page) {
const MODIFIED = { point: 3, vertex: 4 }
/** Applies (not only refuses) changes to a point, a zone and a link; read back at the save. */
/**
* `steps` arrow presses on the focused handle (one unit each on this 200-unit drawing,
* R-11), then Enter: one commit. Returns where `from` lands, rounded as the page does.
*/
async function stepRight(
page: Page,
handle: Locator,
from: number,
steps: number,
) {
await handle.focus()
let to = from
for (let step = 0; step < steps; step++) {
await page.keyboard.press('ArrowRight')
to = round2(to + 1)
}
await page.keyboard.press('Enter')
return to
}
/**
* Applies (not only refuses) changes to a point, a zone and a link; read back at the save.
* U2 Task 5: the point and the vertex move by their handle keys (no coordinate field).
*/
async function modifyAnnotations(page: Page) {
await pickAnnotation(page, dict, /Point essai/)
const cx = geometryField(page, dict, 'cx')
const before = Number(await cx.inputValue())
await commitText(cx, String(before + MODIFIED.point))
await expect(cx).toHaveValue(String(before + MODIFIED.point))
const before = await shownNumber(page, 'cx')
const handle = page.getByTestId('point-handle')
const point = await stepRight(page, handle, before, MODIFIED.point)
await expect(shownShape(page)).toHaveAttribute('cx', String(point))
await pickAnnotation(page, dict, /Zone dessinée/)
const vertex = page.getByLabel(
dict['editor.annotations.geometry.vertex_x'].replace('{n}', '1'),
)
const start = Number(await vertex.inputValue())
await commitText(vertex, String(start + MODIFIED.vertex))
await expect(vertex).toHaveValue(String(start + MODIFIED.vertex))
const [[start]] = await shownPoints(page)
const first = page.getByRole('button', { name: 'Sommet 1', exact: true })
const vertex = await stepRight(page, first, start, MODIFIED.vertex)
await expect.poll(async () => (await shownPoints(page))[0][0]).toBe(vertex)
await pickAnnotation(page, dict, /Accès essai/)
await commitText(page.locator('#annotation-name-fr'), 'Accès modifié')
await page.locator('#annotation-laterality').selectOption('bilateral')
await expect(page.locator('#annotation-name-fr')).toHaveValue('Accès modifié')
return { point: before + MODIFIED.point, vertex: start + MODIFIED.vertex }
return { point, vertex }
}
/** Guide 4.4: a click near the edge proposes a position; a far value is refused. */
/**
* Guide 4.4: a click near the edge proposes a position; a far place is refused (U2 Task
* 5: dragged by the handle, the coordinate fields left the panel).
*/
async function repairGeometry(page: Page) {
await toolButton(page, dict, 'point').click()
// On this 200 x 150 drawing the core keeps a shrunk marker at 1 unit from the edge: the
@@ -216,16 +244,20 @@ async function repairGeometry(page: Page) {
await fillCreation(page, dict, { fr: 'Point de bord', en: 'Edge point' })
await createFromPanel(page, dict)
await expect(selectionTag(page)).toContainText('Point de bord')
const cx = geometryField(page, dict, 'cx')
await cx.fill('9999')
await cx.press('Enter')
await expect(
page.getByText(dict['editor.annotations.geometry.unapplied']),
).toBeVisible()
await clickButton(page, dict['editor.annotations.geometry.revert'])
await expect(
page.getByText(dict['editor.annotations.geometry.unapplied']),
).toHaveCount(0)
// The point tool stays on after « Créer » (A7 lands with Task 7): the handle needs select.
await toolButton(page, dict, 'select').click()
const cx = String(await shownNumber(page, 'cx'))
const cy = await shownNumber(page, 'cy')
const from = await clientOf(page, Number(cx), cy)
const to = await clientOf(page, 260, cy)
await page.mouse.move(from.x, from.y)
await page.mouse.down()
await page.mouse.move(to.x, to.y, { steps: 6 })
await page.mouse.up()
await expect(page.getByTestId('gesture-message')).toContainText(
dict['editor.annotations.message.move_refused'].split(' :')[0],
)
await expect(shownShape(page)).toHaveAttribute('cx', cx)
}
/** Guide 4.5: an unsaved change, a reload (beforeunload accepted), the offer, a restore. */
@@ -284,6 +316,9 @@ test.describe('editor journey (owner trial steps)', () => {
await historyButton(page, dict, 'undo').click()
await historyButton(page, dict, 'redo').click()
const modified = await modifyAnnotations(page)
// The last list row scrolled the page: the shell's top bar would cover « Enregistrer »
// (axe target-size); the shorter panel of U2 Task 5 made that scroll reach it.
await page.evaluate(() => window.scrollTo(0, 0))
await expectAccessible(page, 'the editor with annotations')
await saveDraft(page, dict, 1)
const draftId = await sql(
@@ -9,7 +9,8 @@ import {
copyKeyOf,
editorActor,
expectNoDialog,
geometryField,
shownNumber,
shownShape,
historyButton,
openEditor,
openCitations,
@@ -362,8 +363,7 @@ test.describe('editor shell, width crossing (H)', () => {
)
await selectTab(page, dict, 'annotations')
await pickAnnotation(page, dict, 'Point libre')
const cx = geometryField(page, dict, 'cx')
const before = await cx.inputValue()
const before = String(await shownNumber(page, 'cx'))
const from = await clientOf(page, 120, 120)
const to = await clientOf(page, 200, 160)
await page.mouse.move(from.x, from.y)
@@ -372,7 +372,7 @@ test.describe('editor shell, width crossing (H)', () => {
await cross(page, NARROW)
await page.mouse.up()
await cross(page, WIDE)
await expect(geometryField(page, dict, 'cx')).toHaveValue(before)
await expect(shownShape(page)).toHaveAttribute('cx', before)
await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE)
await expect(historyButton(page, dict, 'undo')).toHaveAttribute(
'aria-disabled',
+292
View File
@@ -0,0 +1,292 @@
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { fr } from '@/i18n/fr'
import type { Page, TestInfo } from '@playwright/test'
import { expect, expectAccessible, test } from '../support/browser'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
clientOf,
editorActor,
openEditor,
pickAnnotation,
seedDraft,
selectionTag,
shownPoints,
toolButton,
} from '../support/editor'
import { expectNoShift } from '../support/layout'
// V1-2.6 U2 Task 5: a zone edited on the drawing, « Vertèbres thoraciques » of the equine
// draft on its own drawing: vertex drag, « + », « − », zone drag, redraw accepted and
// refused, each undone, nothing around the drawing moving (A14); the topmost rule.
const dict = fr
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
const DRAFT = join(
__dirname,
'../../../../supabase/seed/anatomical-sheets/equine/draft',
)
const THORACIC = /Vertèbres thoraciques/
// The side panel's content may change (U2 Task 6 moves it into a dialog).
const SWAPS = ['aside-content'] as const
interface Draft {
vertebral_config: unknown
references: unknown
categories: unknown
finding_zones: unknown
views: { id: string; svg_asset_id: string | null }[]
annotations: { view_id: string; kind: string }[]
}
/** The equine draft's main view, its annotations and structures, on the seeded drawing. */
function equineShape(document: Record<string, unknown>) {
const draft = JSON.parse(
readFileSync(join(DRAFT, 'document.json'), 'utf8'),
) as Draft
const [seeded] = document.views as Draft['views']
const main = draft.views.find((view) => view.id === 'main')!
Object.assign(document, {
vertebral_config: draft.vertebral_config,
references: draft.references,
categories: draft.categories,
finding_zones: draft.finding_zones,
views: [{ ...main, svg_asset_id: seeded.svg_asset_id }],
// The detail view is left out, so is the link that opens it.
annotations: draft.annotations.filter(
(a) => a.view_id === 'main' && a.kind !== 'detail_trigger',
),
})
}
async function openThoracic(page: Page) {
await page.setViewportSize({ width: 1280, height: 800 })
const actor = await editorActor('fr')
const seed = await seedDraft(actor, {
drawing: readFileSync(join(DRAFT, 'assets/horse.svg'), 'utf8'),
shape: equineShape,
})
await openEditor(page, dict, actor, seed.sheetId)
await expect(toolButton(page, dict, 'point')).toBeEnabled()
return actor
}
const handle = (page: Page, name: string) =>
page.getByRole('button', { name, exact: true })
const line = (page: Page) => page.getByTestId('gesture-line')
const button = (page: Page, key: string) =>
page.getByRole('button', { name: dict[key], exact: true })
const undo = (page: Page) => page.keyboard.press('Control+z')
/** A press and release at the centre of a handle's hit shape. */
async function pressHandle(page: Page, name: string) {
const box = (await handle(page, name).locator('[data-handle]').boundingBox())!
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2)
}
/** A mouse drag between two drawing points, past the slop. */
async function dragDrawing(
page: Page,
from: { x: number; y: number },
to: { x: number; y: number },
) {
const start = await clientOf(page, from.x, from.y)
const end = await clientOf(page, to.x, to.y)
await page.mouse.move(start.x, start.y)
await page.mouse.down()
await page.mouse.move(end.x, end.y, { steps: 6 })
await page.mouse.up()
}
async function clickAt(page: Page, x: number, y: number) {
const at = await clientOf(page, x, y)
await page.mouse.click(at.x, at.y)
}
const count = async (page: Page) => (await shownPoints(page)).length
test.describe('editor zones on the drawing (U2 Task 5)', () => {
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
test.beforeEach(async ({ context }, info) => {
test.skip(isPhone(info), 'editing needs 1 024 px') // floor-guard: allow C16 editing needs >= 1024 px; phone read-only covered in editor-access
await routeToSandbox(context)
})
test.afterEach(async ({ context }) => {
await dropLateReplays(context)
})
test('Thoraciques: vertex drag, « + », « − », zone drag, each undone', async ({
page,
requests,
}) => {
const actor = await openThoracic(page)
requests.forbid(actor.account.email, actor.account.password)
await pickAnnotation(page, dict, THORACIC)
await expect(selectionTag(page)).toContainText('Vertèbres thoraciques')
await expect(handle(page, 'Sommet 9')).toBeAttached()
// R-18: at fit zoom some segments are too short for their « + ».
await expect(page.getByTestId('edit-strip-notice')).toContainText(
dict['editor.annotations.strip.zoom_hint'],
)
// The list row scrolled the page: the shell's top bar would cover the header's buttons.
await page.evaluate(() => window.scrollTo(0, 0))
await expectAccessible(page, 'a selected zone: vertices and « + »')
const stored = await shownPoints(page)
// A vertex dragged: one commit, the vertex chosen, then undone.
await expectNoShift(
page,
async () => {
await dragDrawing(page, { x: 1103, y: 558.9 }, { x: 1103, y: 620 })
await expect(line(page)).toContainText(
dict['editor.annotations.message.vertex_moved'],
)
},
SWAPS,
)
const [, moved] = await shownPoints(page)
expect(Math.abs(moved[1] - 620)).toBeLessThan(3)
await undo(page)
await expect.poll(() => shownPoints(page)).toEqual(stored)
// « + » on the segment from vertex 2: a vertex added and chosen, then undone.
await expectNoShift(
page,
async () => {
await pressHandle(page, 'Ajouter un sommet après le sommet 2')
await expect(line(page)).toContainText(
dict['editor.annotations.message.vertex_added'],
)
},
SWAPS,
)
expect(await count(page)).toBe(10)
await expect(page.getByTestId('edit-strip-detail')).toContainText(
'sommet 3 choisi',
)
await undo(page)
await expect.poll(() => count(page)).toBe(9)
// « − » on the chosen vertex 3, then undone.
await pressHandle(page, 'Sommet 3')
await expectNoShift(
page,
async () => {
await pressHandle(page, 'Retirer le sommet 3')
await expect(line(page)).toContainText(
dict['editor.annotations.message.vertex_removed'],
)
},
SWAPS,
)
expect(await count(page)).toBe(8)
await undo(page)
await expect.poll(() => shownPoints(page)).toEqual(stored)
// The interior dragged by the mouse moves the zone as a block, then undone.
await expectNoShift(
page,
async () => {
await dragDrawing(page, { x: 914, y: 498 }, { x: 954, y: 538 })
await expect(line(page)).toContainText(
dict['editor.annotations.message.moved.zone'],
)
},
SWAPS,
)
const [first] = await shownPoints(page)
expect(Math.abs(first[0] - (stored[0][0] + 40))).toBeLessThan(3)
await undo(page)
await expect.poll(() => shownPoints(page)).toEqual(stored)
})
test('Thoraciques: redraw accepted, then refused, the old outline kept meanwhile', async ({
page,
requests,
}) => {
const actor = await openThoracic(page)
requests.forbid(actor.account.email, actor.account.password)
await pickAnnotation(page, dict, THORACIC)
const stored = await shownPoints(page)
// Accepted: four clicks, « Fermer le tracé », one commit, every property kept.
await expectNoShift(
page,
() => button(page, 'editor.annotations.redraw').click(),
SWAPS,
)
for (const [x, y] of [
[850, 440],
[1100, 470],
[1100, 560],
[850, 545],
])
await expectNoShift(page, () => clickAt(page, x, y), SWAPS)
await expect(page.getByTestId('overlay-old-place')).toBeAttached()
await expectNoShift(
page,
async () => {
await button(page, 'editor.annotations.trace_close').click()
await expect(line(page)).toContainText(
dict['editor.annotations.message.redrawn.zone'],
)
},
SWAPS,
)
await expect(selectionTag(page)).toContainText('Vertèbres thoraciques')
expect(await count(page)).toBe(4)
await undo(page)
await expect.poll(() => shownPoints(page)).toEqual(stored)
// Refused: a sliver; the tracing stays open with the core's message, then cancelled.
await button(page, 'editor.annotations.redraw').click()
for (const [x, y] of [
[900, 450],
[1100, 452],
[1300, 455],
])
await clickAt(page, x, y)
await expectNoShift(
page,
async () => {
await button(page, 'editor.annotations.trace_close').click()
await expect(page.getByTestId('edit-strip-title')).toHaveText(
dict['editor.annotations.strip.close_refused'],
)
},
SWAPS,
)
await expect(button(page, 'editor.annotations.trace_close')).toBeVisible()
await expectNoShift(
page,
() => button(page, 'editor.annotations.trace_cancel').click(),
SWAPS,
)
await expect.poll(() => shownPoints(page)).toEqual(stored)
})
test('a click inside Thoraciques on C7-T1 selects the point drawn on top', async ({
page,
requests,
}) => {
const actor = await openThoracic(page)
requests.forbid(actor.account.email, actor.account.password)
await clickAt(page, 865, 528)
await expect(selectionTag(page)).toContainText('C7-T1')
// Thoraciques selected: zoomed at C7-T1 so that its vertex handles leave room, a click
// inside both shapes still selects the point (the selection's interior comes after).
await pickAnnotation(page, dict, THORACIC)
const at = await clientOf(page, 870, 515)
await page.mouse.move(at.x, at.y)
await page.keyboard.down('Control')
for (let notch = 0; notch < 14; notch++) await page.mouse.wheel(0, -100)
await page.keyboard.up('Control')
// R-18: zoomed enough, every « + » shows and the zoom line is gone.
await expect(page.getByTestId('edit-strip-notice')).not.toContainText(
dict['editor.annotations.strip.zoom_hint'],
)
await clickAt(page, 870, 515)
await expect(selectionTag(page)).toContainText('C7-T1')
})
})
+30 -1
View File
@@ -676,10 +676,39 @@ export async function clickDrawing(page: Page, x: number, y: number) {
await page.mouse.click(at.x, at.y)
}
/** The geometry fields of the open creation panel or properties panel. */
/** The geometry fields of the open creation panel (until U2 Task 7) or repair dialog. */
export const geometryField = (page: Page, dict: Dict, key: string) =>
page.getByLabel(dict[`editor.annotations.geometry.${key}`], { exact: true })
/**
* The selected shape as the overlay draws it, its circle or polygon: read `cx`, `cy`, `r`
* or `points` (U2 Task 5: the coordinate fields left the properties panel). During a
* pending move it draws the preview; the stored place is `storedShape`.
*/
export const shownShape = (page: Page) =>
page.getByTestId('overlay-selection').locator('circle, polygon').first()
/** The stored shape while a preview moves it: the old place in grey dashes. */
export const storedShape = (page: Page) =>
page.getByTestId('overlay-old-place').locator('circle, polygon').first()
/** One number of the shown shape (`cx`, `cy`, `r`). */
export async function shownNumber(page: Page, name: string): Promise<number> {
return Number(await shownShape(page).getAttribute(name))
}
/** The vertices of the shown polygon, from its `points` attribute. */
export async function shownPoints(page: Page): Promise<number[][]> {
const points = (await shownShape(page).getAttribute('points')) ?? ''
return points
.trim()
.split(/\s+/)
.map((pair) => pair.split(',').map(Number))
}
/** The page's own rounding of a coordinate (0.01 grid). */
export const round2 = (value: number) => Math.round(value * 100) / 100
/** A point annotation of the fixtures (a circle in drawing units, reviewed). */
export function pointOf(
id: string,