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

This commit is contained in:
2026-11-28 15:45:52 +02:00
parent eb32c74c56
commit 060c119ba1
92 changed files with 4936 additions and 43 deletions
+37 -1
View File
@@ -3,7 +3,12 @@ import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test } from 'vitest';
import Legal from '../../resources/js/pages/supply/import-legal';
function renderLegal(canManage: boolean, withRule = true, withCharges = false) {
function renderLegal(
canManage: boolean,
withRule = true,
withCharges = false,
withReference = false,
) {
const data = {
title: '<script>synthetic rule</script>',
official_reference: 'Synthetic official edition',
@@ -58,6 +63,25 @@ function renderLegal(canManage: boolean, withRule = true, withCharges = false) {
encryptHistory: true,
props: {
errors: {},
referenceDrafts: withReference
? [
{
source_id: 8,
code: '3506.91.20',
description:
'Silicone para selagem de painéis solares',
rate_percent: '20',
title: 'Taxa geral documental',
official_reference: 'Lei 8/2025',
official_url: null,
citation: 'Página 2180-(4)',
valid_from: '2026-01-01',
obligations:
'Conferir o exemplar e o regime aplicável',
charges: [],
},
]
: [],
requisition: { id: 1, number: 'QA' },
rules: page,
history: page,
@@ -78,6 +102,18 @@ function renderLegal(canManage: boolean, withRule = true, withCharges = false) {
);
}
test('official reference preparation is explicit and only available to the customs preparer', () => {
const allowed = renderLegal(true, false, false, true);
expect(allowed).toContain('Preparar a partir do exemplar oficial');
expect(allowed).toContain('3506.91.20');
expect(allowed).toContain('taxa geral 20%');
expect(allowed).toContain('não é uma pauta consolidada');
expect(allowed).toContain('não substituir');
const reader = renderLegal(false, false, false, true);
expect(reader).not.toContain('Preparar a partir do exemplar oficial');
expect(reader).not.toContain('Silicone para selagem');
});
test('legal consultation escapes titles preserves periods and offers verified-source downloads without management controls', () => {
const html = renderLegal(false);
expect(html).toContain('&lt;script&gt;synthetic rule&lt;/script&gt;');