Files
faunosteo/apps/app/e2e/shell/editor-geometry.spec.ts
T
bchanot cd794f3c39 feat(editor): properties dialog over the column, transactional save
U2 Task 6 (A1, A2, A3, A9, A10, R-3, R-5, R-6, R-14, R-16).

- Dialog: `anchor` places the panel at the column's left and width,
  from its top, under a 22 % ink veil that ignores clicks; the visual
  viewport below 320 px; centred without an anchor box.
- Navigation: `annotation` layer (LAYERS, EditorView, history entry,
  leave guards, left-draft flag); Back closes, Forward reopens.
- AnnotationDialog: read body, « Modifier » form (CreationFields with
  « Couleur », missingFields, R-3 messages), one `update` on the
  current annotation by id, « Marquer comme relu », « Modifier la
  forme », « Supprimer »; read-only flip keeps the draft.
- The column always shows the overview, selected row marked; Enter on
  it, a second click or a double click, the strip's « Propriétés »
  open the dialog. « Aller à » focuses the row (R-5).
- Read-only twin: strip and read-only dialog at 1 024 px and wider,
  inline read body below. PropertiesPanel and AnnotationFields gone.
- Strip lead 256 px and a fixed status slot, so the commands fit at
  1 024 px and a status change moves nothing.
- e2e: `aside-content` exemption removed; scroll-to-top workarounds
  of editor-geometry, editor-zones and editor-journey removed.

