import { describe, it, expect } from 'vitest' import { pageSchema, type Page } from '@/lib/schema/page' import { exportPage } from '@/lib/exporter/html' function makePage(): Page { return pageSchema.parse({ title: 'Sections Regression', locale: 'en', theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' }, sections: [ { type: 'hero', props: { heading: 'Welcome', subheading: '', imageUrl: 'https://via.placeholder.com/800x400' } }, { type: 'features', props: { items: ['F1','F2'] } }, { type: 'benefits', props: { items: ['B1','B2','B3'] } }, { type: 'testimonials', props: { items: [{ author: 'Ada', quote: 'Great' }] } }, { type: 'faq', props: { items: [{ q: 'Q1', a: 'A1' }] } }, { type: 'cta', props: { text: 'Start', href: '#' } }, ], form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } }, seo: { title: 'SEO', description: 'Desc' }, }) } describe('Exporter - sections regression (includes benefits)', () => { it('renders sections with correct ARIA/heading/list structures', () => { const out = exportPage(makePage()) const html = out.html // hero h1 expect(html).toMatch(/
/) expect(html).toMatch(/

Welcome<\/h1>/) // features expect(html).toMatch(/
/) expect(html).toMatch(/

Features<\/h2>/) expect(html).toMatch(/
    [\s\S]*
  • F1<\/li>[\s\S]*
  • F2<\/li>[\s\S]*<\/ul>/) // benefits expect(html).toMatch(/
    /) expect(html).toMatch(/

    Benefits<\/h2>/) expect(html).toMatch(/
      [\s\S]*
    • B1<\/li>[\s\S]*
    • B2<\/li>[\s\S]*
    • B3<\/li>[\s\S]*<\/ul>/) // testimonials expect(html).toMatch(/
      /) expect(html).toMatch(/

      Testimonials<\/h2>/) // faq with h3 expect(html).toMatch(/
      /) expect(html).toMatch(/

      FAQ<\/h2>/) expect(html).toMatch(/

      Q1<\/h3>/) // cta expect(html).toMatch(/
      /) expect(html).toMatch(/

      CTA<\/h2>/) }) })