teqo-backup/tests/unit/campaignListPageHeader.unit.spec.ts
Cursor Agent 586ac7d218
B118 — hide list page title, subtitle and scope chip on mobile
Extract CampaignListPageHeader with sr-only/md:not-sr-only h1 and hidden
subtitle/scope below md. Apply to all 8 list index routes. Unit + e2e pins.

Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
2026-08-02 00:54:55 +00:00

27 lines
1.1 KiB
TypeScript

import { createElement } from 'react'
import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it } from 'vitest'
import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader'
import { CampaignScopeBadge } from '@/components/campaign/shared/CampaignScopeBadge'
describe('CampaignListPageHeader (B118)', () => {
it('keeps h1 in the DOM with sr-only on mobile and hides subtitle and scope chip below md', () => {
const html = renderToStaticMarkup(
createElement(CampaignListPageHeader, {
title: 'Municípios',
description: 'Os 435 municípios da campanha.',
scope: createElement(CampaignScopeBadge, null, '435 municípios'),
}),
)
expect(html).toContain('<h1')
expect(html).toContain('sr-only')
expect(html).toContain('md:not-sr-only')
expect(html).toContain('hidden')
expect(html).toContain('md:block')
expect(html).toContain('md:contents')
expect(html).toContain('Municípios')
expect(html).toContain('Os 435 municípios da campanha.')
})
})