Files

31 lines
1.1 KiB
TypeScript

import { expect } from 'vitest'
export function assertSectionA11y(html: string) {
// basic landmarks
expect(html).toContain('<main id="main" role="main">')
expect(html).toContain('class="skip-link"')
// hero h1
expect(html).toMatch(/<h1 id="hero-heading">[\s\S]*<\/h1>/)
// features h2 and aria-labelledby
expect(html).toMatch(/<h2 id="features-heading">Features<\/h2>/)
expect(html).toMatch(/<section class="features" aria-labelledby="features-heading">/)
// testimonials h2 and aria-labelledby
expect(html).toMatch(/<h2 id="testimonials-heading">Testimonials<\/h2>/)
expect(html).toMatch(/<section class="testimonials" aria-labelledby="testimonials-heading">/)
// FAQ heading levels and structure
expect(html).toMatch(/<h2 id="faq-heading">FAQ<\/h2>/)
// at least one h3 under FAQ
expect(html).toMatch(/<h3 class="faq-q">[\s\S]*<\/h3>/)
// CTA h2 & aria-labelledby
expect(html).toMatch(/<h2 id="cta-heading">CTA<\/h2>/)
expect(html).toMatch(/<section class="cta" aria-labelledby="cta-heading">/)
// focus-visible tokens (CSS)
expect(html).toContain('outline: 3px solid')
}