@@ -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('<script>synthetic rule</script>');
|
||||
|
||||
Reference in New Issue
Block a user