From 2bce81081e98c0a14159cfcd4a7f7d90e1329e70 Mon Sep 17 00:00:00 2001 From: Jaybe Date: Mon, 17 Nov 2025 20:01:13 +0900 Subject: [PATCH] =?UTF-8?q?E2E:=20=EC=8A=A4=EB=83=85=20=EC=9A=B0=EC=84=A0?= =?UTF-8?q?=EC=88=9C=EC=9C=84=20=ED=99=95=EC=9E=A5=20-=20=EC=84=BC?= =?UTF-8?q?=ED=84=B0=20=EC=9A=B0=EC=84=A0,=20=EA=B7=B8=EB=A6=AC=EB=93=9C?= =?UTF-8?q?=20=EB=8B=A8=EB=8F=85=20=EC=8A=A4=EB=83=85(13=E2=86=9216)=20?= =?UTF-8?q?=EC=BC=80=EC=9D=B4=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/e2e/wysiwyg-snap-priority.e2e.ts | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/e2e/wysiwyg-snap-priority.e2e.ts b/tests/e2e/wysiwyg-snap-priority.e2e.ts index e5745e4..575021b 100644 --- a/tests/e2e/wysiwyg-snap-priority.e2e.ts +++ b/tests/e2e/wysiwyg-snap-priority.e2e.ts @@ -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) + }) })