테스트/린트 안정화: 버튼 쿼리 모호성 제거, 훅 deps 보강, vi.spyOn 모킹, 멀티선택 Moveable 간섭 방지 재확인, 스냅 우선순위 회귀 그린
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { exportFrame } from '@/lib/wysiwyg/export'
|
||||
import type { Frame } from '@/lib/wysiwyg/schema'
|
||||
|
||||
function baseFrame(): Frame {
|
||||
return {
|
||||
id: 'f', width: 400, height: 300, background: '#ffffff',
|
||||
layers: [{ id: 'l1', name: 'Base', visible: true, locked: false, objects: [] }],
|
||||
}
|
||||
}
|
||||
|
||||
describe('wysiwyg export - form validation attributes', () => {
|
||||
it('input: pattern, minLength, maxLength exported', () => {
|
||||
const f = baseFrame()
|
||||
f.layers[0].objects.push({ id: 'in1', type: 'input', x: 0, y: 0, width: 200, height: 40, rotate: 0, zIndex: 0, props: { name: 'code', label: 'Code', placeholder: '', required: false, pattern: '[A-Z]{3}', minLength: 3, maxLength: 3 } })
|
||||
const out = exportFrame(f)
|
||||
expect(out.html).toMatch(/<input id="in1-control" name="code"[^>]*pattern="\[A-Z\]\{3\}"/)
|
||||
expect(out.html).toMatch(/<input id="in1-control" name="code"[^>]*minlength="3"/i)
|
||||
expect(out.html).toMatch(/<input id="in1-control" name="code"[^>]*maxlength="3"/i)
|
||||
})
|
||||
|
||||
it('textarea: minLength, maxLength exported', () => {
|
||||
const f = baseFrame()
|
||||
f.layers[0].objects.push({ id: 'ta1', type: 'textarea', x: 0, y: 0, width: 200, height: 80, rotate: 0, zIndex: 0, props: { name: 'msg', label: 'Msg', placeholder: '', rows: 4, required: false, minLength: 10, maxLength: 200 } })
|
||||
const out = exportFrame(f)
|
||||
expect(out.html).toMatch(/<textarea id="ta1-control" name="msg"[^>]*minlength="10"/i)
|
||||
expect(out.html).toMatch(/<textarea id="ta1-control" name="msg"[^>]*maxlength="200"/i)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user