Removed assertions mapped:
  editor-annotations-tab.test.tsx:
  - selectFromList waited for `annotation-properties` -> waits for the strip's « Propriétés » (selection without dialog, A1)
  - refused place: issues block `annotation-geometry-issues` in the panel -> the strip notice alert (present, then gone)
  - keyboard creation / C26 confirmation: `annotation-properties` after create -> strip « Propriétés » (new element selected)
  - Désélectionner from the panel -> « Désélectionner » in the strip (all 7 tests); « panel closes » -> strip has no « Propriétés »
  - undo after deselect (typed name) -> handle key series then deselect then undo
  - commits a valid typed value once without blur (name field) -> a pending handle key series committed once by the strip deselect
  - a refused typed value: the panel closes (two tests: strip deselect, tap deselect) -> removed: no field outside the dialog; the dialog's draft writes nothing before « Enregistrer » (new dialog tests)
  - not offered while a replace tracing runs: panel's Désélectionner absent -> strip offers neither « Désélectionner » nor « Propriétés » during the tracing
  - tap: isDeselected read `annotation-properties` -> strip « Propriétés » absent; link select -> strip title data-selection
  - tap: undo after tap deselect (typed name) -> handle series; typed value committed on blur -> handle series committed on blur
  - strip geometry issues: list read in the panel -> list read in the properties dialog's issues block
  - a new commit replaces the message (typed name) -> « Marquer comme relu » in the dialog
  editor-escape.test.tsx:
  - `panel()` = `annotation-properties` -> the strip's « Propriétés » or the phone twin's inline read body
  - Escape from a panel button (« Marquer comme relu ») -> from the selected row in the side column: focus on the row
  - after A then B from the panel (via « Toutes les annotations ») -> select A, select B, Escape from a button of the side column: focus on B's row
  - a text field (panel « Nom (FR) ») -> the overview « Filtrer par nom »
  - redraw via the panel's « Remplacer par un polygone » -> the strip's command
  - modal / delete dialog opened by the panel's « Supprimer » -> « Supprimer » of the properties dialog
  - read-only width: hidden `annotation-properties` -> hidden strip « Propriétés » of the kept edit body
  editor-history-buttons.test.tsx (typed text and the press, 8 tests): the annotation's committed « Nom (FR) » field of the panel -> the sheet's committed « Nom (FR) » on Général (same TextField commit-on-blur path; annotation fields are now a dialog draft)
  editor-focus-request.test.tsx: « Aller à » focuses `data-properties-heading` inside `annotation-properties` -> focuses the annotation's row, marked aria-current, no dialog (R-5)
  editor-sections.test.tsx: « Aller à » with nothing in progress focused the properties heading -> focuses the row (R-5); creation kept: no `annotation-properties` -> no strip « Propriétés »
  editor-overview.test.tsx (edit and read-only): row opens `annotation-properties`, « Toutes les annotations » returns -> row selects, stays marked aria-current, no dialog; strip « Désélectionner » returns focus to the row; filter kept across select and « Désélectionner »
  editor-citations-guards.test.tsx: LAYERS_TOP_DOWN gains 'annotation' at the bottom
  editor-keep-alive.test.tsx: `annotation-properties` visible after the round trip -> the strip's « Propriétés » visible (selection kept)
  editor-no-loss.test.tsx: ids `ro-annotation-name-fr` and `annotation-name-fr` (both panels' fields) -> the twin's inline read body (no ids), then the dialog edit form's `annotation-edit-fr`, kept through a flip to 800 px, no duplicate id; « Aller à » visible `annotation-properties` -> visible `annotation-read` (inline twin), none at 1 280
  editor-point-edit.test.tsx / editor-zone-edit.test.tsx: `select()` waited for `annotation-properties` and returned it -> waits for the strip's « Propriétés » and returns the strip (its « Désélectionner » and « Remplacer par un polygone » moved there)
  - move mode Escape: `annotation-properties` still there -> the strip's « Propriétés » back after the mode
  - « Toutes les annotations » asks first during a started move -> Enter on the selected row asks first (no dialog), and the strip offers neither « Propriétés » nor « Désélectionner » during the mode
  - Escape from the handle / slider: `annotation-properties` gone -> the strip's « Propriétés » gone
  - I-3 touch tap: `annotation-properties` gone -> the strip's « Propriétés » gone
  e2e (sandbox):
  - support/layout.ts: `aside-content` exemption removed (ShiftExemption type, the loose compare); every `swaps`/`SWAPS` argument removed (editor-annotations, editor-zones, editor-geometry)
  - support/editor.ts pickAnnotation: clicked « Toutes les annotations » first when the panel showed -> the overview is always shown: clicks the row, then scrolls back to the top (the page no longer shortens)
  - editor-annotations: `annotation-properties` visible after a creation -> strip with « Propriétés »; review toggle and « Supprimer » of the panel -> the properties dialog's; a jitter click on the selected point now opens the dialog (A1), closed by Escape before the drag; handle names exact (the marked row shares the prefix); trace close moved out of expectNoShift (creation panel until Task 7, shortcut + TODO)
  - editor-deselect: `annotation-properties` -> the strip with « Propriétés » or the twin's inline read body; Escape in a field: panel « Nom (FR) » -> overview filter; delete dialog from the panel -> from the properties dialog (Escape closes it, then the dialog); « a typed value is applied by the click that deselects » (name field, refused blank) -> a pending point-handle key series applied by the deselecting click and by « Désélectionner » (refused value: no field outside the dialog); « the selected one stays » -> a second click, double click and jitter open the dialog, Escape closes it, selection kept
  - editor-geometry: `annotation-geometry-issues` in the panel -> read in the properties dialog, then the strip notice; after the refusal the error count unchanged; scroll-to-top workaround removed
  - editor-zones: panel « Désélectionner » -> strip; scroll-to-top after pickAnnotation removed (helper does it)
  - editor-structures: panel « Supprimer » -> properties dialog « Supprimer », confirmation over it
  - editor-journey: `#annotation-name-fr` committed field + `#annotation-laterality` -> the dialog's edit form, one « Enregistrer »; scroll-to-top removed
  - editor-shell / editor-shell-journeys: « Aller à » focus on `data-properties-heading` -> the annotation's row (aria-current), no dialog (R-5)
  - editor-shell-layout: focus kind `annotation-properties` -> removed (the overview is the side)
2026-11-17 22:01:57 +01:00

531 lines
19 KiB
TypeScript

import { fr } from '@/i18n/fr'
import type { Page, TestInfo } from '@playwright/test'
import { expect, expectAccessible, test } from '../support/browser'
import { expectNoShift } from '../support/layout'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
place,
clickDrawing,
clientOf,
editorActor,
shownNumber,
shownShape,
openEditor,
openSection,
pickAnnotation,
pointOf,
saveDraft,
seedDraft,
selectionTag,
selectTab,
serverDocument,
shapeWith,
standardShape,
openProperties,
} from '../support/editor'
// V1-2.6 geometry and adversarial cases (contract C7, C8, C21; owner 2026-11-04): a click
// near the edge of a frame (the corrected position shown, confirmed and cancelled), a
// point inherited out of its frame repaired with the move mode (U2 Task 4), a crop change
// refused when it would invalidate a point, an unmeasured view with its tools disabled,
// and the touch path (touch-action, pointer capture) in a real browser.
const dict = fr
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
const creation = (page: Page) => page.getByTestId('annotation-creation')
const notice = (page: Page) => page.getByTestId('correction-notice')
const tool = (page: Page, id: string) =>
page.getByRole('button', {
name: dict[`editor.annotations.tool.${id}`],
exact: true,
})
const viewChip = (page: Page, name: string) =>
page
.getByRole('group', { name: dict['editor.annotations.views'] })
.getByRole('button', { name })
/** The x and y a correction notice proposes, read from its sentence. */
async function proposed(page: Page): Promise<{ x: string; y: string }> {
const text = (await notice(page).innerText()).replace(/\s+/g, ' ')
const found = /x = (-?\d+(?:\.\d+)?), y = (-?\d+(?:\.\d+)?)/.exec(text)
if (!found) throw new Error('no proposed position in the notice')
return { x: found[1], y: found[2] }
}
/** A mouse drag on the drawing in the move mode, between two points in drawing units. */
async function dragInMode(
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 fillNames(page: Page, fr: string, en: string) {
await creation(page).getByLabel(dict['editor.annotations.name_fr']).fill(fr)
await creation(page).getByLabel(dict['editor.annotations.name_en']).fill(en)
await creation(page)
.getByLabel(dict['editor.annotations.laterality'])
.selectOption('unpaired')
}
async function open(page: Page, ...annotations: unknown[]) {
const actor = await editorActor('fr')
const seed = await seedDraft(actor, { shape: shapeWith(...annotations) })
await openEditor(page, dict, actor, seed.sheetId)
await expect(tool(page, 'point')).toBeEnabled()
return { actor, seed }
}
test.describe('editor geometry (adversarial)', () => {
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('a click near the edge: corrected position shown, cancelled, then confirmed', async ({
page,
requests,
}) => {
const { actor } = await open(page)
requests.forbid(actor.account.email, actor.account.password)
await tool(page, 'point').click()
await clickDrawing(page, 3, 3)
await fillNames(page, 'Bord', 'Edge')
await creation(page)
.getByRole('button', { name: dict['editor.annotations.create'] })
.click()
await expect(notice(page)).toBeVisible()
await expect(page.getByTestId('overlay-click-cross')).toBeAttached()
const shown = await proposed(page)
await expect(selectionTag(page)).toHaveCount(0) // an insertion selects it
// Cancelled: the notice goes, nothing was inserted.
await notice(page)
.getByRole('button', {
name: dict['editor.annotations.correction_cancel'],
})
.click()
await expect(notice(page)).toHaveCount(0)
await expect(selectionTag(page)).toHaveCount(0) // an insertion selects it
// Confirmed: the same attempt again, the corrected position inserted.
await creation(page)
.getByRole('button', { name: dict['editor.annotations.create'] })
.click()
await expect(notice(page)).toBeVisible()
expect(await proposed(page)).toEqual(shown)
await notice(page)
.getByRole('button', { name: dict['editor.annotations.correction_use'] })
.click()
await expect(creation(page)).toHaveCount(0)
await expect(selectionTag(page)).toContainText('Bord')
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 ({
page,
requests,
}) => {
const { actor } = await open(page)
requests.forbid(actor.account.email, actor.account.password)
await viewChip(page, 'Détail A').click()
await tool(page, 'point').click()
await clickDrawing(page, 102, 102)
await fillNames(page, 'Bord détail', 'Detail edge')
await creation(page)
.getByRole('button', { name: dict['editor.annotations.create'] })
.click()
await expect(notice(page)).toBeVisible()
const shown = await proposed(page)
expect(Number(shown.x)).toBeGreaterThan(100)
expect(Number(shown.y)).toBeGreaterThan(100)
// Cancelled first: nothing is added to the crop's view.
await notice(page)
.getByRole('button', {
name: dict['editor.annotations.correction_cancel'],
})
.click()
await expect(notice(page)).toHaveCount(0)
await expect(selectionTag(page)).toHaveCount(0) // an insertion selects it
// Then confirmed: the same attempt again inserts the corrected position.
await creation(page)
.getByRole('button', { name: dict['editor.annotations.create'] })
.click()
expect(await proposed(page)).toEqual(shown)
await notice(page)
.getByRole('button', { name: dict['editor.annotations.correction_use'] })
.click()
await expect(selectionTag(page)).toContainText('Bord détail')
})
test('a point inherited out of its frame is repaired with the move mode', async ({
page,
requests,
}) => {
const { actor } = await open(
page,
pointOf('out', 'detail-a', { cx: 110, cy: 110, r: 30 }, 'Hors cadre'),
)
requests.forbid(actor.account.email, actor.account.password)
await viewChip(page, 'Détail A').click()
await pickAnnotation(page, dict, /Hors cadre/)
// The issue: an alert in the properties dialog's read mode, its text in the strip.
const properties = await openProperties(page, dict)
const issue = (
await properties
.getByTestId('annotation-geometry-issues')
.locator('li')
.first()
.innerText()
).trim()
await page.keyboard.press('Escape')
await expect(page.getByRole('dialog')).toHaveCount(0)
const notice = page.getByTestId('edit-strip-notice')
await expect(notice).toContainText(issue)
const verification = page.getByRole('tab', {
name: dict['editor.tab.verification'],
})
const errorsBefore = Number(
(await verification.innerText()).replace(/\D/g, ''),
)
expect(errorsBefore).toBeGreaterThan(0)
const move = page.getByRole('button', {
name: dict['editor.annotations.move.point'],
})
const confirm = page.getByRole('button', {
name: dict['editor.annotations.move.confirm'],
})
// A partial move (still out of the frame): refused by the core, the point restored.
// Nothing around the drawing moves (A14), wherever the page is scrolled: the issue
// lives in the strip and the dialog, the side column keeps the overview (U2 Task 6).
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.getByTestId('gesture-message')).toBeVisible()
})
await expect(page.getByTestId('gesture-message')).toContainText(
dict['editor.annotations.message.move_refused'].split(' :')[0],
)
await expect(page.getByTestId('overlay-refused-place')).toBeAttached()
await expect(shownShape(page)).toHaveAttribute('cx', '110')
await expect(verification).toContainText(String(errorsBefore))
// Far enough inside: kept, the issue gone, one error less.
await expectNoShift(page, () => move.click())
await dragInMode(page, { x: 250, y: 250 }, { x: 290, y: 290 })
await expectNoShift(page, async () => {
await confirm.click()
await expect(notice).not.toContainText(issue)
})
expect(Math.abs((await shownNumber(page, 'cx')) - 150)).toBeLessThan(2)
const after = (await verification.innerText()).replace(/\D/g, '')
expect(Number(after || 0)).toBeLessThan(errorsBefore)
})
test('a crop change that would invalidate a point is refused, then reverted', async ({
page,
requests,
}) => {
const { actor } = await open(
page,
pointOf(
'inside',
'detail-a',
{ cx: 350, cy: 300, r: 20 },
'Dans le cadre',
),
)
requests.forbid(actor.account.email, actor.account.password)
await openSection(page, dict, 'views')
const detail = page.getByRole('listitem', { name: 'Détail A' })
await detail
.getByRole('button', { name: dict['editor.views.crop.toggle'] })
.click()
const width = detail.getByLabel(dict['editor.views.crop.width'], {
exact: true,
})
await expect(width).toHaveValue('300')
await width.fill('100')
await width.press('Enter')
const refusal = detail.getByRole('alert')
await expect(
refusal.getByText(dict['editor.views.crop.not_applied']),
).toBeVisible()
await expect(refusal).toContainText('Dans le cadre')
await refusal
.getByRole('button', { name: dict['editor.views.crop.revert'] })
.click()
await expect(width).toHaveValue('300')
})
test('attaching a drawing to an unmeasured view repairs the annotations outside its frame', async ({
page,
requests,
}) => {
const zone = {
...pointOf('out-zone', 'main', { cx: 0, cy: 0, r: 1 }, 'Zone hors cadre'),
kind: 'zone',
geometry: {
type: 'polygon',
points: [
[10, 10],
[400, 10],
[400, 400],
],
},
}
const point = pointOf(
'out-point',
'main',
{ cx: 500, cy: 400, r: 20 },
'Point hors cadre',
)
const actor = await editorActor('fr')
requests.forbid(actor.account.email, actor.account.password)
const seed = await seedDraft(actor, {
drawing: null,
shape: (document) => {
standardShape(document)
const views = document.views as { id: string }[]
document.views = views.filter((view) => view.id === 'main')
document.annotations = [point, zone]
},
})
await openEditor(page, dict, actor, seed.sheetId)
await openSection(page, dict, 'views')
await page.getByTestId('view-main-file').setInputFiles({
name: 'petit.svg',
mimeType: 'image/svg+xml',
buffer: Buffer.from(
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">' +
'<rect x="2" y="2" width="96" height="96" fill="#eee"/></svg>',
),
})
const dialog = page.getByRole('dialog', {
name: dict['editor.views.repair.title'],
})
await expect(dialog).toBeVisible()
const row = dialog.getByTestId('repair-out-point')
await expect(
row.getByLabel(dict['editor.annotations.geometry.cx']),
).toHaveValue('85')
await expectAccessible(page, 'the repair dialog')
// A value the core refuses: nothing applied, the typed value kept.
const cx = row.getByLabel(dict['editor.annotations.geometry.cx'])
await cx.fill('900')
await cx.press('Enter')
await dialog
.getByRole('button', { name: dict['editor.views.repair.apply'] })
.click()
await expect(
dialog.getByText(dict['editor.views.repair.refused']),
).toBeVisible()
await expect(cx).toHaveValue('900')
await cx.fill('60')
await cx.press('Enter')
await dialog
.getByRole('button', { name: dict['editor.views.repair.apply'] })
.click()
await expect(dialog).toBeHidden()
await expect(page.getByText(dict['editor.upload.done'])).toBeVisible()
await saveDraft(page, dict, seed.revision + 1)
const saved = await serverDocument<{
views: { id: string; svg_asset_id: string | null }[]
annotations: { id: string; geometry: Record<string, unknown> }[]
}>(seed.draftId)
expect(saved.views[0].svg_asset_id).not.toBeNull()
const byId = Object.fromEntries(saved.annotations.map((a) => [a.id, a]))
expect(byId['out-point'].geometry).toMatchObject({ type: 'circle', cx: 60 })
expect(byId['out-zone'].geometry).toEqual({
type: 'polygon',
points: [
[10, 10],
[100, 10],
[100, 100],
],
})
})
test('a free path outside the new frame blocks the attach, is never reshaped and survives a save', async ({
page,
requests,
}) => {
const seededPath =
'M 300 300 l 40 0 C 350 320 380 360 400 400 q 20 -30 -40 -50 ' +
'A 30 20 0 0 1 320 330 H 310 V 305 Z'
const path = {
...pointOf('out-path', 'main', { cx: 0, cy: 0, r: 1 }, 'Tracé libre'),
kind: 'zone',
geometry: { type: 'path', d: seededPath },
}
const point = pointOf(
'out-point',
'main',
{ cx: 500, cy: 400, r: 20 },
'Point hors cadre',
)
const actor = await editorActor('fr')
requests.forbid(actor.account.email, actor.account.password)
const seed = await seedDraft(actor, {
drawing: null,
shape: (document) => {
standardShape(document)
const views = document.views as { id: string }[]
document.views = views.filter((view) => view.id === 'main')
document.annotations = [point, path]
},
})
await openEditor(page, dict, actor, seed.sheetId)
await openSection(page, dict, 'views')
await page.getByTestId('view-main-file').setInputFiles({
name: 'petit.svg',
mimeType: 'image/svg+xml',
buffer: Buffer.from(
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">' +
'<rect x="2" y="2" width="96" height="96" fill="#eee"/></svg>',
),
})
const dialog = page.getByRole('dialog', {
name: dict['editor.views.repair.title'],
})
await expect(dialog).toBeVisible()
const row = dialog.getByTestId('repair-out-path')
await expect(
row.getByText(dict['editor.views.repair.path_blocked']),
).toBeVisible()
await expect(row.getByRole('button')).toHaveCount(0)
await expect(
dialog.getByRole('button', { name: dict['editor.views.repair.apply'] }),
).toBeDisabled()
await dialog
.getByRole('button', { name: dict['editor.views.repair.cancel'] })
.click()
await expect(dialog).toBeHidden()
// An unrelated change is saved: the path is still the seeded one, byte for byte.
await selectTab(page, dict, 'general')
const nameFr = place(page, 'general').getByLabel(
dict['editor.general.name_fr'],
{
exact: true,
},
)
await nameFr.fill('Fiche sans toucher au tracé')
await nameFr.press('Tab')
await saveDraft(page, dict, seed.revision + 1)
const saved = await serverDocument<{
annotations: { id: string; geometry: Record<string, unknown> }[]
}>(seed.draftId)
const kept = saved.annotations.find((a) => a.id === 'out-path')
expect(kept?.geometry).toEqual({ type: 'path', d: seededPath })
})
test('an unmeasured view: drawing tools and add buttons disabled, the hint shown', async ({
page,
requests,
}) => {
const actor = await editorActor('fr')
requests.forbid(actor.account.email, actor.account.password)
const seed = await seedDraft(actor, { drawing: null, shape: standardShape })
await openEditor(page, dict, actor, seed.sheetId)
// No measurable view: the draft opens on Général (C40).
await selectTab(page, dict, 'annotations')
await expect(
page.getByText(dict['editor.annotations.unmeasured.hint'], {
exact: false,
}),
).toBeVisible()
for (const id of ['point', 'zone', 'link'])
await expect(tool(page, id)).toBeDisabled()
for (const kind of ['point', 'zone', 'detail_trigger'])
await expect(
page.getByRole('button', {
name: dict[`editor.annotations.add.${kind}`],
}),
).toBeDisabled()
await expect(tool(page, 'select')).toBeEnabled()
await expectAccessible(page, 'an unmeasured view with its tools disabled')
})
})
test.describe('editor touch path (real browser)', () => {
test.use({
locale: 'fr-FR',
actionTimeout: 15_000,
hasTouch: true,
viewport: { width: 1280, height: 800 },
})
test.beforeEach(async ({ context }, info) => {
test.skip(isPhone(info), 'touch at 1 024 px runs on desktop') // 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('touch-action follows the tool; a touch drag moves the selected marker', async ({
page,
context,
requests,
}) => {
const { actor } = await open(
page,
pointOf('moving', 'main', { cx: 500, cy: 400, r: 60 }, 'Tactile'),
)
requests.forbid(actor.account.email, actor.account.password)
const box = page.getByTestId('annotation-canvas')
const touchAction = () =>
box.evaluate((el) => getComputedStyle(el).touchAction)
await expect.poll(touchAction).toBe('pan-x pan-y')
await tool(page, 'point').click()
await expect.poll(touchAction).toBe('none')
await tool(page, 'select').click()
await expect.poll(touchAction).toBe('pan-x pan-y')
// A movable selection needs the touch itself: the browser reads touch-action at
// 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')
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)
const touch = (
type: 'touchStart' | 'touchMove' | 'touchEnd',
at: { x: number; y: number } | null,
) =>
cdp.send('Input.dispatchTouchEvent', {
type,
touchPoints: at ? [{ x: at.x, y: at.y }] : [],
})
await touch('touchStart', from)
for (let step = 1; step <= 8; step++)
await touch('touchMove', {
x: from.x + ((to.x - from.x) * step) / 8,
y: from.y,
})
await touch('touchEnd', null)
await expect(shownShape(page)).not.toHaveAttribute('cx', '500')
expect(Math.abs((await shownNumber(page, 'cx')) - 620)).toBeLessThan(3)
})
})