auto: PR for feat/wysiwyg-e2e-group-rotate-resize-ns #90
@@ -45,4 +45,54 @@ test.describe('WYSIWYG - Snap priority (edge > center > grid)', () => {
|
||||
// Allow small tolerance (±1) due to rounding during drag
|
||||
expect(Math.abs(s.left - expectedLeft)).toBeLessThanOrEqual(1)
|
||||
})
|
||||
|
||||
test('dragging near another object prefers center snap over grid', async ({ page }) => {
|
||||
await page.goto(wysiwygUrl)
|
||||
const canvas = page.getByTestId('wysiwyg-canvas')
|
||||
await expect(canvas).toBeVisible()
|
||||
|
||||
const addText = page.getByRole('button', { name: /^Add Text$/i })
|
||||
await addText.click()
|
||||
await addText.click()
|
||||
|
||||
const first = page.locator('[data-testid^="obj-text-"]').first()
|
||||
const second = page.locator('[data-testid^="obj-text-"]').nth(1)
|
||||
const b1 = await first.boundingBox()
|
||||
const b2 = await second.boundingBox()
|
||||
if (!b1 || !b2) throw new Error('objects not found')
|
||||
|
||||
// Target the center alignment: move second so its centerX ~= first.centerX
|
||||
const firstCenterX = b1.x + b1.width / 2
|
||||
await page.mouse.move(b2.x + b2.width / 2, b2.y + 5)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(firstCenterX, b2.y + 5)
|
||||
await page.mouse.up()
|
||||
|
||||
const f = await getBox(page, 0)
|
||||
const s = await getBox(page, 1)
|
||||
const sCenter = s.left + Math.round((await second.evaluate((n)=>parseInt((n as HTMLElement).style.width||'0',10))) / 2)
|
||||
expect(Math.abs(sCenter - (f.left + f.width / 2))).toBeLessThanOrEqual(1)
|
||||
})
|
||||
|
||||
test('when no nearby objects, grid snapping applies (13px → 16px)', async ({ page }) => {
|
||||
await page.goto(wysiwygUrl)
|
||||
const canvas = page.getByTestId('wysiwyg-canvas')
|
||||
await expect(canvas).toBeVisible()
|
||||
|
||||
const addText = page.getByRole('button', { name: /^Add Text$/i })
|
||||
await addText.click()
|
||||
|
||||
const obj = page.locator('[data-testid^="obj-text-"]').first()
|
||||
const b = await obj.boundingBox()
|
||||
if (!b) throw new Error('object not found')
|
||||
|
||||
const before = await getBox(page, 0)
|
||||
await page.mouse.move(b.x + 5, b.y + 5)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(b.x + 5 + 13, b.y + 5)
|
||||
await page.mouse.up()
|
||||
|
||||
const after = await getBox(page, 0)
|
||||
expect(after.left - before.left).toBe(16)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user