feat(editor): creation on the drawing then the creation dialog

U2 Task 7 (A2, A4, A5, A7, A12, A15; R-3, R-4, R-12, R-13, R-14).
The work store's `creation` owns the new shape, its form, its view and
F: a click with the point tool, a closed tracing or a keyboard
« Ajouter … » opens « Nouveau point / zone / accès », a modal without
a history layer over the right column, mounted beside EditOnly so a
read-only flip keeps it (« Créer », « Replacer », « Reprendre » off).
A new zone or link is a creation from its first vertex. The ghost
takes the form's category colour; the point tool previews under a
mouse; the canvas carries data-creating (other markers dimmed,
unselectable). « Replacer le point » / « Reprendre le tracé » hide the
dialog and keep the form; the strip offers « Revenir aux propriétés »,
« Retirer le dernier sommet », « Abandonner ». « Créer »: one insert,
tool back to « Sélectionner », the new element selected, « Point
créé · Défaire », focus on its row. ✕, Échap, « Abandonner » and Back
always ask « Abandonner la création ? » (DiscardConfirm inside the
dialog; DrawingGuardDialog elsewhere); answerDrawing drops the
creation. Undo, its shortcuts and the line's « Défaire » are inactive
during a creation. missingFields replaces formProblem (MissingSummary
shared with the edit form); the C26 notice has no numbers.
CreationPanel, formProblem, withGeometry and the keys required.fields,
required.names and create_cancel are gone; GeometryGroup is imported
by RepairDialog only.

Removed or rewritten assertions:
- tab « holds a point at the frame centre »: « Centre x » = 50 ->
  the ghost circle cx = 50; plus tool back to Sélectionner, « Point
  créé », one undo step.
- tab « refuses a creation without laterality »: the general line
  « Choisissez la catégorie et la latéralité » -> only « Choisissez
  une latéralité. » and « À compléter : Latéralité. », focus on it.
- tab « applies the geometry group to a pending zone »: removed (A8,
  no coordinate field) -> « places a triangle at the centre: the ghost
  shows it, Créer inserts it »; vertex edits after Créer are the e2e
  keyboard test.
- tab C26 « proposes C »: « x = 15, y = 15 » in the notice -> the R-4
  text, the notice inside the dialog; cancel test « Centre x » = 0 ->
  ghost cx = 0.
- tab « offers the correction when the core refuses a pending point »
  (typed cx 98): removed, no typed coordinate is possible; the verdict
  path stays covered by the C26 click tests and correctionFor units.
- tab H5 « a typed radius shows the core issue »: removed (A8); the
  size refusal is the slider's (Task 4 tests).
- tab H6 « a second click moves the pending point »: -> « Replacer le
  point », then the click moves the ghost, the form kept.
- tab H7 « Centre x/y » = 30/50 -> ghost cx/cy.
- tab tracing Enter: « x du sommet 3 » -> ghost points; « drops the
  tracing on Escape » -> Escape asks first (board 32 row 3), Continuer
  keeps, Abandonner drops; new « Annuler le tracé acts at once ».
- keep-alive « a pending creation is kept and focused » and « a
  tracing … is kept and focused »: the tab now asks first (R-12) ->
  « Continuer » keeps the tracing / the form, « Abandonner » goes.
- sections « its panel takes the focus » -> its dialog's
  [data-creation-focus] takes it.
- no-loss « pending creation with its name » (hidden with the body) ->
  the dialog stays across the crossing, read-only, Créer off (R-14).
- point-edit A5 « Rayon » = 7 / 9 -> ghost r = 7 / 9.
- e2e editor-annotations keyboard test « numeric position » (cx field
  250) -> UX_TESTS Keyboard: zone added, vertex added and removed,
  moved by the move mode, validated, saved. The « Fermer le tracé »
  step runs under expectNoShift again (shortcut removed).
- e2e editor-geometry C26: the proposed x, y read from the notice
  text -> from the overlay's correction circle; the R-4 text checked
  in the dialog.
- e2e editor-deselect « Escape cancels the tracing only » -> Escape
  asks, « Abandonner » cancels it, the selection kept.
- e2e editor-shell-crossing « keeps its tool and its pending
  creation » (field hidden) -> the dialog stays read-only, Créer off,
  then editable on widening.
This commit is contained in:
bchanot committed 2026-11-17 23:32:42 +01:00
1 parent 2d58da7d01
commit 4d2c64f57f
50 files changed
+3050 -1181

No files matched your search

