commit compras1 2911
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-29 05:28:30 +02:00
parent 1ddabbbdcc
commit 448948a487
137 changed files with 9481 additions and 1926 deletions
@@ -0,0 +1,86 @@
import { App } from '@inertiajs/react';
import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test } from 'vitest';
import Dashboard from '@/pages/dashboard';
import Requisitions from '@/pages/requisitions/index';
test('dashboard distinguishes visible pending requests from personal decisions and links to the corresponding lists', () => {
const Screen = () => (
<Dashboard
company={null}
stats={{
total: 7,
pending: 3,
approved: 2,
approvedMinor: 10000,
awaitingMe: 0,
}}
recent={[]}
approvals={[]}
/>
);
const html = renderToStaticMarkup(
<App
initialComponent={Screen}
initialPage={{
component: 'dashboard',
url: '/dashboard',
version: null,
clearHistory: false,
encryptHistory: true,
props: { errors: {}, publicNavigation: true },
}}
/>,
);
expect(html).toContain('href="/requisicoes?status=pending"');
expect(html.match(/href="\/requisicoes\?status=approved"/g)).toHaveLength(
2,
);
expect(html).toContain('href="/requisicoes?view=approvals"');
expect(html).toContain('Requisições que aguardam a sua decisão: 0');
expect(html).not.toContain('À espera da sua aprovação');
expect(html).not.toContain('Nova requisição');
});
test.each([
[
{ view: 'approvals' },
'Não há requisições com uma etapa disponível para a sua decisão',
],
[
{ view: 'approvals', status: 'pending' },
'Nenhum pedido corresponde aos filtros neste conjunto',
],
])(
'empty requisition lists explain the selected scope (%j)',
(filters, message) => {
const Screen = () => (
<Requisitions
requisitions={{
data: [],
total: 0,
current_page: 1,
last_page: 1,
prev_page_url: null,
next_page_url: null,
}}
filters={filters}
/>
);
const html = renderToStaticMarkup(
<App
initialComponent={Screen}
initialPage={{
component: 'requisitions/index',
url: '/requisicoes',
version: null,
clearHistory: false,
encryptHistory: true,
props: { errors: {} },
}}
/>,
);
expect(html).toContain(message);
expect(html).not.toContain('aparecem aqui depois de criados');
},
);