E2E: 스냅 우선순위 확장 - 센터 우선, 그리드 단독 스냅(13→16) 케이스 추가
Auto PR / open-pr (push) Failing after 11s
Auto Label PR / add-automerge-label (pull_request) Successful in 6s
CI / test (pull_request) Failing after 1m12s

This commit is contained in:
2025-11-17 20:01:13 +09:00
parent e3a8cf84a0
commit 2bce81081e
+50
View File
@@ -45,4 +45,54 @@ test.describe('WYSIWYG - Snap priority (edge > center > grid)', () => {
// Allow small tolerance (±1) due to rounding during drag // Allow small tolerance (±1) due to rounding during drag
expect(Math.abs(s.left - expectedLeft)).toBeLessThanOrEqual(1) 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)
})
}) })