Merge branch 'main' of https://git.tempo.co.mz/nala/Investidor-V2 into front
This commit is contained in:
@@ -84,14 +84,11 @@ test("actual institution view keeps physical address separate from product cover
|
||||
const html = renderToStaticMarkup(
|
||||
React.createElement(InstitutionView, { value: details }),
|
||||
);
|
||||
assert.match(html, /Sede: SYNTHETIC Maputo office/);
|
||||
assert.match(html, /Nacional, segundo a fonte/);
|
||||
assert.match(html, /Condições: Por confirmar/);
|
||||
assert.match(html, /Disponibilidade: Por confirmar/);
|
||||
assert.match(html, /Sede: SYNTHETIC address/);
|
||||
assert.match(html, /SYNTHETIC QA investment/);
|
||||
assert.match(html, /https:\/\/example.invalid\/contact/);
|
||||
assert.match(html, /https:\/\/example\.invalid\/source/);
|
||||
assert.match(html, /Consultar informação da entidade/);
|
||||
assert.match(html, /não é elegibilidade confirmada/);
|
||||
assert.doesNotMatch(html,/Por confirmar|não é elegibilidade|SHA-256/);
|
||||
|
||||
});
|
||||
test("adding a physical location does not fill product financing coverage", () => {
|
||||
const { InstitutionFields } = load("components/funding-institution.tsx");
|
||||
|
||||
@@ -60,16 +60,26 @@ function load(file) {
|
||||
}
|
||||
: name === './shared'
|
||||
? { windowLabels: {} }
|
||||
: name === '@/lib/portal-api' ? {portalRequest:()=>{throw Error('Read-only rendering must not send requests');}} : name === '@/components/funding-classification'
|
||||
? load('components/funding-classification.tsx')
|
||||
: name === '@/components/funding-institution'
|
||||
? load('components/funding-institution.tsx')
|
||||
: name === '@/components/funding-dossier-choice'
|
||||
? { FundingDossierChoice: () => null }
|
||||
: name ===
|
||||
'@/components/funding-criteria-assessment'
|
||||
? load('components/funding-criteria-assessment.tsx')
|
||||
: require(name),
|
||||
: name === '@/lib/portal-api'
|
||||
? {
|
||||
portalRequest: () => {
|
||||
throw Error(
|
||||
'Read-only rendering must not send requests',
|
||||
);
|
||||
},
|
||||
}
|
||||
: name === '@/components/funding-classification'
|
||||
? load('components/funding-classification.tsx')
|
||||
: name === '@/components/funding-institution'
|
||||
? load('components/funding-institution.tsx')
|
||||
: name === '@/components/funding-dossier-choice'
|
||||
? { FundingDossierChoice: () => null }
|
||||
: name ===
|
||||
'@/components/funding-criteria-assessment'
|
||||
? load(
|
||||
'components/funding-criteria-assessment.tsx',
|
||||
)
|
||||
: require(name),
|
||||
module,
|
||||
module.exports,
|
||||
);
|
||||
@@ -146,8 +156,143 @@ test('actual public cards and detail lead with description/products and keep imp
|
||||
new RegExp(raw.title.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')),
|
||||
);
|
||||
}
|
||||
const out=new URL('../../outputs/funding-public-editorial-20261111/',import.meta.url);fs.mkdirSync(out,{recursive:true});const name=p.products.length?'bank-with-products':'investment-manager';fs.writeFileSync(new URL(name+'-index.html',out),index);fs.writeFileSync(new URL(name+'-detail.html',out),detail);fs.writeFileSync(new URL('verification.json',out),JSON.stringify({publishedSourceRecords:270,descriptionsPreserved:true,productsNotFabricated:true,actualPublicComponents:true,metadataRemovedFromPresentation:true,privateEditorialFieldsUnchanged:true,activeDataWrites:0,visualBrowserReview:false},null,2));
|
||||
const out = new URL(
|
||||
'../../outputs/funding-public-editorial-20261111/',
|
||||
import.meta.url,
|
||||
);
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
const name = p.products.length
|
||||
? 'bank-with-products'
|
||||
: 'investment-manager';
|
||||
fs.writeFileSync(new URL(name + '-index.html', out), index);
|
||||
fs.writeFileSync(new URL(name + '-detail.html', out), detail);
|
||||
fs.writeFileSync(
|
||||
new URL('verification.json', out),
|
||||
JSON.stringify(
|
||||
{
|
||||
publishedSourceRecords: 270,
|
||||
descriptionsPreserved: true,
|
||||
productsNotFabricated: true,
|
||||
actualPublicComponents: true,
|
||||
metadataRemovedFromPresentation: true,
|
||||
privateEditorialFieldsUnchanged: true,
|
||||
activeDataWrites: 0,
|
||||
visualBrowserReview: false,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
assert.match(detail, /Descrição/);
|
||||
if (p.products.length) assert.match(detail, /Soluções PME/);
|
||||
}
|
||||
});
|
||||
|
||||
test('Quorus and Moza use one shared clean profile in both list and detail', () => {
|
||||
const Index = load('pages/funding/index.tsx').default,
|
||||
Show = load('pages/funding/show.tsx').default;
|
||||
const out = new URL(
|
||||
'../../outputs/funding-uniform-menu-20261111/',
|
||||
import.meta.url,
|
||||
);
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
for (const title of ['Quorus', 'Moza Banco']) {
|
||||
const raw = records.find((p) => p.title === title);
|
||||
assert.ok(raw, title);
|
||||
const p = { ...raw, windows: [], documents: [] },
|
||||
item = {
|
||||
id: 'synthetic',
|
||||
version_id: 'synthetic-version',
|
||||
version: 1,
|
||||
payload: p,
|
||||
};
|
||||
const index = renderToStaticMarkup(
|
||||
React.createElement(Index, {
|
||||
items: { data: [item], links: [] },
|
||||
filters: {},
|
||||
kinds: {},
|
||||
options: { territories: [], sectors: [] },
|
||||
management: false,
|
||||
}),
|
||||
);
|
||||
const detail = renderToStaticMarkup(
|
||||
React.createElement(Show, {
|
||||
record: item,
|
||||
authenticated: false,
|
||||
saved: null,
|
||||
}),
|
||||
);
|
||||
for (const html of [
|
||||
index.match(/<article class="card">([\s\S]*?)<\/article>/)?.[0] ??
|
||||
index,
|
||||
detail,
|
||||
]) {
|
||||
assert.doesNotMatch(
|
||||
html,
|
||||
/Por confirmar|por confirmar|correspondência confirmada|Instituição identificada|Entidade responsável|Sectores:|Cobertura|garantia de financiamento|Não encontrado|ficha|Sede ou contacto indicado|Informação institucional/,
|
||||
);
|
||||
assert.equal((html.match(/Produtos e serviços/g) || []).length, 1);
|
||||
assert.equal((html.match(/Descrição/g) || []).length, 1);
|
||||
}
|
||||
if (title === 'Quorus') {
|
||||
assert.equal(
|
||||
(detail.match(/Entidade de corretagem de seguros/g) || [])
|
||||
.length,
|
||||
1,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
detail,
|
||||
/<h3[^>]*>Contactos|<h3[^>]*>Localização/,
|
||||
);
|
||||
} else {
|
||||
assert.equal((detail.match(/21 342 000/g) || []).length, 1);
|
||||
assert.equal(
|
||||
(detail.match(/Rua dos Desportistas/g) || []).length,
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
(
|
||||
detail.match(
|
||||
/Tesouraria, investimento, construção e equipamento/g,
|
||||
) || []
|
||||
).length,
|
||||
1,
|
||||
);
|
||||
assert.doesNotMatch(detail, /500\.000|30\.000\.000|Prime|spread/);
|
||||
}
|
||||
fs.writeFileSync(
|
||||
new URL(title.replaceAll(' ', '-') + '-index.html', out),
|
||||
index,
|
||||
);
|
||||
fs.writeFileSync(
|
||||
new URL(title.replaceAll(' ', '-') + '-detail.html', out),
|
||||
detail,
|
||||
);
|
||||
}
|
||||
});
|
||||
test('contact and location deduplication preserves different branches and original records', () => {
|
||||
const moza = records.find((p) => p.title === 'Moza Banco'),
|
||||
original = JSON.stringify(moza);
|
||||
assert.equal(
|
||||
presentation
|
||||
.publicInstitutionContacts(moza.contacts)
|
||||
.filter((c) => c.kind === 'phone').length,
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
presentation.publicInstitutionLocations(moza.locations).length,
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
presentation.publicInstitutionLocations([
|
||||
...moza.locations,
|
||||
{
|
||||
...moza.locations[0],
|
||||
role: 'branch',
|
||||
address: 'Rua dos Desportistas, número 714',
|
||||
},
|
||||
]).length,
|
||||
2,
|
||||
);
|
||||
assert.equal(JSON.stringify(moza), original);
|
||||
});
|
||||
|
||||
@@ -417,7 +417,7 @@ void test('installed concours has its own primary group and preserves public and
|
||||
authenticated,
|
||||
procurement: true,
|
||||
});
|
||||
const group = groups.find((g) => g.id === 'procurement-area');
|
||||
const group = groups.find((g) => g.id === 'discovery').children.find(g=>g.id==='procurement-area');
|
||||
assert.equal(group.label, 'Concursos e anúncios');
|
||||
assert.equal(
|
||||
destinations(groups).filter((h) => h === '/concursos').length,
|
||||
@@ -427,15 +427,15 @@ void test('installed concours has its own primary group and preserves public and
|
||||
JSON.stringify(groups.find((g) => g.id === 'discovery')).includes(
|
||||
'/concursos',
|
||||
),
|
||||
false,
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
currentNavigationGroup(groups, '/concursos?q=obras'),
|
||||
'procurement-area',
|
||||
'discovery',
|
||||
);
|
||||
assert.equal(
|
||||
currentNavigationGroup(groups, '/concursos/fixture'),
|
||||
'procurement-area',
|
||||
'discovery',
|
||||
);
|
||||
assert.equal(
|
||||
destinations(group.children).includes('/concursos/acompanhar'),
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import { compileFunction } from 'node:vm';
|
||||
import ts from 'typescript';
|
||||
import React from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import * as navigation from '../../resources/js/lib/portal-navigation.ts';
|
||||
import { searchTerritoryHref } from '../../resources/js/lib/search-territory.ts';
|
||||
const require = createRequire(import.meta.url);
|
||||
let state, mobile;
|
||||
const primitive =
|
||||
(tag) =>
|
||||
({ children, asChild, className, ...props }) =>
|
||||
asChild
|
||||
? React.cloneElement(children, { className })
|
||||
: React.createElement(
|
||||
tag,
|
||||
{
|
||||
className,
|
||||
...Object.fromEntries(
|
||||
Object.entries(props).filter(
|
||||
([k]) =>
|
||||
k.startsWith('aria-') ||
|
||||
k.startsWith('data-'),
|
||||
),
|
||||
),
|
||||
},
|
||||
children,
|
||||
);
|
||||
const source = fs.readFileSync(
|
||||
new URL(
|
||||
'../../resources/js/components/portal-grouped-menu.tsx',
|
||||
import.meta.url,
|
||||
),
|
||||
'utf8',
|
||||
),
|
||||
module = { exports: {} };
|
||||
const output = ts.transpileModule(source, {
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
target: ts.ScriptTarget.ES2022,
|
||||
jsx: ts.JsxEmit.ReactJSX,
|
||||
},
|
||||
}).outputText;
|
||||
compileFunction(output, ['require', 'module', 'exports'])(
|
||||
(name) =>
|
||||
name === '@/components/portal-product-identity'
|
||||
? {}
|
||||
: name === '@inertiajs/react'
|
||||
? {
|
||||
usePage: () => state,
|
||||
Link: ({ children, href, className, ...props }) =>
|
||||
React.createElement(
|
||||
'a',
|
||||
{
|
||||
href,
|
||||
className,
|
||||
...Object.fromEntries(
|
||||
Object.entries(props).filter(
|
||||
([k]) =>
|
||||
k.startsWith('aria-') ||
|
||||
k.startsWith('data-'),
|
||||
),
|
||||
),
|
||||
},
|
||||
children,
|
||||
),
|
||||
router: {},
|
||||
}
|
||||
: name === 'lucide-react'
|
||||
? new Proxy({}, { get: () => () => null })
|
||||
: name === '@/hooks/use-mobile'
|
||||
? { useIsMobile: () => mobile }
|
||||
: name === '@/components/navigation-context'
|
||||
? { useNavigationContext: () => ({ view: null }) }
|
||||
: name === '@/components/tempo-brand'
|
||||
? { useTempoUi: () => ({ t: (x) => x, language: 'pt' }) }
|
||||
: name === '@/components/tempo-header-tools'
|
||||
? { TempoLanguageSelector: () => null }
|
||||
: name === '@/components/ui/dropdown-menu'
|
||||
? new Proxy(
|
||||
{},
|
||||
{
|
||||
get: (_, key) =>
|
||||
primitive(
|
||||
String(key).includes('Trigger')
|
||||
? 'button'
|
||||
: 'div',
|
||||
),
|
||||
},
|
||||
)
|
||||
: name === '@/lib/portal-navigation'
|
||||
? navigation
|
||||
: name === '@/lib/search-territory'
|
||||
? { searchTerritoryHref }
|
||||
: name === '@/routes'
|
||||
? { logout: () => '/logout' }
|
||||
: require(name),
|
||||
module,
|
||||
module.exports,
|
||||
);
|
||||
test('actual header has exactly the requested six primary entries on desktop and mobile for public and signed-in users', () => {
|
||||
const out = new URL(
|
||||
'../../outputs/funding-uniform-menu-20261111/',
|
||||
import.meta.url,
|
||||
);
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
for (const authenticated of [false, true])
|
||||
for (mobile of [false, true]) {
|
||||
state = {
|
||||
url: '/',
|
||||
props: {
|
||||
auth: {
|
||||
user: authenticated
|
||||
? {
|
||||
name: 'SYNTHETIC QA',
|
||||
email: 'qa@example.invalid',
|
||||
}
|
||||
: null,
|
||||
canManagePortal: false,
|
||||
},
|
||||
procurementEnabled: true,
|
||||
fundingEnabled: true,
|
||||
},
|
||||
};
|
||||
const html = renderToStaticMarkup(
|
||||
React.createElement(module.exports.PortalGroupedMenu),
|
||||
);
|
||||
const nav = html.match(
|
||||
/<nav[^>]*aria-label="Áreas do portal"[\s\S]*?<\/nav>/,
|
||||
)?.[0];
|
||||
assert.ok(nav);
|
||||
const labels = [
|
||||
...nav.matchAll(
|
||||
/<(?:a|button)[^>]*class="tempo-nav-trigger"[^>]*>([\s\S]*?)<\/(?:a|button)>/g,
|
||||
),
|
||||
].map((m) => m[1].replace(/<[^>]*>/g, '').trim());
|
||||
assert.deepEqual(labels, [
|
||||
'Início',
|
||||
'Descoberta',
|
||||
'Realização',
|
||||
'Suporte',
|
||||
'Sobre nós',
|
||||
'Mais',
|
||||
]);
|
||||
for (const href of [
|
||||
'/concursos',
|
||||
'/fundos',
|
||||
'/documentos',
|
||||
'/legislacao',
|
||||
'/sobre',
|
||||
'/contacto',
|
||||
'/acesso-gestao',
|
||||
])
|
||||
assert.ok(html.includes('href="' + href + '"'), href);
|
||||
assert.ok(html.includes('step=S08'));
|
||||
assert.equal(html.includes('/management/'), false);
|
||||
fs.writeFileSync(
|
||||
new URL(
|
||||
'header-' + authenticated + '-' + mobile + '.html',
|
||||
out,
|
||||
),
|
||||
html,
|
||||
);
|
||||
}
|
||||
fs.writeFileSync(
|
||||
new URL('verification.json', out),
|
||||
JSON.stringify(
|
||||
{
|
||||
synthetic: true,
|
||||
sharedInstitutionProfile: true,
|
||||
suppliedExamples: ['Quorus', 'Moza Banco'],
|
||||
sourceRowsPreserved: true,
|
||||
primaryEntries: [
|
||||
'Início',
|
||||
'Descoberta',
|
||||
'Realização',
|
||||
'Suporte',
|
||||
'Sobre nós',
|
||||
'Mais',
|
||||
],
|
||||
actualHeaderRendered: true,
|
||||
publicAndSignedIn: true,
|
||||
mobileAndDesktopBranches: true,
|
||||
visualBrowserReview: false,
|
||||
activeDataWrites: 0,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,119 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import { compileFunction } from 'node:vm';
|
||||
import { createRequire } from 'node:module';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import ts from 'typescript';
|
||||
const require = createRequire(import.meta.url);
|
||||
const root = new URL('../../', import.meta.url);
|
||||
const source = JSON.parse(fs.readFileSync(new URL('database/data/mining-reference-20261111.json', root)));
|
||||
// Public data follows exactly the service projection, while native QA verifies the route itself.
|
||||
const begin = source.risks.findIndex(x => x.startsWith('Riscos e pontos'));
|
||||
const end = source.risks.findIndex(x => x.startsWith('Próximos passos'));
|
||||
const data = { ...source, sector_slug:'mineracao', title:'Mineração e cadeias de valor', introduction:'Explore recursos minerais por localização.', group_label:'Grupo mineral', resource_heading:'Recursos e localização', resource_notice:'Conservar o âmbito territorial da fonte.', background:[], risks: source.risks.slice(begin + 1, end) };
|
||||
data.groups=source.minerals.map(({province_names,...group})=>({...group,location_labels:province_names}));
|
||||
data.indicators=source.indicators.map(({mineral,value,source})=>({value,source,label:mineral}));
|
||||
delete data.original_paragraphs;
|
||||
data.areas = data.areas.map(({source_fields: _sourceFields,province_names,mineral_ids, ...area}) => ({...area,location_labels:province_names,group_ids:mineral_ids}));
|
||||
function load(file, mocks) {
|
||||
const code = ts.transpileModule(fs.readFileSync(new URL(file, root), 'utf8'), {
|
||||
compilerOptions: {module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,jsx:ts.JsxEmit.ReactJSX},
|
||||
}).outputText;
|
||||
const mod = {exports:{}};
|
||||
compileFunction(code,['require','module','exports'])(key => mocks[key] ?? require(key),mod,mod.exports);
|
||||
return mod.exports.default;
|
||||
}
|
||||
function nodes(tree) {
|
||||
if (!tree || typeof tree !== 'object') return [];
|
||||
if (Array.isArray(tree)) return tree.flatMap(nodes);
|
||||
return [tree,...nodes(tree.props?.children)];
|
||||
}
|
||||
const Link = ({children, ...props}) => require('react').createElement('a',props,children);
|
||||
function mount(url = '/sectores/mineracao', content = data) {
|
||||
const state = []; let cursor = 0;
|
||||
const Component = load('resources/js/components/sector-resource-reference.tsx', {
|
||||
react:{useState(initial) {const n=cursor++; if (!(n in state)) state[n]=initial; return [state[n],value=>state[n]=value];}},
|
||||
'@inertiajs/react':{Link,usePage:()=>({url})},
|
||||
});
|
||||
return () => {cursor=0;return Component({data:content});};
|
||||
}
|
||||
test('mineral and province filters keep value-chain selection in the existing investment route',()=>{
|
||||
const render=mount(); let tree=render();
|
||||
nodes(tree).find(n=>n.props?.['aria-label']==='Localização sectorial').props.onChange({target:{value:'Cabo Delgado'}});
|
||||
tree=render(); nodes(tree).find(n=>n.props?.['aria-label']==='Grupo mineral').props.onChange({target:{value:'MINERAL-04'}});
|
||||
tree=render();
|
||||
const links=nodes(tree).filter(n=>n.type===Link);
|
||||
assert.equal(links.length,1);
|
||||
const url=new URL(links[0].props.href,'https://qa.invalid');
|
||||
assert.equal(url.pathname,'/investimentos/a-partir-do-setor/mineracao');
|
||||
assert.equal(url.searchParams.get('resource_area'),'MIN-02');
|
||||
assert.equal(url.searchParams.get('resource_location'),'Cabo Delgado');
|
||||
assert.equal(url.searchParams.get('resource_group'),'MINERAL-04');
|
||||
assert.equal(url.searchParams.get('resource_source'),source.source_sha256);
|
||||
const html=renderToStaticMarkup(tree);
|
||||
assert.match(html,/Beneficiamento/);
|
||||
if (process.env.INVESTMOZ_MINING_QA_ARTIFACTS === '1') {
|
||||
const view=JSON.parse(fs.readFileSync(new URL('outputs/mining-reference-20261111/public-view.json',root)));
|
||||
for (const key of ['source_sha256','reference_date','groups','areas','projects','indicators','sources','risks']) assert.deepEqual(view[key],data[key]);
|
||||
fs.writeFileSync(new URL('outputs/mining-reference-20261111/Cabo-Delgado-Grafite.html',root),html);
|
||||
}
|
||||
});
|
||||
test('return link filters and source uncertainty survive without invented map pins or publishing instructions',()=>{
|
||||
const render=mount('/sectores/mineracao?resource_area=MIN-06&resource_location=Maputo');
|
||||
const html=renderToStaticMarkup(render());
|
||||
assert.match(html,/Maputo — província\/cidade a precisar/);
|
||||
assert.match(html,/Minerais industriais/);
|
||||
assert.doesNotMatch(html,/Próximos passos|documento gerador|seis requisitos|latitude|longitude/);
|
||||
const clear=nodes(render()).find(n=>n.type==='button');clear.props.onClick();
|
||||
assert.ok(nodes(render()).filter(n=>n.type===Link).length>=1);
|
||||
});
|
||||
test('selected mining context reaches both new and existing dossier actions',()=>{
|
||||
let initial; const posted=[];
|
||||
const selection={sector_slug:'mineracao',area_id:'MIN-02',group_id:'MINERAL-04',location_label:'Cabo Delgado',source_sha256:source.source_sha256,title:data.areas[1].title,value_chain:data.areas[1].value_chain};
|
||||
const Component=load('resources/js/pages/investor-path/index.tsx',{
|
||||
react:{useState:fn=>[typeof fn==='function'?fn():fn,()=>{}]},
|
||||
'@/lib/operation-key':{createOperationKey:()=> 'SYNTHETIC-key'},
|
||||
'@/lib/company-comparison':{}, '@/lib/investment-guides':{},
|
||||
'@inertiajs/react':{Head:()=>null,Link,router:{post:(...args)=>posted.push(args)},useForm:data=>{initial=data;return {data,errors:{},processing:false,setData:()=>{},post:url=>posted.push([url,data])};}},
|
||||
});
|
||||
const tree=Component({contexts:[{id:'SYNTHETIC-case',version:3,title:'Synthetic dossier',updated_at:'2026-11-11'}],sectorSource:{slug:'mineracao',name:'Mineração',href:'/sectores/mineracao'},resourceSource:selection});
|
||||
assert.deepEqual(initial.sector_reference,{area_id:selection.area_id,group_id:selection.group_id,source_sha256:selection.source_sha256,location_label:selection.location_label});
|
||||
const button=nodes(tree).find(n=>n.type==='button' && n.props.onClick);
|
||||
button.props.onClick();
|
||||
assert.equal(posted[0][0],'/investimentos/SYNTHETIC-case/sectores');
|
||||
assert.deepEqual(posted[0][1].sector_reference,initial.sector_reference);
|
||||
nodes(tree).find(n=>n.type==='form').props.onSubmit({preventDefault(){}});
|
||||
assert.equal(posted[1][0],'/investimentos');
|
||||
assert.deepEqual(posted[1][1].sector_reference,initial.sector_reference);
|
||||
});
|
||||
|
||||
const energySource=JSON.parse(fs.readFileSync(new URL('database/data/energy-reference-20261111.json',root)));
|
||||
const energyData={...energySource,sector_slug:'energia-especifica',title:'Energia e cadeias de valor',introduction:'Prepare o investimento energético.',group_label:'Segmento energético',resource_heading:'Segmentos e âmbito territorial',resource_notice:'Conservar bacias,corredores e localidades.'};
|
||||
test('energy solar selection preserves Niassa, batteries and the correct sector route',()=>{
|
||||
const render=mount('/sectores/energia-especifica',energyData);let tree=render();
|
||||
nodes(tree).find(n=>n.props?.['aria-label']==='Localização sectorial').props.onChange({target:{value:'Niassa'}});
|
||||
tree=render();nodes(tree).find(n=>n.props?.['aria-label']==='Segmento energético').props.onChange({target:{value:'EN-SOLAR'}});
|
||||
tree=render();const links=nodes(tree).filter(n=>n.type===Link);assert.equal(links.length,1);
|
||||
const url=new URL(links[0].props.href,'https://qa.invalid');
|
||||
assert.equal(url.pathname,'/investimentos/a-partir-do-setor/energia-especifica');
|
||||
assert.equal(url.searchParams.get('resource_area'),'ENE-07');
|
||||
assert.equal(url.searchParams.get('resource_location'),'Niassa');
|
||||
assert.equal(url.searchParams.get('resource_group'),'EN-SOLAR');
|
||||
const html=renderToStaticMarkup(tree);
|
||||
assert.match(html,/baterias|armazenamento/);assert.match(html,/47,3 milhões EUR/);assert.match(html,/56 milhões USD/);
|
||||
assert.doesNotMatch(html,/Produção e recursos por período/);
|
||||
if(process.env.INVESTMOZ_MINING_QA_ARTIFACTS==='1'){
|
||||
const view=JSON.parse(fs.readFileSync(new URL('outputs/energy-reference-20261111/public-view.json',root)));
|
||||
for(const key of ['groups','areas','projects','sources','risks','background'])assert.deepEqual(view[key],energyData[key]);
|
||||
fs.writeFileSync(new URL('outputs/energy-reference-20261111/Niassa-Solar.html',root),html);
|
||||
}
|
||||
});
|
||||
test('energy studies without a named location stay selectable without assigning national coverage',()=>{
|
||||
const tree=mount('/sectores/energia-especifica?resource_area=ENE-09',energyData)();
|
||||
const links=nodes(tree).filter(n=>n.type===Link);assert.equal(links.length,1);
|
||||
const url=new URL(links[0].props.href,'https://qa.invalid');
|
||||
assert.equal(url.searchParams.get('resource_location'),null);
|
||||
assert.equal(url.searchParams.get('resource_area'),'ENE-09');
|
||||
const html=renderToStaticMarkup(tree);assert.match(html,/Sem implantação concreta/);assert.doesNotMatch(html,/latitude|longitude/);
|
||||
});
|
||||
Reference in New Issue
Block a user