50 lines
1.9 KiB
JavaScript
50 lines
1.9 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { createProjectDossierReport } from '../../resources/js/lib/project-dossier-report.ts';
|
|
|
|
void test('report retains the frozen preparation and an inactive historical document without claiming approval or a tax benefit', () => {
|
|
const preparation = {
|
|
enabled: true,
|
|
version: 'private-investment-preparation-2026-v1',
|
|
mode: 'registration',
|
|
next: 'Preparar documentos do pedido de mero registo',
|
|
calculation_notice: 'O regime procedimental não altera a taxa de IVA.',
|
|
notice: 'Sem submissão à Administração.',
|
|
requirements: [
|
|
{
|
|
label: 'Estudo de viabilidade',
|
|
state: 'not_applicable',
|
|
document_id: 'synthetic-old-document',
|
|
source: {
|
|
reference: 'R14',
|
|
url: 'https://example.test/official-source',
|
|
},
|
|
reason: 'Apenas para autorização.',
|
|
},
|
|
],
|
|
};
|
|
const snapshot = JSON.stringify({
|
|
version: 1,
|
|
context_revision: 3,
|
|
preparation,
|
|
});
|
|
const report = createProjectDossierReport(
|
|
{ context_applicability_snapshot: snapshot },
|
|
{ selectedSections: new Set(['sources']) },
|
|
);
|
|
const sources = report.sections.find((s) => s.id === 'sources');
|
|
assert.equal(
|
|
sources.rows.find(
|
|
(r) => r.field === 'Preparação do investimento privado',
|
|
).value,
|
|
'Pedido de mero registo',
|
|
);
|
|
assert.match(
|
|
sources.rows.find((r) => r.field === 'Estudo de viabilidade').value,
|
|
/Não aplicável; histórico preservado/,
|
|
);
|
|
assert.ok(sources.paragraphs.includes(preparation.calculation_notice));
|
|
preparation.mode = 'authorization';
|
|
assert.equal(JSON.parse(snapshot).preparation.mode, 'registration');
|
|
});
|