diff --git a/apps/app/e2e/shell/editor-deselect.spec.ts b/apps/app/e2e/shell/editor-deselect.spec.ts new file mode 100644 index 00000000..55add1cd --- /dev/null +++ b/apps/app/e2e/shell/editor-deselect.spec.ts @@ -0,0 +1,681 @@ +import { fr } from '@/i18n/fr' +import type { CDPSession, Page, TestInfo } from '@playwright/test' +import { expect, test } from '../support/browser' +import { dropLateReplays, routeToSandbox } from '../support/sandbox' +import { + annotationList, + clickDrawing, + clientOf, + creationPanel, + editorActor, + geometryField, + historyButton, + openEditor, + openReferences, + pickAnnotation, + place, + pointOf, + reloadAccepting, + revisionText, + saveLine, + seedDraft, + selectionTag, + selectTab, + serverDocument, + serverRevision, + shapeWith, + toolButton, + UNSAVED_LINE, +} from '../support/editor' + +// R1 (« Défaire » / « Refaire », « Désélectionner », Escape) and D6b (an empty tap or click +// on the drawing deselects): the button, Escape by place, mouse, touch (with a recorder +// of the events each step really produced) and the read-only twin at 375 px. + +const dict = fr +const isPhone = (info: TestInfo) => info.project.name === 'chromium-375' +const properties = (page: Page) => page.getByTestId('annotation-properties') +const overview = (page: Page) => page.getByTestId('annotation-overview') +const box = (page: Page) => page.getByTestId('annotation-canvas') +const liveRegion = (page: Page) => + page + .locator('p[aria-live="polite"]') + .filter({ hasText: dict['editor.annotations.deselected'] }) + +const POINT = 'Pt Alpha' +const ZONE = 'Zone Beta' +const LINK = 'Accès Gamma' +// Away from every annotation: the inner circle, the inner rect, the root, the box margin. +const IN_CIRCLE = { x: 500, y: 300 } +const IN_RECT = { x: 400, y: 700 } +const IN_ROOT = { x: 20, y: 20 } + +const zone = { + ...pointOf('zone-b', 'main', { cx: 0, cy: 0, r: 1 }, ZONE), + kind: 'zone', + geometry: { + type: 'polygon', + points: [ + [100, 100], + [250, 100], + [250, 250], + [100, 250], + ], + }, +} +const link = { + id: 'link-g', + kind: 'detail_trigger', + view_id: 'main', + category_id: 'cat-a', + laterality: 'unpaired', + geometry: { + type: 'polygon', + points: [ + [750, 500], + [900, 500], + [900, 650], + [750, 650], + ], + }, + review_status: 'reviewed', + name: { fr: LINK, en: LINK }, + opens_view_id: 'detail-a', +} + +async function open(page: Page, editable = true) { + const actor = await editorActor('fr') + const seed = await seedDraft(actor, { + shape: shapeWith( + pointOf('pt-a', 'main', { cx: 700, cy: 250, r: 30 }, POINT), + zone, + link, + ), + }) + const saves: string[] = [] + page.on('request', (request) => { + if (request.url().includes('save_sheet_draft')) saves.push(request.url()) + }) + await openEditor(page, dict, actor, seed.sheetId) + if (editable) await expect(toolButton(page, dict, 'point')).toBeEnabled() + return { actor, seed, saves } +} + +const frames = (page: Page) => + page.evaluate( + () => + new Promise((done) => + requestAnimationFrame(() => requestAnimationFrame(() => done())), + ), + ) + +async function expectSelected(page: Page, name: string) { + await expect(selectionTag(page)).toContainText(name) + await expect(properties(page)).toBeVisible() +} + +async function expectDeselected(page: Page) { + await expect(selectionTag(page)).toHaveCount(0) + await expect(properties(page)).toHaveCount(0) + await expect(overview(page)).toBeVisible() +} + +/** A negative check: the state is still there after two animation frames. */ +async function expectKept(page: Page, name: string) { + await frames(page) + await expectSelected(page, name) +} + +const select = async (page: Page, name: string) => { + await pickAnnotation(page, dict, name) + await expectSelected(page, name) +} + +/** Clicks a drawing point (coordinates recomputed at the press, LRN-104). */ +const clickAt = (page: Page, at: { x: number; y: number }) => + clickDrawing(page, at.x, at.y) + +async function mouseJitter(page: Page, x: number, y: number) { + const at = await clientOf(page, x, y) + await page.mouse.move(at.x, at.y) + await page.mouse.down() + await page.mouse.move(at.x + 2, at.y + 1) + await page.mouse.up() +} + +test.describe('deselect and D6b (editor, mouse and keyboard)', () => { + 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('« Désélectionner »: live region, focus on the row, document unchanged', async ({ + page, + requests, + }) => { + const { actor, seed, saves } = await open(page) + requests.forbid(actor.account.email, actor.account.password) + const before = await serverDocument(seed.draftId) + await select(page, POINT) + await properties(page) + .getByRole('button', { name: dict['editor.annotations.deselect'] }) + .click() + await expectDeselected(page) + await expect(liveRegion(page)).toHaveCount(1) + await expect( + annotationList(page, dict).getByRole('button', { name: POINT }), + ).toBeFocused() + await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE) + expect(await reloadAccepting(page), 'no unsaved-changes prompt').toEqual([]) + await expect(saveLine(page)).toHaveText(revisionText(dict, 1)) + expect(await serverRevision(seed.draftId)).toBe(1) + expect(await serverDocument(seed.draftId)).toEqual(before) + expect(saves).toEqual([]) + }) + + test('Escape: canvas, field, delete dialog, references panel, tracing', async ({ + page, + requests, + }) => { + const { actor, saves } = await open(page) + requests.forbid(actor.account.email, actor.account.password) + + // The canvas box focused: the selection goes. + await select(page, POINT) + await box(page).focus() + await page.keyboard.press('Escape') + await expectDeselected(page) + + // A field focused: nothing happens, the field keeps the focus. + await select(page, POINT) + const cx = geometryField(page, dict, 'cx') + await cx.focus() + await page.keyboard.press('Escape') + await expectKept(page, POINT) + await expect(cx).toBeFocused() + + // The delete dialog: only it closes (LRN-111: wait until it is gone). + await properties(page) + .getByRole('button', { name: dict['editor.action.delete'] }) + .click() + const dialog = page.getByRole('dialog') + await expect(dialog).toBeVisible() + await page.keyboard.press('Escape') + await expect(dialog).toHaveCount(0) + await expectKept(page, POINT) + + // The references panel: it closes, the selection stays, a second Escape deselects. + await openReferences(page, dict) + await page.keyboard.press('Escape') + await expect(place(page, 'references')).toHaveCount(0) + await expectKept(page, POINT) + await box(page).focus() + await page.keyboard.press('Escape') + await expectDeselected(page) + + // A tracing: Escape cancels the tracing only. + await select(page, POINT) + await toolButton(page, dict, 'zone').click() + await clickAt(page, { x: 300, y: 500 }) + await clickAt(page, { x: 400, y: 500 }) + const bar = page.getByTestId('tracing-bar') + await expect(bar).toBeVisible() + await box(page).focus() + await page.keyboard.press('Escape') + await expect(bar).toHaveCount(0) + await expectKept(page, POINT) + expect(saves).toEqual([]) + }) + + test('mouse: empty clicks deselect, annotations select, the selected one stays', async ({ + page, + requests, + }) => { + const { actor, saves } = await open(page) + requests.forbid(actor.account.email, actor.account.password) + await select(page, POINT) + for (const at of [IN_CIRCLE, IN_RECT, IN_ROOT]) { + await clickAt(page, at) + await expectDeselected(page) + await select(page, POINT) + } + // The margin of the box beside the drawing (the box is 4:3, the drawing 5:4). + const rect = (await box(page).boundingBox())! + await page.mouse.click(rect.x + 3, rect.y + rect.height / 2) + await expectDeselected(page) + + // Selecting: point, zone interior, link. + const targets: [string, { x: number; y: number }][] = [ + [POINT, { x: 700, y: 250 }], + [ZONE, { x: 175, y: 175 }], + [LINK, { x: 825, y: 575 }], + ] + for (const [name, at] of targets) { + await clickAt(page, at) + await expectSelected(page, name) + } + + // The selected point and zone: click, double click and a 2 px jitter keep them. + for (const [name, at] of targets.slice(0, 2)) { + await clickAt(page, at) + await expectSelected(page, name) + await clickAt(page, at) + await expectKept(page, name) + const now = await clientOf(page, at.x, at.y) + await page.mouse.dblclick(now.x, now.y) + await expectKept(page, name) + await mouseJitter(page, at.x, at.y) + await expectKept(page, name) + } + await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE) + expect(saves).toEqual([]) + }) + + test('zoom, pan, marker drag and Ctrl+wheel keep the selection; a 2 px jitter on empty deselects', async ({ + page, + requests, + }) => { + const { actor, saves } = await open(page) + requests.forbid(actor.account.email, actor.account.password) + await select(page, POINT) + await page.getByRole('button', { name: dict['catalogue.zoom.in'] }).click() + await expectKept(page, POINT) + + // A drag-pan of 20 px on empty. + const from = await clientOf(page, IN_CIRCLE.x, IN_CIRCLE.y) + await page.mouse.move(from.x, from.y) + await page.mouse.down() + await page.mouse.move(from.x + 10, from.y + 4, { steps: 3 }) + await page.mouse.move(from.x + 20, from.y + 8, { steps: 3 }) + await page.mouse.up() + await expectKept(page, POINT) + + // Ctrl+wheel over empty. + const wheel = await clientOf(page, IN_CIRCLE.x, IN_CIRCLE.y) + await page.mouse.move(wheel.x, wheel.y) + await page.keyboard.down('Control') + await page.mouse.wheel(0, -120) + await page.keyboard.up('Control') + await expectKept(page, POINT) + + // Back to the whole drawing, then a marker drag: the selection stays, the move is + // undone from the header. + await page.getByRole('button', { name: dict['catalogue.zoom.fit'] }).click() + const start = await clientOf(page, 700, 250) + await page.mouse.move(start.x, start.y) + await page.mouse.down() + await page.mouse.move(start.x - 40, start.y + 30, { steps: 6 }) + await page.mouse.up() + await expectKept(page, POINT) + await expect(saveLine(page)).toHaveText(UNSAVED_LINE) + await historyButton(page, dict, 'undo').click() + await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE) + await expectSelected(page, POINT) + + // A 2 px jitter on empty is a tap. + await mouseJitter(page, IN_CIRCLE.x, IN_CIRCLE.y) + await expectDeselected(page) + expect(saves).toEqual([]) + }) + + test('a typed value is applied by the click that deselects; « Désélectionner » commits in one click', async ({ + page, + requests, + }) => { + const { actor, saves } = await open(page) + requests.forbid(actor.account.email, actor.account.password) + const cx = geometryField(page, dict, 'cx') + + // Valid value, no blur, ONE click on the drawing. + await select(page, POINT) + await expect(cx).toHaveValue('700') + await cx.fill('720') + await clickAt(page, IN_CIRCLE) + await expectDeselected(page) + await expect(saveLine(page)).toHaveText(/1 modification non enregistrée/) + // Undo reverts the value. + await historyButton(page, dict, 'undo').click() + await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE) + await select(page, POINT) + await expect(cx).toHaveValue('700') + + // « Désélectionner » with an unblurred refused value: closed at once, unchanged. + const deselect = properties(page).getByRole('button', { + name: dict['editor.annotations.deselect'], + }) + await cx.fill('abc') + await deselect.click() + await expectDeselected(page) + await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE) + await select(page, POINT) + await expect(cx).toHaveValue('700') + + // « Désélectionner » with an unblurred valid value: committed and closed. + await cx.fill('730') + 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') + expect(saves).toEqual([]) + }) +}) + +interface Recorded { + type: string + primary: boolean + pointerType: string + anno: string | null +} + +/** A capture-phase recorder: what the page really received for each gesture. */ +async function startRecorder(page: Page) { + await page.evaluate(() => { + const w = window as unknown as { __rec: Recorded[]; __live: string[] } + w.__rec = [] + w.__live = [] + const anno = (target: EventTarget | null) => + target instanceof Element + ? (target.closest('[data-anno-id]')?.getAttribute('data-anno-id') ?? + null) + : null + for (const type of ['pointerdown', 'pointerup', 'pointercancel', 'click']) + document.addEventListener( + type, + (event) => { + const pointer = event as PointerEvent + w.__rec.push({ + type, + primary: pointer.isPrimary, + pointerType: pointer.pointerType ?? '', + anno: anno(event.target), + }) + }, + true, + ) + for (const live of document.querySelectorAll('p[aria-live="polite"]')) + new MutationObserver(() => w.__live.push(live.textContent ?? '')).observe( + live, + { childList: true, characterData: true, subtree: true }, + ) + }) +} + +async function takeRecord(page: Page) { + return page.evaluate(() => { + const w = window as unknown as { __rec: Recorded[]; __live: string[] } + return { events: w.__rec.splice(0), live: w.__live.splice(0) } + }) +} + +function summary(events: Recorded[]): string { + const count = (pick: (e: Recorded) => boolean) => events.filter(pick).length + const clicks = events.filter((e) => e.type === 'click') + return [ + `pointerdown primary ${count((e) => e.type === 'pointerdown' && e.primary)}`, + `pointerdown non-primary ${count((e) => e.type === 'pointerdown' && !e.primary)}`, + `pointerup ${count((e) => e.type === 'pointerup')}`, + `pointercancel ${count((e) => e.type === 'pointercancel')}`, + `click ${clicks.length}`, + `click targets [${clicks.map((c) => c.anno ?? 'none').join(', ')}]`, + ].join('; ') +} + +type TouchPoint = { x: number; y: number } + +const touch = ( + cdp: CDPSession, + type: 'touchStart' | 'touchMove' | 'touchEnd', + points: TouchPoint[], +) => + cdp.send('Input.dispatchTouchEvent', { + type, + touchPoints: points.map((p, id) => ({ x: p.x, y: p.y, id })), + }) + +async function tap(cdp: CDPSession, at: TouchPoint) { + await touch(cdp, 'touchStart', [at]) + await touch(cdp, 'touchEnd', []) +} + +async function drag(cdp: CDPSession, from: TouchPoint, to: TouchPoint) { + await touch(cdp, 'touchStart', [from]) + for (let step = 1; step <= 6; step++) + await touch(cdp, 'touchMove', [ + { + x: from.x + ((to.x - from.x) * step) / 6, + y: from.y + ((to.y - from.y) * step) / 6, + }, + ]) + await touch(cdp, 'touchEnd', []) +} + +/** The id of the annotated element under a client point, null on empty drawing. */ +const annotationUnder = (page: Page, at: TouchPoint) => + page.evaluate( + ({ x, y }) => + document + .elementFromPoint(x, y) + ?.closest('[data-anno-id]') + ?.getAttribute('data-anno-id') ?? null, + at, + ) + +test.describe('deselect and D6b (touch, editor at 1 280 px)', () => { + 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 280 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('taps deselect once, near annotations and the canvas bottom; drags, two fingers and pinch keep', async ({ + page, + context, + requests, + }, info) => { + const { actor, saves } = await open(page) + requests.forbid(actor.account.email, actor.account.password) + const cdp = await context.newCDPSession(page) + await startRecorder(page) + const report = async (step: string) => { + const { events, live } = await takeRecord(page) + const line = `${summary(events)}; live ${JSON.stringify(live)}` + info.annotations.push({ type: `recorder ${step}`, description: line }) + console.log(`RECORDER ${step}: ${line}`) + return { events, live } + } + const announced = (live: string[]) => + live.some((text) => text.includes(dict['editor.annotations.deselected'])) + await box(page).scrollIntoViewIfNeeded() + + // a. A tap on the inner circle. + await select(page, POINT) + await takeRecord(page) + await tap(cdp, await clientOf(page, IN_CIRCLE.x, IN_CIRCLE.y)) + await expectDeselected(page) + const plain = await report('a tap on empty') + expect(announced(plain.live)).toBe(true) + + // b. Empty drawing, a zone about 40 px below the tap. + await select(page, POINT) + await takeRecord(page) + const top = await clientOf(page, 175, 100) + const above = { x: top.x, y: top.y - 40 } + expect(await annotationUnder(page, above)).toBeNull() + await tap(cdp, above) + await expectDeselected(page) + await expect(creationPanel(page)).toHaveCount(0) + await report('b tap 40 px above a zone') + + // c. Within 36 px of the canvas bottom, above the add buttons. + await select(page, POINT) + await takeRecord(page) + await box(page).scrollIntoViewIfNeeded() + const rect = (await box(page).boundingBox())! + const bottom = { x: rect.x + rect.width / 2, y: rect.y + rect.height - 36 } + expect(bottom.y).toBeLessThan(800) + expect(await annotationUnder(page, bottom)).toBeNull() + await tap(cdp, bottom) + await expectDeselected(page) + await expect(creationPanel(page)).toHaveCount(0) + await report('c tap 36 px above the canvas bottom') + + // d. About 6 px outside a marker: the marker or nothing, never both. + await select(page, ZONE) + await takeRecord(page) + const centre = await clientOf(page, 700, 250) + const edge = await clientOf(page, 730, 250) + const near = { x: edge.x + 6, y: centre.y } + await tap(cdp, near) + await frames(page) + const nearRecord = await report('d tap 6 px outside a marker') + const marker = await selectionTag(page).count() + if (marker > 0) { + await expect(selectionTag(page)).toContainText(POINT) + expect(announced(nearRecord.live), 'selected AND announced').toBe(false) + } else { + await expectDeselected(page) + } + info.annotations.push({ + type: 'near-miss outcome', + description: marker > 0 ? 'marker selected' : 'deselected', + }) + + // e. One-finger drag on empty drawing. + await select(page, POINT) + await takeRecord(page) + const dragFrom = await clientOf(page, IN_CIRCLE.x, IN_CIRCLE.y) + await drag(cdp, dragFrom, { x: dragFrom.x + 40, y: dragFrom.y + 20 }) + await expectKept(page, POINT) + await report('e one-finger drag') + + // f. Two-finger tap on empty drawing. + await takeRecord(page) + const two = await clientOf(page, IN_CIRCLE.x, IN_CIRCLE.y) + const pair = [two, { x: two.x + 40, y: two.y }] + await touch(cdp, 'touchStart', pair) + await touch(cdp, 'touchEnd', []) + await expectKept(page, POINT) + await report('f two-finger tap') + + // g. Pinch on empty drawing. + await takeRecord(page) + const mid = await clientOf(page, IN_CIRCLE.x, IN_CIRCLE.y) + await touch(cdp, 'touchStart', [ + { x: mid.x - 20, y: mid.y }, + { x: mid.x + 20, y: mid.y }, + ]) + for (let step = 1; step <= 5; step++) + await touch(cdp, 'touchMove', [ + { x: mid.x - 20 - step * 8, y: mid.y }, + { x: mid.x + 20 + step * 8, y: mid.y }, + ]) + await touch(cdp, 'touchEnd', []) + await expectKept(page, POINT) + await report('g pinch') + + expect(saves).toEqual([]) + }) +}) + +test.describe('deselect and D6b (read-only twin at 375 px)', () => { + test.use({ locale: 'fr-FR', actionTimeout: 15_000 }) + test.beforeEach(async ({ context }, info) => { + test.skip(!isPhone(info), 'the twin is the phone view') // 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('tap a marker, tap the rect: deselected, focus on the box; drag and two fingers keep', async ({ + page, + context, + requests, + }, info) => { + const { actor, saves } = await open(page, false) + requests.forbid(actor.account.email, actor.account.password) + await selectTab(page, dict, 'annotations') + const canvas = page.getByTestId('catalogue-canvas') + await expect(canvas).toBeVisible() + const cdp = await context.newCDPSession(page) + await startRecorder(page) + const report = async (step: string) => { + const { events } = await takeRecord(page) + info.annotations.push({ + type: `recorder ${step}`, + description: summary(events), + }) + console.log(`RECORDER ${step}: ${summary(events)}`) + return events + } + /** Client point of a drawing coordinate, through the twin's own svg. */ + const twinAt = async (x: number, y: number) => { + await canvas.scrollIntoViewIfNeeded() + return page + .getByTestId('catalogue-canvas-drawing') + .locator('svg') + .first() + .evaluate( + (svg, at) => { + const root = svg as unknown as SVGSVGElement + const p = root.createSVGPoint() + p.x = at.x + p.y = at.y + const m = p.matrixTransform(root.getScreenCTM()!) + return { x: m.x, y: m.y } + }, + { x, y }, + ) + } + const markerAt = async () => { + const found = await page + .getByTestId('catalogue-canvas-drawing') + .locator('[data-anno-id="pt-a"]') + .first() + .boundingBox() + return { x: found!.x + found!.width / 2, y: found!.y + found!.height / 2 } + } + + await takeRecord(page) + await tap(cdp, await markerAt()) + await expect(selectionTag(page)).toContainText(POINT) + await report('twin tap on a marker') + + await takeRecord(page) + await tap(cdp, await twinAt(IN_RECT.x, IN_RECT.y)) + await expect(selectionTag(page)).toHaveCount(0) + await expect(canvas).toBeFocused() + await report('twin tap on the rect') + + await tap(cdp, await markerAt()) + await expect(selectionTag(page)).toContainText(POINT) + await takeRecord(page) + const from = await twinAt(IN_CIRCLE.x, IN_CIRCLE.y) + await drag(cdp, from, { x: from.x + 30, y: from.y + 10 }) + await frames(page) + await expect(selectionTag(page)).toContainText(POINT) + await report('twin one-finger drag') + + await takeRecord(page) + const two = await twinAt(IN_CIRCLE.x, IN_CIRCLE.y) + await touch(cdp, 'touchStart', [two, { x: two.x + 30, y: two.y }]) + await touch(cdp, 'touchEnd', []) + await frames(page) + await expect(selectionTag(page)).toContainText(POINT) + await report('twin two-finger tap') + expect(saves).toEqual([]) + }) +}) diff --git a/apps/app/e2e/shell/editor-equine.spec.ts b/apps/app/e2e/shell/editor-equine.spec.ts index be93803e..b1a73d4b 100644 --- a/apps/app/e2e/shell/editor-equine.spec.ts +++ b/apps/app/e2e/shell/editor-equine.spec.ts @@ -13,6 +13,7 @@ import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { place, type Actor, + annotationList, closeReferences, editorActor, openEditor, @@ -20,6 +21,7 @@ import { openSection, SECTIONS, seedDraft, + selectionTag, selectTab, serverDocument, showDrawing, @@ -304,6 +306,45 @@ test.describe('equine working copy and commit latency', () => { expect(errors, 'page errors on the equine copy').toEqual([]) }) + test('an empty click on the horse drawing deselects the annotation (D6b)', async ({ + page, + requests, + }) => { + test.setTimeout(120_000) + expect(copyId).not.toBe('') + requests.forbid(actor.account.email, actor.account.password) + await signIn(page, actor.account, dict) + await page.goto('/app/admin') + await stepUpAdmin(page, dict, actor.secret) + await page.goto(`/app/admin/sheets/${copyId}/draft`) + await expect(toolButton(page, dict, 'point')).toBeEnabled() + await showDrawing(page, dict) + await annotationList(page, dict).getByRole('button').first().click() + await expect(selectionTag(page)).toBeVisible() + // A horse path no annotation covers: its box centre hits the path itself. + const at = await page + .getByTestId('annotation-canvas') + .evaluate((canvas) => { + const paths = canvas.querySelectorAll('path') + for (const path of paths) { + if (path.closest('[data-anno-id]')) continue + const r = path.getBoundingClientRect() + const x = r.x + r.width / 2 + const y = r.y + r.height / 2 + if (document.elementFromPoint(x, y) !== path) continue + return { x, y } + } + return null + }) + expect( + at, + 'a horse path with no annotation under its centre', + ).not.toBeNull() + await page.mouse.click(at!.x, at!.y) + await expect(selectionTag(page)).toHaveCount(0) + await expect(page.getByTestId('annotation-overview')).toBeVisible() + }) + test('commit latency on the equine copy', async ({ page, requests }) => { test.setTimeout(180_000) expect(copyId).not.toBe('')