feat(tests): adicionar testes de regras PDF e componentes frontend

Backend:
- test_pdf_rules.py: 108 testes para regras de pontuação do PDF
- test_pdf_selos.py: validação de selos disponíveis

Frontend:
- Configuração Vitest para testes de componentes React
- FiltroSelos.test.jsx: testes do componente de filtro
- Header.test.jsx: testes do componente de cabeçalho
This commit is contained in:
Frederico Castro
2025-12-29 09:16:19 -03:00
parent d48fff2236
commit 7d02289605
7 changed files with 344 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
import { render, screen, fireEvent } from '@testing-library/react';
import FiltroSelos from '../FiltroSelos';
describe('FiltroSelos', () => {
it('applies selected seals', () => {
const handleChange = vi.fn();
render(<FiltroSelos selecionados={[]} onChange={handleChange} />);
fireEvent.click(screen.getByRole('button', { name: /Filtrar por selos/i }));
const checkbox = screen.getByLabelText(/Coord\./i);
fireEvent.click(checkbox);
fireEvent.click(screen.getByRole('button', { name: /Aplicar/i }));
expect(handleChange).toHaveBeenCalledWith(['CA']);
});
it('clears filters from the trigger when active', () => {
const handleChange = vi.fn();
render(<FiltroSelos selecionados={['CA']} onChange={handleChange} />);
fireEvent.click(screen.getByTitle('Limpar filtros'));
expect(handleChange).toHaveBeenCalledWith([]);
});
});

View File

@@ -0,0 +1,19 @@
import { render, screen, fireEvent } from '@testing-library/react';
import Header from '../Header';
describe('Header', () => {
it('renders the title and total count', () => {
render(<Header total={1000} />);
expect(screen.getByText('Ranking de Consultores CAPES')).toBeInTheDocument();
expect(screen.getByText(/Total:\s+1\.000 consultores/)).toBeInTheDocument();
});
it('opens the criteria modal when a block is clicked', () => {
render(<Header total={0} />);
fireEvent.click(screen.getByText('A - Coordenacao CAPES'));
expect(screen.getByText(/Coordena/)).toBeInTheDocument();
});
});