Preserve selected portfolio context through investment preparation
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { inheritCompatibleFields } from '../../resources/js/lib/context-inheritance.ts';
|
||||
import { buildProjectDossierRows, exportProjectDossierCsv } from '../../resources/js/lib/project-dossier.ts';
|
||||
import { createProjectDossierReport, createProjectDossierPrintHtml } from '../../resources/js/lib/project-dossier-report.ts';
|
||||
|
||||
test('selected associations stay attached to each opportunity in reports and do not replace deliberate simulator answers', async()=>{
|
||||
const choices=[
|
||||
{opportunity:{key:'opportunity:1',title:'Oportunidade QA A'},territory:{title:'Sofala / Dondo'},portfolio_origins:[{title:'Âncora QA',id:'p',sha256:'internal-hash'}]},
|
||||
{opportunity:{key:'opportunity:2',title:'Oportunidade QA B'},territory:{title:'Manica'},portfolio_origins:[{title:'Cluster QA',id:'c'}]},
|
||||
];
|
||||
const snapshot=JSON.stringify({version:1,context_revision:3,opportunity_choices:choices,land_preparation:{need:'unknown'}});
|
||||
const values={project_title:'Título deliberado',province_id:'local-edit',context_applicability_snapshot:'old'};
|
||||
const result=inheritCompatibleFields('dossier:A:simulator',values,{project_title:'Origem',province_id:'source',context_applicability_snapshot:snapshot},null);
|
||||
assert.equal(result.patch.project_title,undefined);assert.equal(result.patch.province_id,undefined);
|
||||
assert.equal(result.patch.context_applicability_snapshot,snapshot);
|
||||
const draft={...values,...result.patch};const before=JSON.stringify(draft);
|
||||
const rows=buildProjectDossierRows(draft);
|
||||
assert.ok(rows.some(row=>row[1]==='Associação escolhida na carteira'&&row[2]==='Âncora QA'&&row[3].startsWith('Oportunidade QA A;')));
|
||||
assert.ok(rows.some(row=>row[1]==='Associação escolhida na carteira'&&row[2]==='Cluster QA'&&row[3].startsWith('Oportunidade QA B;')));
|
||||
assert.match(exportProjectDossierCsv(draft),/Sofala \/ Dondo/);
|
||||
const html=await createProjectDossierPrintHtml(createProjectDossierReport(draft,{selectedSections:new Set(['location'])}),[],false);
|
||||
assert.match(html,/Âncora QA/);assert.match(html,/Cluster QA/);assert.match(html,/Manica/);
|
||||
assert.doesNotMatch(html,/internal-hash/);assert.equal(JSON.stringify(draft),before);
|
||||
});
|
||||
@@ -1,6 +1,15 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { searchTerritoryHref } from '../../resources/js/lib/search-territory.ts';
|
||||
import { searchTerritoryHref, investmentPreparationHref } from '../../resources/js/lib/search-territory.ts';
|
||||
|
||||
test('preparation carries only the validated portfolio origin and territorial choices, including nested catalogue return context',()=>{
|
||||
const href=investmentPreparationHref(53,'/oportunidades/florestas?province_id=p&district_id=d&q=private-note&context=other','origin');
|
||||
const query=new URL(href,'https://portal.invalid').searchParams;
|
||||
assert.equal(query.get('source'),'opportunity:53');assert.equal(query.get('from_dossier'),'origin');
|
||||
assert.equal(query.get('province_id'),'p');assert.equal(query.get('district_id'),'d');
|
||||
assert.equal(query.has('q'),false);assert.equal(query.has('context'),false);
|
||||
assert.equal(new URL(investmentPreparationHref(53,'/oportunidades/florestas?catalogue_query='+encodeURIComponent('province_id=p&district_id=d')),'https://portal.invalid').searchParams.get('district_id'),'d');
|
||||
});
|
||||
|
||||
test('portfolio to catalogue to related screen retains only territorial search filters', () => {
|
||||
const start = '/carteira?province_id=inh&district_id=vil&q=airport&kind=project';
|
||||
|
||||
Reference in New Issue
Block a user