test(ci): add exporter heading levels and a11y typography smoke; update MAIN_PLAN
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
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('<h1 id="hero-heading">Hero Title</h1>')
|
||||
|
||||
// features/testimonials/faq/cta sections labeled by h2
|
||||
expect(html).toContain('<h2 id="features-heading">')
|
||||
expect(html).toContain('<section class="features" aria-labelledby="features-heading">')
|
||||
|
||||
expect(html).toContain('<h2 id="testimonials-heading">')
|
||||
expect(html).toContain('<section class="testimonials" aria-labelledby="testimonials-heading">')
|
||||
|
||||
expect(html).toContain('<h2 id="faq-heading">')
|
||||
expect(html).toContain('<section class="faq" aria-labelledby="faq-heading">')
|
||||
|
||||
expect(html).toContain('<h2 id="cta-heading">')
|
||||
expect(html).toContain('<section class="cta" aria-labelledby="cta-heading">')
|
||||
|
||||
// faq items use h3
|
||||
expect(html).toMatch(/<h3[^>]*>Q1<\/h3>/)
|
||||
expect(html).toMatch(/<h3[^>]*>Q2<\/h3>/)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user