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
+56
View File
@@ -0,0 +1,56 @@
import { App } from '@inertiajs/react';
import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test } from 'vitest';
import ImportTariffs from '@/pages/supply/import-tariffs';
test.each([false, true])(
'tariff lookup remains a consultation while business forms respect authority (%s)',
(canWrite) => {
const page = { data: [], prev_page_url: null, next_page_url: null };
const html = renderToStaticMarkup(
<App
initialComponent={ImportTariffs}
initialPage={{
component: 'supply/import-tariffs',
url: '/requisicoes/1/classificacao-pautal',
version: null,
clearHistory: false,
encryptHistory: true,
props: {
errors: {},
requisition: { id: 1, number: 'REQ-QA' },
actorId: 2,
tenantId: 3,
legalReady: true,
canPropose: canWrite,
canConfirm: canWrite,
masterSearch: 'QA<123',
items: [
{
id: 4,
description: 'Material QA',
quantity: '1',
unit: 'un',
},
],
latest: [],
history: page,
masters: page,
stockItems: page,
},
}}
/>,
);
const forms = html.match(/<form\b[^>]*>/g) ?? [];
expect(
forms.filter((form) => form.includes('data-query-form="true"')),
).toHaveLength(1);
expect(forms.find((form) => form.includes('method="get"'))).toContain(
'data-query-form="true"',
);
expect(forms).toHaveLength(canWrite ? 2 : 1);
expect(html).toContain('QA&lt;123');
expect(html).toContain('/requisicoes/1/base-legal');
expect(html).not.toContain('data-query-form="true" data-preparation');
},
);