I tried userEvent of testinglibrary and fireEvent but i dont have any success...
it('Deve renderizar o processo lista', async () => {
const { getByText, getByRole } = render(
<HelmetProvider>
<MemoryRouter>
<ProcessoGerenciamento />
</MemoryRouter>
</HelmetProvider>,
);
act(() => {
const botaofiltrar = getByRole('button', { name: /filtrar/i });
fireEvent.input(getByRole('textbox', { name: /número do processo/i }), { target: { value: '1' } });
fireEvent.click(botaofiltrar);
});
await waitFor(() => {
const processo = getByText('Processos');
expect(processo).toBeInTheDocument();
});});
and the class related of have 3 components
<div>
<ProcessoFiltro
retornoFiltro={filtrarProcesso}
tiposProcesso={listaTiposProcesso}
situacoes={listaSituacao}
loadingButton={carregando}
resetFiltro={resetFiltroFormData}
/>
{Object.keys(filtroFormData).length > 0 && <div className="br-divider"></div>}
{Object.keys(filtroFormData).length > 0 && (
<ProcessoLista
filtro={filtroFormData}
loading={carregando}
sort={filtroOrdenacao}
cabecalhoTabela={camposTabela}
/>
)}
{Object.keys(filtroFormData).length > 0 && (
<Paginacao retornoPaginacao={filtroPaginacao} metaDataPaginacao={metadata} />
)}
</div>
i click a button in the first component and i have a server request, then i recieve a object and setFiltroFormData but in the test doesnt work
SORRY MY BAD ENGLISH.