Files
landing-builder/lib/exporter/focusVisibleTokens.test.ts
T

26 lines
1.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: 'Focus Tokens',
locale: 'en',
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
sections: [],
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
seo: { title: 'SEO', description: 'Desc' },
analytics: { ga4MeasurementId: '', metaPixelId: '', customHeadHtml: '' },
})
describe('CSS focus-visible tokens smoke', () => {
test('outline uses 3px solid and hex color token', () => {
const { css } = exportPage(makePage())
expect(css).toMatch(/outline:\s*3px\s*solid/i)
// check presence of our hex color used for outline (example: #2563eb)
expect(css).toMatch(/outline:\s*3px\s*solid\s*#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/)
// ensure focus-visible styles exist on common interactive elements
expect(css).toMatch(/button:focus|:focus-visible|a:focus|input:focus|textarea:focus|select:focus/)
})
})