feat(wysiwyg): 레이어/속성 패널 및 Export(절대배치) 1차 TDD/구현
- LayersPanel: 순서 변경/잠금/숨김 토글 - PropsPanel: 위치/크기/회전 및 이미지 src/alt 편집 - exportFrame: frame-scale 토큰 및 오브젝트 절대배치 HTML/CSS 출력 - 테스트 추가 및 전체 그린 유지
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { render, fireEvent } from '@testing-library/react'
|
||||
import { Canvas } from '@/components/wysiwyg/Canvas'
|
||||
import type { Frame } from '@/lib/wysiwyg/schema'
|
||||
|
||||
function makeFrame(): Frame {
|
||||
return {
|
||||
id: 'f1',
|
||||
width: 400,
|
||||
height: 300,
|
||||
background: '#ffffff',
|
||||
layers: [
|
||||
{
|
||||
id: 'l1',
|
||||
name: 'L1',
|
||||
visible: true,
|
||||
locked: false,
|
||||
objects: [
|
||||
{ id: 'o1', type: 'image', x: 100, y: 100, width: 50, height: 40, rotate: 0, zIndex: 0, props: { src: 'x', alt: '' } },
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
describe('WYSIWYG Canvas resize with 8px snap', () => {
|
||||
it('dragging bottom-right handle resizes and snaps to nearest 8px', () => {
|
||||
const frame = makeFrame()
|
||||
const { getByTestId } = render(<Canvas frame={frame} />)
|
||||
const handle = getByTestId('resize-handle-o1')
|
||||
const canvas = getByTestId('wysiwyg-canvas')
|
||||
|
||||
// start resize
|
||||
fireEvent.mouseDown(handle, { clientX: 150, clientY: 140 })
|
||||
// move by +7,+9 → width 50-> 57 -> snap8 => 56, height 40->49 -> snap8 => 48
|
||||
fireEvent.mouseMove(canvas, { clientX: 157, clientY: 149 })
|
||||
fireEvent.mouseUp(canvas)
|
||||
|
||||
const obj = getByTestId('obj-o1')
|
||||
expect(obj).toHaveStyle({ width: '56px', height: '48px' })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user