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:
27
frontend/src/components/__tests__/FiltroSelos.test.jsx
Normal file
27
frontend/src/components/__tests__/FiltroSelos.test.jsx
Normal 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([]);
|
||||
});
|
||||
});
|
||||
19
frontend/src/components/__tests__/Header.test.jsx
Normal file
19
frontend/src/components/__tests__/Header.test.jsx
Normal 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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user