import { describe, it, expect, vi } from 'vitest'; import { render, screen } from '@testing-library/react'; import { AppShell } from '@/components/AppShell'; vi.mock('next/link', () => ({ default: ({ href, children, className }: { href: string; children: React.ReactNode; className?: string }) => ( {children} ), })); describe('AppShell', () => { it('renders the page title', () => { render(
content
); expect(screen.getByRole('heading', { name: 'Dashboard' })).toBeInTheDocument(); }); it('renders child content', () => { render(

Hello content

); expect(screen.getByText('Hello content')).toBeInTheDocument(); }); it('renders the BitReport brand link', () => { render(
); expect(screen.getByText('BitReport')).toBeInTheDocument(); }); it('renders nav links for Painel and Incidentes', () => { render(
); expect(screen.getByRole('link', { name: /Painel/i })).toBeInTheDocument(); expect(screen.getByRole('link', { name: /Incidentes/i })).toBeInTheDocument(); }); it('renders breadcrumb when provided', () => { render(
); expect(screen.getByRole('navigation', { name: 'breadcrumb' })).toBeInTheDocument(); expect(screen.getByText('Home')).toBeInTheDocument(); expect(screen.getByText('Current')).toBeInTheDocument(); }); it('does not render breadcrumb nav when breadcrumb is empty', () => { render(
); expect(screen.queryByRole('navigation', { name: 'breadcrumb' })).toBeNull(); }); it('does not render breadcrumb nav when breadcrumb is omitted', () => { render(
); expect(screen.queryByRole('navigation', { name: 'breadcrumb' })).toBeNull(); }); it('breadcrumb item with href renders as a link', () => { render(
); const link = screen.getByText('Home').closest('a'); expect(link).not.toBeNull(); }); it('breadcrumb item without href has aria-current="page"', () => { render(
); const item = screen.getByText('Current page').closest('li'); expect(item?.getAttribute('aria-current')).toBe('page'); }); });