import { App } from '@inertiajs/react';
import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test } from 'vitest';
import ImportPartySelection, {
type ImportPartyWorkspace,
} from '@/components/import-party-selection';
function renderParties(canSelect: boolean) {
const selected = {
id: 1,
version: 2,
data: { role: 'broker', supplier_id: 3, instruction_document_id: 4 },
snapshot: {
supplier: {
name: '',
nuit: '123456789',
version: 1,
},
instructions: { data: { reference: 'INSTRUCTIONS-QA' } },
},
reason: 'Explicit synthetic selection.',
issues: [
'As instruções escritas têm uma versão diferente; confira a selecção.',
],
};
const workspace: ImportPartyWorkspace = {
roles: { broker: 'Despachante aduaneiro', forwarder: 'Transitário' },
canSelect,
search: '',
current: [selected],
history: { data: [selected], prev_page_url: null, next_page_url: null },
suppliers: {
data: [{ id: 3, name: 'Broker QA', nuit: '123456789', version: 1 }],
prev_page_url: null,
next_page_url: null,
},
instructions: {
data: [
{
id: 4,
version: 1,
data: {
reference: 'INSTRUCTIONS-QA',
issuer_reference: 'QA buyer',
},
},
],
prev_page_url: null,
next_page_url: null,
},
};
return renderToStaticMarkup(
,
);
}
test('party reader sees preserved selection instructions and pending issues without selection commands', () => {
const html = renderParties(false);
expect(html).toContain('INSTRUCTIONS-QA');
expect(html).toContain('uma versão diferente');
expect(html).toContain('/compras/importacoes/5/documentos/4');
expect(html).not.toContain('Confirmar entidade e instruções');
expect(html).toContain('<script>Broker QA</script>');
expect(html).not.toContain('