fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -12,38 +12,108 @@ import {
|
||||
validateDossierAttachments,
|
||||
} from '../../resources/js/lib/project-dossier-report.ts';
|
||||
|
||||
test('report separates inapplicable documents from missing and unknown requirements without changing the saved snapshot', async () => {
|
||||
void test('report separates inapplicable documents from missing and unknown requirements without changing the saved snapshot', async () => {
|
||||
const requirements = [
|
||||
{ label: 'Título DUAT', state: 'not_applicable', reason: 'Arrendamento declarado' },
|
||||
{ label: 'Identificação', state: 'missing', reason: 'Pedido em preparação' },
|
||||
{ label: 'Capital externo', state: 'indeterminate', reason: 'Origem por determinar' },
|
||||
{
|
||||
label: 'Título DUAT',
|
||||
state: 'not_applicable',
|
||||
reason: 'Arrendamento declarado',
|
||||
},
|
||||
{
|
||||
label: 'Identificação',
|
||||
state: 'missing',
|
||||
reason: 'Pedido em preparação',
|
||||
},
|
||||
{
|
||||
label: 'Capital externo',
|
||||
state: 'indeterminate',
|
||||
reason: 'Origem por determinar',
|
||||
},
|
||||
];
|
||||
const snapshot = JSON.stringify({ version: 1, context_revision: 2, preparation: {
|
||||
enabled: true, mode: 'registration', version: 'QA', next: 'Completar identificação',
|
||||
calculation_notice: 'Cálculo separado', notice: 'Preparação', requirements,
|
||||
} });
|
||||
const snapshot = JSON.stringify({
|
||||
version: 1,
|
||||
context_revision: 2,
|
||||
preparation: {
|
||||
enabled: true,
|
||||
mode: 'registration',
|
||||
version: 'QA',
|
||||
next: 'Completar identificação',
|
||||
calculation_notice: 'Cálculo separado',
|
||||
notice: 'Preparação',
|
||||
requirements,
|
||||
},
|
||||
});
|
||||
const draft = { context_applicability_snapshot: snapshot };
|
||||
const report = createProjectDossierReport(draft, { selectedSections: new Set(['sources']) });
|
||||
const report = createProjectDossierReport(draft, {
|
||||
selectedSections: new Set(['sources']),
|
||||
});
|
||||
const section = report.sections.find((section) => section.id === 'sources');
|
||||
assert.ok(section);
|
||||
assert.equal(section.rows.some((row) => row.field === 'Título DUAT'), false);
|
||||
assert.match(section.paragraphs.join(' '), /Não exigido neste contexto: Título DUAT \(Arrendamento declarado\)/);
|
||||
assert.equal(section.rows.find((row) => row.field === 'Identificação').value, 'Documento por associar');
|
||||
assert.equal(section.rows.find((row) => row.field === 'Capital externo').value, 'Informação em falta para decidir');
|
||||
assert.equal(
|
||||
section.rows.some((row) => row.field === 'Título DUAT'),
|
||||
false,
|
||||
);
|
||||
assert.match(
|
||||
section.paragraphs.join(' '),
|
||||
/Não exigido neste contexto: Título DUAT \(Arrendamento declarado\)/,
|
||||
);
|
||||
assert.equal(
|
||||
section.rows.find((row) => row.field === 'Identificação').value,
|
||||
'Documento por associar',
|
||||
);
|
||||
assert.equal(
|
||||
section.rows.find((row) => row.field === 'Capital externo').value,
|
||||
'Informação em falta para decidir',
|
||||
);
|
||||
const print = await createProjectDossierPrintHtml(report, [], false);
|
||||
assert.match(print, /Arrendamento declarado/);
|
||||
assert.equal(draft.context_applicability_snapshot, snapshot);
|
||||
});
|
||||
|
||||
test('executive summary exposes the same financial result and period without replacing missing data by zero', () => {
|
||||
const draft = { currency:'MZN', financial_tools_snapshot:serializeFinancialToolsSnapshot({budgetPeriod:'Mensal',loan:{principal:'1200',rate:'0',months:'12',rateType:'nominal',periodMonths:'1',gracePeriods:'0',upfrontFee:'0',recurringFee:'0'},breakEven:{fixed:'100.01',price:'30',variable:'20'},funding:{total:'1000',secured:'800'},incomes:[{label:'Receita QA',amount:'1000'}],expenses:[{label:'Despesa QA',amount:'1100'}]}) };
|
||||
const report = createProjectDossierReport(draft,{selectedSections:new Set(['summary','finance'])});
|
||||
const summary=report.sections.find(s=>s.id==='summary');
|
||||
const detail=report.sections.find(s=>s.id==='finance');
|
||||
assert.equal(summary.rows.find(r=>r.field.startsWith('Saldo operacional')).value,detail.rows.find(r=>r.field==='Saldo operacional estimado').value);
|
||||
assert.match(summary.rows.find(r=>r.field.startsWith('Saldo operacional')).field,/Mensal/);
|
||||
const missing=createProjectDossierReport({}, {selectedSections:new Set(['summary'])});
|
||||
assert.equal(missing.sections[0].rows.some(r=>r.field.startsWith('Saldo operacional')),false);
|
||||
void test('executive summary exposes the same financial result and period without replacing missing data by zero', () => {
|
||||
const draft = {
|
||||
currency: 'MZN',
|
||||
financial_tools_snapshot: serializeFinancialToolsSnapshot({
|
||||
budgetPeriod: 'Mensal',
|
||||
loan: {
|
||||
principal: '1200',
|
||||
rate: '0',
|
||||
months: '12',
|
||||
rateType: 'nominal',
|
||||
periodMonths: '1',
|
||||
gracePeriods: '0',
|
||||
upfrontFee: '0',
|
||||
recurringFee: '0',
|
||||
},
|
||||
breakEven: { fixed: '100.01', price: '30', variable: '20' },
|
||||
funding: { total: '1000', secured: '800' },
|
||||
incomes: [{ label: 'Receita QA', amount: '1000' }],
|
||||
expenses: [{ label: 'Despesa QA', amount: '1100' }],
|
||||
}),
|
||||
};
|
||||
const report = createProjectDossierReport(draft, {
|
||||
selectedSections: new Set(['summary', 'finance']),
|
||||
});
|
||||
const summary = report.sections.find((s) => s.id === 'summary');
|
||||
const detail = report.sections.find((s) => s.id === 'finance');
|
||||
assert.equal(
|
||||
summary.rows.find((r) => r.field.startsWith('Saldo operacional')).value,
|
||||
detail.rows.find((r) => r.field === 'Saldo operacional estimado').value,
|
||||
);
|
||||
assert.match(
|
||||
summary.rows.find((r) => r.field.startsWith('Saldo operacional')).field,
|
||||
/Mensal/,
|
||||
);
|
||||
const missing = createProjectDossierReport(
|
||||
{},
|
||||
{ selectedSections: new Set(['summary']) },
|
||||
);
|
||||
assert.equal(
|
||||
missing.sections[0].rows.some((r) =>
|
||||
r.field.startsWith('Saldo operacional'),
|
||||
),
|
||||
false,
|
||||
);
|
||||
});
|
||||
import {
|
||||
serializeBusinessPlanSnapshot,
|
||||
@@ -163,7 +233,10 @@ void test('business plan values in the dossier equal the existing simulator fore
|
||||
);
|
||||
assert.equal(numeric(row('Caixa final projectada')), expected.endingCash);
|
||||
assert.equal(expected.fundingStatus, 'surplus');
|
||||
assert.equal(row('Reconciliação do financiamento'), 'Fontes superiores aos usos previstos');
|
||||
assert.equal(
|
||||
row('Reconciliação do financiamento'),
|
||||
'Fontes superiores aos usos previstos',
|
||||
);
|
||||
});
|
||||
|
||||
void test('an attached simulator execution keeps its exact snapshot result, explanation and version', () => {
|
||||
@@ -322,7 +395,10 @@ void test('print/PDF HTML escapes user content and explains omitted annexes', as
|
||||
assert.match(pdf, /@bottom-right\{content:counter\(page\)/);
|
||||
assert.doesNotMatch(pdf, /position:fixed|bottom:-14mm/);
|
||||
const escapedVersion = await createProjectDossierPrintHtml(
|
||||
{ ...report, version: 'Revisão "QA" </style><script>alert(2)</script>' },
|
||||
{
|
||||
...report,
|
||||
version: 'Revisão "QA" </style><script>alert(2)</script>',
|
||||
},
|
||||
[],
|
||||
false,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user