Files
landing-builder/lib/exporter/a11yMainContain.test.ts
T
2025-11-14 16:40:45 +09:00

31 lines
1.3 KiB
TypeScript

import { describe, expect, test } from 'vitest'
import { exportPage } from './html'
import { pageSchema, type Page } from '@/lib/schema/page'
function makePage(): Page {
return pageSchema.parse({
title: 'T',
locale: 'en',
theme: { primaryColor: '#000000', fontFamily: 'Inter' },
sections: [
{ type: 'hero', props: { heading: 'Welcome', subheading: '', imageUrl: 'https://example.com/hero.png' } },
{ type: 'faq', props: { items: [{ q: 'Q1', a: 'A1' }] } },
{ type: 'cta', props: { text: 'Go', href: '#' } },
] as Page['sections'],
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
analytics: { ga4MeasurementId: '', metaPixelId: '', customHeadHtml: '' },
seo: { title: 'SEO', description: 'Desc' },
})
}
describe('Exporter a11y/structure - main contains sections and form', () => {
test('main landmark wraps sections and form markup', () => {
const out = exportPage(makePage())
expect(out.html).toContain('<main id="main" role="main">')
// sections inside main
expect(out.html).toMatch(/<main[\s\S]*<section class="hero"[\s\S]*<section class="faq"[\s\S]*<section class="cta"[\s\S]*<\/main>/)
// form inside main
expect(out.html).toMatch(/<main[\s\S]*<form method="post"[\s\S]*<\/main>/)
})
})