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

This commit is contained in:
2026-11-28 07:11:35 +02:00
parent d58b75c87a
commit eb32c74c56
202 changed files with 17463 additions and 1526 deletions
@@ -0,0 +1,104 @@
import { App } from '@inertiajs/react';
import type { ComponentProps } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test } from 'vitest';
import Accounts from '@/pages/requisitions/accounts';
import Summary from '@/components/requisition-account-summary';
const account = {
id: 7,
code: 'QA-7',
label: 'Conta & material',
currency: 'MZN',
source_hash: 'a'.repeat(64),
};
const props: ComponentProps<typeof Accounts> = {
requisition: { id: 1, number: 'REQ-QA', status: 'draft' },
actorId: 1,
tenantId: 1,
canWrite: true,
search: '',
items: [
{
id: 2,
description: 'Material sintético',
subtotal_minor: '10000',
total_minor: '10000',
basis_hash: 'b'.repeat(64),
},
],
accounts: {
data: [account],
prev_page_url: null,
next_page_url: '/requisicoes/1/contas?accounts_page=2',
},
current: [],
history: { data: [], prev_page_url: null, next_page_url: null },
};
function render(value: typeof props) {
function Screen() {
return <Accounts {...value} />;
}
return renderToStaticMarkup(
<App
initialComponent={Screen}
initialPage={{
component: 'requisitions/accounts',
url: '/requisicoes/1/contas',
version: 'qa',
clearHistory: false,
encryptHistory: true,
props: { errors: {} },
}}
/>,
);
}
test('account assignment begins with an explicit line and preserves catalogue pagination', () => {
const html = render(props);
expect(html).toContain('Seleccione a linha');
expect(html).toContain('Adicionar conta à linha');
expect(html).toContain('/requisicoes/1/contas?accounts_page=2');
expect(html).toContain('Conta &amp; material');
expect(html).not.toContain('Reutilizar parcelas actuais');
expect(html).not.toContain('Base sem IVA (MZN)');
});
test('read-only history keeps exact original money and does not expose an editing form', () => {
const row = {
id: 9,
version: 2,
reason: 'Conferência sintética',
data: {
requisition_item_id: 2,
allocations: [
{
account,
subtotal_minor: '9007199254740993',
total_minor: '9007199254740993',
},
],
},
};
const html = render({
...props,
canWrite: false,
accounts: null,
current: [row],
history: { data: [row], prev_page_url: null, next_page_url: null },
});
expect(html).toContain('90.071.992.547.409,93 MZN');
expect(html).toContain('Versão 2');
expect(html).not.toContain('Guardar versão');
expect(html).not.toContain('Adicionar conta à linha');
const summary = renderToStaticMarkup(
<Summary
records={{
'2': {
...row,
snapshot: { line: { description: 'Necessidade original' } },
},
}}
/>,
);
expect(summary).toContain('90.071.992.547.409,93 MZN');
expect(summary).toContain('não representam valores contabilizados');
});