+92 -48
View File
@@ -35,7 +35,10 @@ import { expectNoShift, keepNativeFrames } from '../support/layout'
const dict = fr
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
/** The creation dialog's form (U2 Task 7). */
const creation = (page: Page) => page.getByTestId('annotation-creation')
const creationDialog = (page: Page, kind: string) =>
page.getByRole('dialog', { name: dict[`editor.annotations.new.${kind}`] })
/** The selection's commands in the strip (U2 Task 6: the properties are a dialog). */
const properties = (page: Page) =>
page.locator('[data-testid="edit-strip"]:has([data-properties-button])')
@@ -53,7 +56,7 @@ interface Names {
en: string
}
/** Fills the creation panel; the category keeps its first choice. */
/** Fills the creation dialog; the category keeps its first choice (A4). */
async function fillCreation(page: Page, names: Names, opens?: string) {
const panel = creation(page)
await panel.getByLabel(dict['editor.annotations.name_fr']).fill(names.fr)
@@ -71,6 +74,8 @@ async function createFromPanel(page: Page) {
.getByRole('button', { name: dict['editor.annotations.create'] })
.click()
await expect(creation(page)).toHaveCount(0)
// A7: back to « Sélectionner », the new element selected.
await expect(tool(page, 'select')).toHaveAttribute('aria-pressed', 'true')
}
async function openAnnotations(page: Page) {
@@ -97,12 +102,34 @@ test.describe('editor annotations (A3)', () => {
}) => {
const { actor, seed } = await openAnnotations(page)
requests.forbid(actor.account.email, actor.account.password)
const line = page.getByTestId('gesture-line')
// A point: the tool, a click in the drawing, the fields the core requires.
// An entry of the editor's own below this one, for the Back further down.
await selectTab(page, dict, 'general')
await selectTab(page, dict, 'annotations')
// A point: the tool, a click in the drawing, the dialog « Nouveau point » (A2).
await tool(page, 'point').click()
await clickDrawing(page, 300, 300)
await expect(creation(page)).toBeVisible()
await expectAccessible(page, 'the point creation panel')
await expect(creationDialog(page, 'point')).toBeVisible()
await expect(page.getByTestId('overlay-ghost')).toBeAttached()
await expect(page.getByTestId('annotation-canvas')).toHaveAttribute(
'data-creating',
'',
)
await expectAccessible(page, 'the point creation dialog')
// A Back while the dialog is open: refused (a modal, no history layer), the question
// inside the dialog (A12); the tab stays.
await page.goBack()
const ask = creationDialog(page, 'point').getByRole('group', {
name: dict['editor.annotations.guard.creation'],
})
await expect(ask).toBeVisible()
await expect(page.locator('dialog[open]')).toHaveCount(1)
await ask
.getByRole('button', { name: dict['editor.annotations.guard.continue'] })
.click()
await expect(ask).toHaveCount(0)
await expect(creationDialog(page, 'point')).toBeVisible()
await fillCreation(page, { fr: 'Point un', en: 'Point one' })
await creation(page)
.getByLabel(dict['editor.annotations.zone'])
@@ -110,6 +137,9 @@ test.describe('editor annotations (A3)', () => {
await createFromPanel(page)
await expect(selectionTag(page)).toContainText('Point un')
await expect(properties(page)).toBeVisible()
await expect(line).toContainText(
dict['editor.annotations.message.created.point'],
)
const placed = await shownNumber(page, 'cx')
expect(Math.abs(placed - 300)).toBeLessThan(1)
@@ -121,12 +151,18 @@ test.describe('editor annotations (A3)', () => {
[700, 400],
])
await clickDrawing(page, x, y)
await expectAccessible(page, 'a zone tracing in progress')
await page
.getByRole('button', { name: dict['editor.annotations.trace_close'] })
.click()
await expect(creationDialog(page, 'zone')).toBeVisible()
await expectAccessible(page, 'the zone creation dialog')
await fillCreation(page, { fr: 'Zone une', en: 'Zone one' })
await createFromPanel(page)
await expect(selectionTag(page)).toContainText('Zone une')
await expect(line).toContainText(
dict['editor.annotations.message.created.zone'],
)
// A link to the detail view: the same tracing, the opened view chosen.
await tool(page, 'link').click()
@@ -144,6 +180,15 @@ test.describe('editor annotations (A3)', () => {
await expect(selectionTag(page)).toContainText('Accès un')
await expect(historyButton(page, dict, 'undo')).toBeEnabled()
// Each creation is one step: « Défaire » removes the link, « Refaire » brings it back.
const rows = list(page).getByRole('button')
await expect(rows.filter({ hasText: 'Accès un' })).toHaveCount(1)
await historyButton(page, dict, 'undo').click()
await expect(rows.filter({ hasText: 'Accès un' })).toHaveCount(0)
await expect(rows.filter({ hasText: 'Zone une' })).toHaveCount(1)
await historyButton(page, dict, 'redo').click()
await expect(rows.filter({ hasText: 'Accès un' })).toHaveCount(1)
// 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/)
@@ -221,64 +266,63 @@ test.describe('editor annotations (A3)', () => {
await expect(shownShape(page)).toHaveAttribute('cx', x0)
})
test('keyboard only: creation by the add buttons, numeric position, edit by the handle keys', async ({
// UX_TESTS « Keyboard »: create a zone, add and remove a vertex, move the zone, validate.
test('keyboard only: a zone by « Ajouter une zone », a vertex added and removed, moved, validated', async ({
page,
requests,
}) => {
const { actor, seed } = await openAnnotations(page)
requests.forbid(actor.account.email, actor.account.password)
const add = page.getByRole('button', {
name: dict['editor.annotations.add.point'],
})
await add.focus()
await page.keyboard.press('Enter')
await expect(creation(page)).toBeVisible()
await fillCreation(page, { fr: 'Clavier', en: 'Keyboard' })
const cx = creation(page).getByLabel(dict['editor.annotations.geometry.cx'])
await cx.fill('250')
await cx.press('Enter')
await expect(cx).toHaveValue('250')
await creation(page)
.getByRole('button', { name: dict['editor.annotations.create'] })
.focus()
await page.keyboard.press('Enter')
await expect(creation(page)).toHaveCount(0)
await expect(selectionTag(page)).toContainText('Clavier')
await expect(shownShape(page)).toHaveAttribute('cx', '250')
// 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', exact: true })
.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, its first vertex moved by its keys.
await page
.getByRole('button', { name: dict['editor.annotations.add.zone'] })
.focus()
await page.keyboard.press('Enter')
await expect(creationDialog(page, 'zone')).toBeVisible()
await fillCreation(page, { fr: 'Zone clavier', en: 'Keyboard zone' })
await creation(page)
.getByRole('button', { name: dict['editor.annotations.create'] })
.focus()
await page.keyboard.press('Enter')
await expect(creation(page)).toHaveCount(0)
await expect(selectionTag(page)).toContainText('Zone clavier')
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')
// Board 32: « Créer » réussi, the focus on the new row.
await expect(
list(page).getByRole('button', { name: /Zone clavier/ }),
).toBeFocused()
const [first] = await shownPoints(page)
expect(await shownPoints(page)).toHaveLength(3)
// « + » after vertex 1 by Enter: four vertices; Delete on the chosen one: three again.
await page
.getByRole('button', { name: 'Ajouter un sommet après le sommet 1' })
.focus()
await page.keyboard.press('Enter')
await expect.poll(async () => (await shownPoints(page)).length).toBe(4)
await page.getByRole('button', { name: 'Sommet 2', exact: true }).focus()
await page.keyboard.press('Delete')
await expect.poll(async () => (await shownPoints(page)).length).toBe(3)
// Escape unchooses the vertex (board 32 row 5): the strip offers the zone's move.
await page.keyboard.press('Escape')
// The move mode by its keys: two steps right, then « Valider la position ».
await page
.getByRole('button', { name: dict['editor.annotations.move.zone'] })
.focus()
await page.keyboard.press('Enter')
const right = page.getByRole('button', {
name: dict['editor.annotations.move.right'],
})
await right.focus()
await page.keyboard.press('Enter')
await page.keyboard.press('Enter')
await page
.getByRole('button', { name: dict['editor.annotations.move.confirm'] })
.focus()
await page.keyboard.press('Enter')
await expect
.poll(async () => (await shownPoints(page))[0][0])
.toBe(round2(round2(before + 5) + 5))
.toBe(round2(round2(first[0] + 5) + 5))
await saveDraft(page, dict, seed.revision + 1)
})
@@ -394,11 +438,11 @@ test.describe('editor annotations (A3)', () => {
button(page, 'editor.annotations.trace_pop').click(),
)
await expectNoShift(page, () => clickDrawing(page, 700, 400))
// shortcut: the creation panel still replaces the overview in the side column until
// Task 7 (the creation dialog), so the close is checked out of the no-shift probe.
// Upgrade path: wrap it in expectNoShift again once the creation is a dialog.
await button(page, 'editor.annotations.trace_close').click()
await expect(creation(page)).toBeVisible()
// The close opens « Nouvelle zone » over the column: nothing under it moves.
await expectNoShift(page, async () => {
await button(page, 'editor.annotations.trace_close').click()
await expect(creationDialog(page, 'zone')).toBeVisible()
})
})
}