43 lines
2.1 KiB
TypeScript
43 lines
2.1 KiB
TypeScript
import { describe, expect, test } from 'vitest'
|
|
import { exportPage } from './html'
|
|
import { pageSchema, type Page } from '@/lib/schema/page'
|
|
|
|
const makePage = (): Page =>
|
|
pageSchema.parse({
|
|
title: 'Snapshot',
|
|
locale: 'en',
|
|
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
|
|
sections: [
|
|
{ type: 'hero', props: { heading: 'Welcome', subheading: 'Sub', imageUrl: 'https://example.com/hero.png' } },
|
|
{ type: 'features', props: { items: ['One', 'Two'] } },
|
|
{ type: 'testimonials', props: { items: [{ author: 'Jane', quote: 'Great' }] } },
|
|
{ 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 } },
|
|
seo: { title: 'SEO', description: 'Desc' },
|
|
analytics: { ga4MeasurementId: '', metaPixelId: '', customHeadHtml: '' },
|
|
})
|
|
|
|
describe('Exporter regression snapshot (markers only)', () => {
|
|
test('combined markers for headings/aria/responsive exist', () => {
|
|
const out = exportPage(makePage())
|
|
const { html, css } = out
|
|
// headings/aria markers
|
|
expect(html).toContain('<h1 id="hero-heading">Welcome</h1>')
|
|
expect(html).toContain('<section class="features" aria-labelledby="features-heading">')
|
|
expect(html).toContain('<h2 id="features-heading">')
|
|
expect(html).toContain('<section class="testimonials" aria-labelledby="testimonials-heading">')
|
|
expect(html).toContain('<h2 id="testimonials-heading">')
|
|
expect(html).toContain('<section class="faq" aria-labelledby="faq-heading">')
|
|
expect(html).toContain('<h2 id="faq-heading">')
|
|
expect(html).toContain('<section class="cta" aria-labelledby="cta-heading">')
|
|
expect(html).toContain('<h2 id="cta-heading">')
|
|
// responsive/a11y CSS markers
|
|
expect(css).toMatch(/@media \(max-width: 640px\)/)
|
|
expect(css).toMatch(/@media \(prefers-reduced-motion: reduce\)/)
|
|
expect(css).toMatch(/a\.skip-link:focus/)
|
|
expect(css).toMatch(/outline:\s*3px\s*solid/)
|
|
})
|
|
})
|