@@ -1,7 +1,8 @@
|
||||
import { App } from '@inertiajs/react';
|
||||
import { App, router } from '@inertiajs/react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { expect, test } from 'vitest';
|
||||
import { afterEach, expect, test, vi } from 'vitest';
|
||||
import Legal from '../../resources/js/pages/supply/import-legal';
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
function renderLegal(
|
||||
canManage: boolean,
|
||||
@@ -108,12 +109,49 @@ test('official reference preparation is explicit and only available to the custo
|
||||
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');
|
||||
expect(allowed).toContain('Ainda não existem regras neste âmbito.');
|
||||
expect(allowed).not.toContain('Ainda não existem fontes neste âmbito.');
|
||||
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('remembered legal preparation is preserved and disables replacement by official reference drafts', () => {
|
||||
vi.spyOn(router, 'restore').mockImplementation((key) =>
|
||||
key === 'legal-rule:1:1:1:data'
|
||||
? {
|
||||
operation_key: 'c1111111-1111-4111-8111-111111111111',
|
||||
record_key: null,
|
||||
version: 0,
|
||||
action: 'save',
|
||||
title: 'PRESERVED-DELIBERATE-TITLE',
|
||||
official_reference: '',
|
||||
official_url: '',
|
||||
citation: '',
|
||||
valid_from: '',
|
||||
valid_until: '',
|
||||
match_code: '',
|
||||
suggested_code: '',
|
||||
origin_country: '',
|
||||
sector: '',
|
||||
obligations: '',
|
||||
document_types: [],
|
||||
reason: '',
|
||||
file: null,
|
||||
source_id: '',
|
||||
charges: [],
|
||||
}
|
||||
: undefined,
|
||||
);
|
||||
const post = vi.spyOn(router, 'post');
|
||||
const html = renderLegal(true, false, false, true);
|
||||
expect(html).toContain('PRESERVED-DELIBERATE-TITLE');
|
||||
expect(html).toContain('O preenchimento existente será conservado');
|
||||
expect(html).toContain('Limpar preparação');
|
||||
expect(html).toMatch(/<select[^>]*disabled[^>]*>/);
|
||||
expect(post).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
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