fix: complete InvesteMoz validation and error corrections

This commit is contained in:
2026-10-29 21:47:33 +02:00
parent 63147312e2
commit daf8623441
718 changed files with 127308 additions and 20959 deletions
+77 -15
View File
@@ -1,19 +1,81 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {createProjectDossierReport,createProjectDossierPrintHtml} from '../../resources/js/lib/project-dossier-report.ts';
import {
createProjectDossierReport,
createProjectDossierPrintHtml,
} from '../../resources/js/lib/project-dossier-report.ts';
test('native print source includes only selected applicable requirements and human stage states',async()=>{
const context={version:1,consumer_opportunity:'opportunity:309',context_revision:1,
opportunity_choices:[{opportunity:{key:'opportunity:309',title:'Segunda oportunidade Manica'}}],
path:{steps:[{code:'S10',title:'Terra',state:'not_started',applicability:'applicable'},{code:'S13',title:'Financiamento',applicability:'not_needed_for_preparation',reason:'Sem financiamento externo'}]},
requirements_assessment:{requirements:[
{opportunity_key:'opportunity:309',opportunity_title:'Segunda oportunidade Manica',step:'S10',title:'Acesso à terra e DUAT',state:'conditional',documents:['Planta do local'],basis:'Fonte documentada',source_url:'/documentos/fonte'},
{opportunity_key:'opportunity:286',step:'S10',title:'Requisito da primeira Sofala',documents:[]},
{opportunity_key:'opportunity:309',step:'S13',title:'Documento de financiamento dispensado',documents:[]},
]}};
const report=createProjectDossierReport({project_title:'QA PDF Manica',context_applicability_snapshot:JSON.stringify(context)},{selectedSections:new Set(['sources'])});
const html=await createProjectDossierPrintHtml(report,[],false);
assert.match(html,/Por iniciar/);assert.doesNotMatch(html,/not_started/);
assert.match(html,/Acesso à terra e DUAT/);assert.match(html,/Planta do local/);assert.match(html,/Fonte documentada/);
assert.doesNotMatch(html,/Requisito da primeira Sofala|Documento de financiamento dispensado/);
void test('native print source includes only selected applicable requirements and human stage states', async () => {
const context = {
version: 1,
consumer_opportunity: 'opportunity:309',
context_revision: 1,
opportunity_choices: [
{
opportunity: {
key: 'opportunity:309',
title: 'Segunda oportunidade Manica',
},
},
],
path: {
steps: [
{
code: 'S10',
title: 'Terra',
state: 'not_started',
applicability: 'applicable',
},
{
code: 'S13',
title: 'Financiamento',
applicability: 'not_needed_for_preparation',
reason: 'Sem financiamento externo',
},
],
},
requirements_assessment: {
requirements: [
{
opportunity_key: 'opportunity:309',
opportunity_title: 'Segunda oportunidade Manica',
step: 'S10',
title: 'Acesso à terra e DUAT',
state: 'conditional',
documents: ['Planta do local'],
basis: 'Fonte documentada',
source_url: '/documentos/fonte',
},
{
opportunity_key: 'opportunity:286',
step: 'S10',
title: 'Requisito da primeira Sofala',
documents: [],
},
{
opportunity_key: 'opportunity:309',
step: 'S13',
title: 'Documento de financiamento dispensado',
documents: [],
},
],
},
};
const report = createProjectDossierReport(
{
project_title: 'QA PDF Manica',
context_applicability_snapshot: JSON.stringify(context),
},
{ selectedSections: new Set(['sources']) },
);
const html = await createProjectDossierPrintHtml(report, [], false);
assert.match(html, /Por iniciar/);
assert.doesNotMatch(html, /not_started/);
assert.match(html, /Acesso à terra e DUAT/);
assert.match(html, /Planta do local/);
assert.match(html, /Fonte documentada/);
assert.doesNotMatch(
html,
/Requisito da primeira Sofala|Documento de financiamento dispensado/,
);
});