Compare commits

...

3 Commits

Author SHA1 Message Date
jaybe 8f51494433 E2E 스모크 확장: 그룹 리사이즈(E)/회전(15° 스냅) + 라이브리전 가이드 포함 검증 추가
Auto PR / open-pr (push) Successful in 27s
Auto Label PR / add-automerge-label (pull_request) Successful in 6s
CI / test (pull_request) Failing after 1m14s
2025-11-17 19:08:06 +09:00
jaybe e602b16254 E2E 스모크: 그룹 드래그 스냅 델타 동일 적용 검증 추가
Auto PR / open-pr (push) Successful in 21s
Auto Label PR / add-automerge-label (pull_request) Successful in 8s
CI / test (pull_request) Failing after 1m6s
2025-11-17 19:03:16 +09:00
jaybe e4287b8567 CI E2E 수정: 캔버스 빈 영역 클릭 시 마퀴 항상 시작하도록 타깃 판정 완화 2025-11-17 18:59:28 +09:00
4 changed files with 198 additions and 3 deletions
+5 -3
View File
@@ -434,9 +434,11 @@ export function Canvas({ frame, onChange, onSelectIds, enableGuides = true }: Ca
tabIndex={0} tabIndex={0}
onKeyDown={onKeyDown} onKeyDown={onKeyDown}
onMouseDown={(e) => { onMouseDown={(e) => {
// 빈 캔버스 클릭 시 마퀴 시작 또는 선택 해제 // 빈 영역(객체/핸들이 아닌 영역) 클릭 시 마퀴 시작 또는 선택 해제
// 객체 onMouseDown에서 선택을 처리하므로, 여기서는 드래그 박스 시작만 담당 const t = e.target as HTMLElement
if ((e.target as HTMLElement).dataset.testid === 'wysiwyg-canvas') { const isObj = !!t.closest('[data-testid^="obj-"],[aria-label^="object "]')
const isHandle = !!t.closest('[data-testid^="resize-handle-"]')
if (!isObj && !isHandle) {
setSelectedIds([]) setSelectedIds([])
setMarquee({ active: true, x0: e.clientX, y0: e.clientY, x1: e.clientX, y1: e.clientY }) setMarquee({ active: true, x0: e.clientX, y0: e.clientY, x1: e.clientX, y1: e.clientY })
try { onSelectIds?.([]) } catch {} try { onSelectIds?.([]) } catch {}
@@ -0,0 +1,46 @@
import { describe, it, expect } from 'vitest'
import { exportPage } from '@/lib/exporter/html'
import type { ExportOptions } from '@/lib/exporter/html'
import type { Page } from '@/lib/schema/page'
const basePage: Page = {
title: 'Img Matrix',
locale: 'en',
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
sections: [
{ type: 'hero', props: { heading: 'Hero', subheading: '', imageUrl: 'https://example.com/hero.jpg' } },
],
form: {
actionUrl: '',
fields: [],
spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 },
},
analytics: { ga4MeasurementId: '', metaPixelId: '', customHeadHtml: '' },
seo: { title: 'T', description: 'D' },
}
describe('image responsive options - matrix', () => {
it('applies loading and decoding attributes from options', () => {
const opts: ExportOptions = { imageLoading: 'eager', imageDecoding: 'sync' }
const { html } = exportPage(basePage, opts)
expect(html).toMatch(/<img[^>]*loading="eager"/)
expect(html).toMatch(/<img[^>]*decoding="sync"/)
})
it('sets fetchpriority="low" when specified', () => {
const opts: ExportOptions = { imageFetchPriority: 'low' }
const { html } = exportPage(basePage, opts)
expect(html).toMatch(/<img[^>]*fetchpriority="low"/)
})
it('prefers preset sizes over auto default when both provided (no explicit sizes)', () => {
const opts: ExportOptions = {
imageSrcset: 'https://example.com/hero.jpg 1x, https://example.com/hero@2x.jpg 2x',
imageAutoSizes: true,
imageSizesPreset: 'mobile-first',
}
const { html } = exportPage(basePage, opts)
// preset should win over default auto sizes
expect(html).toMatch(/<img[^>]*sizes="\(max-width: 640px\) 100vw, 800px"/)
})
})
+58
View File
@@ -0,0 +1,58 @@
import { test, expect } from '@playwright/test'
const wysiwygUrl = '/en/wysiwyg'
function snap8(v: number) { return Math.round(v / 8) * 8 }
async function getLefts(page: import('@playwright/test').Page) {
const els = page.locator('[data-testid^="obj-text-"]')
const count = await els.count()
const results: number[] = []
for (let i = 0; i < count; i++) {
const style = await els.nth(i).evaluate((n) => (n as HTMLElement).style.left || '0')
results.push(parseInt(style || '0', 10))
}
return results
}
test.describe('WYSIWYG - Group drag', () => {
test('marquee select two items and drag group by 16px on X (snaps to 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()
// Marquee select both
const box = await canvas.boundingBox()
if (!box) throw new Error('canvas not found')
await page.mouse.move(box.x + 40, box.y + 40)
await page.mouse.down()
await page.mouse.move(box.x + 240, box.y + 160)
await page.mouse.up()
const live = page.getByTestId('aria-live')
await expect(live).toContainText(/선택\s*2개/)
const before = await getLefts(page)
// Drag one of selected (the second) by +16 on X
const target = page.locator('[data-testid^="obj-text-"]').nth(1)
const tbox = await target.boundingBox()
if (!tbox) throw new Error('target not found')
await page.mouse.move(tbox.x + 5, tbox.y + 5)
await page.mouse.down()
await page.mouse.move(tbox.x + 21, tbox.y + 5) // ~+16 on X
await page.mouse.up()
const after = await getLefts(page)
// Expect both moved by same snapped delta
const expectedDx = snap8(before[1] + 16) - before[1]
expect(after.length).toBeGreaterThanOrEqual(2)
expect(after[0]).toBe(before[0] + expectedDx)
expect(after[1]).toBe(before[1] + expectedDx)
})
})
@@ -0,0 +1,89 @@
import { test, expect } from '@playwright/test'
const wysiwygUrl = '/en/wysiwyg'
function snap8(v: number) { return Math.round(v / 8) * 8 }
async function getBoxStyles(page: import('@playwright/test').Page, nth: number) {
const el = page.locator('[data-testid^="obj-text-"]').nth(nth)
const left = await el.evaluate((n) => parseInt((n as HTMLElement).style.left || '0', 10))
const top = await el.evaluate((n) => parseInt((n as HTMLElement).style.top || '0', 10))
const width = await el.evaluate((n) => parseInt((n as HTMLElement).style.width || '0', 10))
const height = await el.evaluate((n) => parseInt((n as HTMLElement).style.height || '0', 10))
const transform = await el.evaluate((n) => (n as HTMLElement).style.transform || '')
return { left, top, width, height, transform }
}
test.describe('WYSIWYG - Group resize/rotate and guide live region', () => {
test('group E handle resizes both by snapped delta without shifting x', 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()
// Marquee select both
const box = await canvas.boundingBox()
if (!box) throw new Error('canvas not found')
await page.mouse.move(box.x + 40, box.y + 40)
await page.mouse.down()
await page.mouse.move(box.x + 260, box.y + 160)
await page.mouse.up()
const live = page.getByTestId('aria-live')
await expect(live).toContainText(/선택\s*2개/)
const b0 = await getBoxStyles(page, 0)
const b1 = await getBoxStyles(page, 1)
// Drag east handle of second by +16px
const target = page.locator('[data-testid^="obj-text-"]').nth(1)
const tbox = await target.boundingBox()
if (!tbox) throw new Error('target not found')
await page.mouse.move(tbox.x + tbox.width - 5, tbox.y + 5)
await page.mouse.down()
await page.mouse.move(tbox.x + tbox.width + 16, tbox.y + 5)
await page.mouse.up()
const a0 = await getBoxStyles(page, 0)
const a1 = await getBoxStyles(page, 1)
const dw = snap8(b1.width + 16) - b1.width
expect(a0.left).toBe(b0.left)
expect(a1.left).toBe(b1.left)
expect(a0.width).toBe(b0.width + dw)
expect(a1.width).toBe(b1.width + dw)
})
test('rotate handle snaps to 15deg and live region includes guide coords while dragging', 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 target = page.locator('[data-testid^="obj-text-"]').first()
const tbox = await target.boundingBox()
if (!tbox) throw new Error('target not found')
// Select
await target.click()
// Drag rotate handle horizontally to cause rotation ~15deg (snapped)
const rotateHandle = page.locator('[data-testid^="rotate-handle-"]').first()
const hbox = await rotateHandle.boundingBox()
if (!hbox) throw new Error('rotate handle not found')
await page.mouse.move(hbox.x + 5, hbox.y + 5)
await page.mouse.down()
await page.mouse.move(hbox.x + 40, hbox.y + 5)
const live = page.getByTestId('aria-live')
await expect(live).toContainText(/가이드\s*x=|y=/)
await page.mouse.up()
const a = await getBoxStyles(page, 0)
expect(a.transform).toMatch(/rotate\(15deg\)|rotate\(30deg\)/)
})
})