test(ci): add exporter heading levels and a11y typography smoke; update MAIN_PLAN
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { pageSchema, type Page } from '@/lib/schema/page'
|
||||
import { exportPage } from '@/lib/exporter/html'
|
||||
|
||||
const makePage = (overrides: Partial<Page> = {}): Page =>
|
||||
pageSchema.parse({
|
||||
title: 'Validate',
|
||||
locale: 'en',
|
||||
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
|
||||
sections: [],
|
||||
form: {
|
||||
actionUrl: '',
|
||||
fields: [
|
||||
{ type: 'text', name: 'name', label: 'Name', required: true, pattern: '^[A-Za-z ]+$', maxLength: 30 },
|
||||
{ type: 'email', name: 'email', label: 'Email', required: true },
|
||||
{ type: 'textarea', name: 'msg', label: 'Message', required: false, maxLength: 200 },
|
||||
],
|
||||
spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 },
|
||||
},
|
||||
seo: { title: 'Validate', description: 'desc' },
|
||||
...overrides,
|
||||
})
|
||||
|
||||
|
||||
describe('Exporter - field validation attributes', () => {
|
||||
it('text에 pattern/maxLength, textarea에 maxLength를 렌더링한다', () => {
|
||||
const page = makePage()
|
||||
const out = exportPage(page)
|
||||
|
||||
// text: pattern + maxlength
|
||||
expect(out.html).toContain('name="name"')
|
||||
expect(out.html).toContain('pattern="^[A-Za-z ]+$"')
|
||||
expect(out.html).toContain('maxlength="30"')
|
||||
|
||||
// textarea: maxlength
|
||||
expect(out.html).toContain('<textarea')
|
||||
expect(out.html).toContain('name="msg"')
|
||||
expect(out.html).toContain('maxlength="200"')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user