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.
531 lines
19 KiB
TypeScript
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,
|
|
} 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/)
|
|
const issues = page.getByTestId('annotation-geometry-issues')
|
|
await expect(issues).toBeVisible()
|
|
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); 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(
|
|
page,
|
|
async () => {
|
|
await confirm.click()
|
|
await expect(page.getByTestId('gesture-message')).toBeVisible()
|
|
},
|
|
swaps,
|
|
)
|
|
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(issues).toBeVisible()
|
|
|
|
// Far enough inside: kept, the issue gone, one error less.
|
|
await expectNoShift(page, () => move.click(), swaps)
|
|
await dragInMode(page, { x: 250, y: 250 }, { x: 290, y: 290 })
|
|
await expectNoShift(
|
|
page,
|
|
async () => {
|
|
await confirm.click()
|
|
await expect(issues).toHaveCount(0)
|
|
},
|
|
swaps,
|
|
)
|
|
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)
|
|
})
|
|
})
|