Merge branch 'main' into task/qlfw-5
Some checks failed
peppa/lint lint: success за 1с
peppa/typecheck typecheck: success за 3с
peppa/test test: success за 1с
peppa/build build: success за 44с
ci / checks (pull_request) Successful in 1m37s
deploy / deploy (pull_request) Failing after 1m46s

This commit is contained in:
peppa-bot 2026-11-17 18:30:15 +05:00
commit 8aa00a3407

View File

@ -0,0 +1,32 @@
import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
// QLFW-24: первый экран контрастный (заголовок, подзаголовок, кнопка «Направления»).
const css = readFileSync('src/app/(site)/globals.css', 'utf8')
const page = readFileSync('src/app/(site)/[locale]/page.tsx', 'utf8')
const color = (name: string) => css.match(new RegExp(`--color-${name}:\\s*(#[0-9a-f]{6})`, 'i'))![1]
const lum = (hex: string) => {
const c = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255)
.map((v) => (v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4))
return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2]
}
const ratio = (a: string, b: string) => {
const [x, y] = [lum(a), lum(b)].sort((p, q) => q - p)
return (x + 0.05) / (y + 0.05)
}
describe('QLFW-24: контраст первого экрана', () => {
it('заголовок и подзаголовок тёмные на светлом фоне (не ниже 7:1)', () => {
expect(ratio(color('graphite'), color('paper'))).toBeGreaterThanOrEqual(7)
expect(page).toMatch(/<h1[^>]*text-graphite/)
expect(page).toMatch(/<p className="reveal reveal-2[^"]*text-graphite/)
})
it('кнопка «Направления» бордовая с белым текстом (не ниже 4.5:1)', () => {
expect(ratio(color('burgundy'), '#ffffff')).toBeGreaterThanOrEqual(4.5)
expect(page).toMatch(/href="#directions"[^>]*bg-burgundy[^>]*text-white/)
})
it('анимация не меняет прозрачность текста', () => {
expect(css).not.toMatch(/@keyframes rise[^}]*opacity/)
})
})