import { describe, expect, test } from 'vitest' import { exportPage } from './html' import { pageSchema, type Page } from '@/lib/schema/page' const makeFullPage = (): Page => pageSchema.parse({ title: 'Heading Levels All', locale: 'en', theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' }, sections: [ { type: 'hero', props: { heading: 'Hero Title', subheading: 'Sub', imageUrl: 'https://example.com/hero.png' } }, { type: 'features', props: { items: ['Feat A', 'Feat B'] } }, { type: 'testimonials', props: { items: [{ author: 'Ada', quote: 'Nice' }] } }, { type: 'faq', props: { items: [{ q: 'Q1', a: 'A1' }, { q: 'Q2', a: 'A2' }] } }, { type: 'cta', props: { text: 'Try', href: '#' } }, ] as Page['sections'], form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } }, seo: { title: 'SEO', description: 'Desc' }, analytics: { ga4MeasurementId: '', metaPixelId: '', customHeadHtml: '' }, }) describe('Exporter heading level consistency (full)', () => { test('hero=h1, others=h2, faq items=h3', () => { const { html } = exportPage(makeFullPage()) // hero expect(html).toContain('

Hero Title

') // features/testimonials/faq/cta sections labeled by h2 expect(html).toContain('

') expect(html).toContain('
') expect(html).toContain('

') expect(html).toContain('
') expect(html).toContain('

') expect(html).toContain('
') expect(html).toContain('

') expect(html).toContain('
') // faq items use h3 expect(html).toMatch(/]*>Q1<\/h3>/) expect(html).toMatch(/]*>Q2<\/h3>/) }) })