feat(editor): resumed trace edits the closed shape with its handles

« Reprendre le tracé » keeps the pending shape closed; the zone handles
(vertex, « + », « − », vertex keys) edit it through the same press path
and useZoneEdit, the target generalised to points + drop. A drop on
PENDING_ID patches creation.pending only: document, history and unsaved
count untouched, message without « Défaire ». Strip: « Tracé repris,
saisie gardée » with « Revenir aux propriétés » and « Abandonner ».
Handle names fall back to « la nouvelle zone » / « le nouvel accès ».

Removed (resumed branch of popVertex, backToProperties -> closeTrace,
CreationCommands tracedCount and its « Retirer le dernier sommet »).

Removed assertions, editor-creation-dialog.test.tsx, « keeps the
vertices and the form; a new vertex, then the dialog again »:
- strip « Tracé repris, saisie gardée » -> kept in « keeps the shape
  closed and the form, shows its handles; two strip commands »
- « Retirer le dernier sommet » enabled -> absent; commands are exactly
  « Revenir aux propriétés », « Abandonner » (same test)
- a click on the drawing adds a 4th vertex -> « a click off the handles
  adds and selects nothing; a double « + » inserts once »
- dialog again with Nom (FR) « Tibia » -> « « Revenir aux propriétés »
  shows the edited shape; « Créer » inserts it »
- « Zone tracée, 4 sommets » -> « Zone tracée, 5 sommets » after « + »
  (same test)
This commit is contained in:
bchanot committed 2026-11-19 09:42:58 +01:00
1 parent 816d0f4f9a
commit a5896710e5
17 files changed
+679 -118

No files matched your search

@@ -746,4 +746,118 @@ test.describe('editor annotations (A3)', () => {
expect(await gutter()).toBe('auto')
})
})
// Rev 4 point 3 (board 04 C, criterion 27): « Reprendre le tracé » edits the closed shape
// with its handles; the document and the history wait for « Créer ».
test('a resumed trace is edited with its handles, then created in one step', async ({
page,
requests,
}) => {
await page.setViewportSize({ width: 1280, height: 800 })
const { actor } = await openAnnotations(page)
requests.forbid(actor.account.email, actor.account.password)
const line = page.getByTestId('gesture-line')
const strip = page.getByTestId('edit-strip')
const ghostPoints = async () =>
(
(await page
.getByTestId('overlay-ghost')
.locator('polygon')
.first()
.getAttribute('points')) ?? ''
)
.trim()
.split(/\s+/)
.map((pair) => pair.split(',').map(Number))
const handle = (name: string) =>
page.getByRole('button', { name, exact: true })
const button = (_page: Page, key: string) => handle(dict[key])
const pressHandle = async (name: string) => {
const box = (await handle(name).locator('[data-handle]').boundingBox())!
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2)
}
await tool(page, 'zone').click()
for (const [x, y] of [
[200, 150],
[450, 150],
[500, 350],
[350, 450],
[150, 350],
])
await clickDrawing(page, x, y)
await button(page, 'editor.annotations.trace_close').click()
await expect(creationDialog(page, 'zone')).toBeVisible()
await creation(page)
.getByLabel(dict['editor.annotations.name_fr'])
.fill('Tibia')
const saved = await saveLine(page).textContent()
await expectNoShift(page, async () => {
await creationDialog(page, 'zone')
.getByRole('button', {
name: dict['editor.annotations.creation.resume'],
})
.click()
await expect(creationDialog(page, 'zone')).toHaveCount(0)
await expect(handle('Sommet 1 de Tibia')).toBeAttached()
})
await expect(strip).toContainText(dict['editor.annotations.strip.resumed'])
await expect(
strip.getByRole('button', { name: dict['editor.annotations.trace_pop'] }),
).toHaveCount(0)
await expect(
page.getByRole('group', { name: 'Sommets de Tibia', exact: true }),
).toBeAttached()
await expectAccessible(page, 'a resumed trace with its handles')
// A vertex dragged: the ghost changes, said without « Défaire »; nothing else moves.
const from = await clientOf(page, 450, 150)
const to = await clientOf(page, 480, 110)
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(line).toContainText(
dict['editor.annotations.message.vertex_moved'],
)
await expect(
line.getByRole('button', { name: dict['editor.history.undo_title'] }),
).toHaveCount(0)
const [, moved] = await ghostPoints()
expect(Math.abs(moved[0] - 480)).toBeLessThan(3)
expect(Math.abs(moved[1] - 110)).toBeLessThan(3)
// « + » then « − »: six vertices, then five again; the document never changed.
await pressHandle('Ajouter un sommet après le sommet 1 de Tibia')
await expect.poll(async () => (await ghostPoints()).length).toBe(6)
await expect(line).toContainText(
dict['editor.annotations.message.vertex_added'],
)
await pressHandle('Sommet 4 de Tibia')
await pressHandle('Retirer le sommet 4 de Tibia')
await expect.poll(async () => (await ghostPoints()).length).toBe(5)
await expect(saveLine(page)).toHaveText(saved ?? '')
await expect(historyButton(page, dict, 'undo')).toHaveAttribute(
'aria-disabled',
'true',
)
const edited = await ghostPoints()
await expectNoShift(page, async () => {
await button(page, 'editor.annotations.back_to_properties').click()
await expect(creationDialog(page, 'zone')).toBeVisible()
})
await expect(
creation(page).getByLabel(dict['editor.annotations.name_fr']),
).toHaveValue('Tibia')
await fillCreation(page, { fr: 'Tibia', en: 'Tibia' })
await createFromPanel(page)
await expect(selectionTag(page)).toContainText('Tibia')
expect(await shownPoints(page)).toEqual(edited)
// One step: a single undo removes the whole new zone.
const rows = list(page).getByRole('button')
await expect(rows.filter({ hasText: 'Tibia' })).toHaveCount(1)
await historyButton(page, dict, 'undo').click()
await expect(rows.filter({ hasText: 'Tibia' })).toHaveCount(0)
})
})