import test from 'node:test'; import assert from 'node:assert/strict'; import { createProjectDossierReport, createProjectDossierPrintHtml, } from '../../resources/js/lib/project-dossier-report.ts'; 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/, ); });