mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-14 17:43:04 +00:00
Otimizar AVIF no Next 15.4.11 decodifica via libheif (GHSA-2xp9-vwfh-vxw4) e um hang transiente envenena a chave para sempre no Batcher do ResponseCache; o patch oficial (15.5.24) bypassa AVIF. Masters WebP mantêm a entrega e o enquadramento; guards proíbem AVIF em src/ e public/.
68 lines
2.5 KiB
TypeScript
68 lines
2.5 KiB
TypeScript
import { cleanup, render, screen } from '@testing-library/react'
|
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import { CampaignHero } from '@/components/CampaignHero'
|
|
|
|
type MockImageProps = React.ImgHTMLAttributes<HTMLImageElement> & { priority?: boolean }
|
|
|
|
vi.mock('next/image', () => ({
|
|
default: ({ alt, priority: _priority, ...props }: MockImageProps) => (
|
|
// eslint-disable-next-line @next/next/no-img-element
|
|
<img alt={alt} {...props} />
|
|
),
|
|
}))
|
|
|
|
afterEach(cleanup)
|
|
|
|
describe('CampaignHero', () => {
|
|
it('apresenta a candidatura e mantém um único CTA primário', () => {
|
|
render(<CampaignHero />)
|
|
|
|
expect(screen.getByRole('heading', { level: 1, name: 'MAIS SAÚDE MAIS FUTURO' })).toBeTruthy()
|
|
|
|
const supportLink = screen.getByRole('link', { name: /Quero apoiar/i })
|
|
expect(supportLink.getAttribute('href')).toBe('https://apoiar.me/jorgesolla')
|
|
expect(supportLink.getAttribute('data-cta')).toBe('primary')
|
|
|
|
// S9 — the secondary CTA is the shortcut to the novidades capture; the
|
|
// bandeiras stay reachable through the footer link and the success card.
|
|
const novidadesLink = screen.getByRole('link', { name: /Receba novidades da campanha/i })
|
|
expect(novidadesLink.getAttribute('href')).toBe('#novidades')
|
|
expect(novidadesLink.getAttribute('data-cta')).toBe('secondary')
|
|
})
|
|
|
|
it('não percent-encoda os caminhos das imagens', () => {
|
|
const { container } = render(<CampaignHero />)
|
|
|
|
const sources = Array.from(container.querySelectorAll('img')).map((image) =>
|
|
image.getAttribute('src'),
|
|
)
|
|
expect(sources.length).toBeGreaterThan(0)
|
|
|
|
for (const source of sources) {
|
|
expect(source).not.toContain('%')
|
|
}
|
|
})
|
|
|
|
it('serve masters WebP — AVIF fica fora do otimizador (libheif)', () => {
|
|
const { container } = render(<CampaignHero />)
|
|
|
|
const sources = Array.from(container.querySelectorAll('img')).map(
|
|
(image) => image.getAttribute('src') ?? '',
|
|
)
|
|
expect(sources.length).toBeGreaterThan(0)
|
|
|
|
for (const source of sources) {
|
|
expect(source.endsWith('.webp'), source).toBe(true)
|
|
}
|
|
})
|
|
|
|
it('expõe as provas e as fotos com nomes acessíveis', () => {
|
|
render(<CampaignHero />)
|
|
|
|
expect(screen.getByLabelText('DIAP entre os 40 melhores da Câmara')).toBeTruthy()
|
|
expect(screen.getByLabelText('Mais votado do PT-BA em 2022')).toBeTruthy()
|
|
expect(screen.getByRole('img', { name: /Jorge Solla 1313/i })).toBeTruthy()
|
|
expect(screen.getByAltText('Jorge Solla, candidato a deputado federal pela Bahia')).toBeTruthy()
|
|
})
|
|
})
|