fix(demography): verify D01-D06 in isolated QA with INE traceability

This commit is contained in:
2026-11-20 20:07:16 +02:00
parent 558c11ef17
commit 3f66201cbe
17 changed files with 570 additions and 89 deletions
+113 -8
View File
@@ -24,10 +24,26 @@ function load(path, overrides = {}) {
compileFunction(code, ['require', 'module', 'exports'])(
(n) => {
if (n in overrides) return overrides[n];
const relative = n.startsWith('@/') ? n.slice(2) : n.startsWith('.') ? pathModule.posix.join(pathModule.posix.dirname(path), n) : null;
const relative = n.startsWith('@/')
? n.slice(2)
: n.startsWith('.')
? pathModule.posix.join(pathModule.posix.dirname(path), n)
: null;
if (relative) {
for (const candidate of [relative, relative + '.tsx', relative + '.ts']) {
if (fs.existsSync(new URL('../../resources/js/' + candidate, import.meta.url))) return load(candidate, overrides);
for (const candidate of [
relative,
relative + '.tsx',
relative + '.ts',
]) {
if (
fs.existsSync(
new URL(
'../../resources/js/' + candidate,
import.meta.url,
),
)
)
return load(candidate, overrides);
}
}
return require(n);
@@ -169,16 +185,23 @@ test('growth uses explicit comparable endpoints and does not fill missing interm
s.values[1].data_kind = 'observed';
assert.equal(helpers.demographicReading(s, 2026, 2028).growth, null);
});
test('technical source and full decimals remain available in closed details after a readable summary', () => {
test('public dimensions round population and hide technical references without modifying evidence', () => {
const original = base(),
before = JSON.stringify(original);
const html = renderToStaticMarkup(
React.createElement(Component, { evidence: evidence([base()]) }),
React.createElement(Component, { evidence: evidence([original]) }),
);
assert.ok(
html.indexOf('Retrato da população') <
html.indexOf('Valores originais por ano'),
html.indexOf('Valores de apresentação por ano'),
);
assert.match(html, /1000.1234567890123/);
assert.match(html, /Valores por dimensão, fonte e advertências/);
assert.doesNotMatch(
html,
/1000.1234567890123|SHA256|source.xlsx|Referência/,
);
assert.match(html, /1\s000/);
assert.match(html, /Valores por ano e dimensão/);
assert.equal(JSON.stringify(original), before);
assert.doesNotMatch(html, /<details[^>]*\bopen\b/);
assert.match(html, /um único ano/);
assert.match(html, /capacidade instalada/);
@@ -233,3 +256,85 @@ test('Barue 2026 provided evidence produces the readable proportions without cha
assert.equal(Number(r.age15to64Share.toFixed(1)), 51.3);
assert.equal(JSON.stringify(s), before);
});
test('annual comparisons format all populations and do not repeat technical explanations', () => {
const data = evidence([base()]);
data.comparisons = [2026, 2027, 2028].map((year) => ({
year,
left: 'Bilene',
right: 'Funhalouro',
left_value: '157982.9857834139',
right_value: '46656.505898723823',
difference: '111326.479884690077',
left_import: 'a',
right_import: 'b',
explanation: 'INTERNAL REPEATED EXPLANATION',
}));
const html = renderToStaticMarkup(
React.createElement(Component, { evidence: data }),
);
assert.match(html, /157\s983/);
assert.match(html, /46\s657/);
assert.match(html, /111\s326/);
assert.match(html, /<h3[^>]*>2027<\/h3>/);
assert.doesNotMatch(html, /111326\.479|INTERNAL REPEATED/);
assert.equal(
(
html.match(/Os indicadores demográficos não demonstram procura/g) ||
[]
).length,
1,
);
});
test('concurrent divergence remains visible without exposing reconciliation identifiers', () => {
const data = evidence([base()]);
data.differences = [
{
territory_id: 'INTERNAL-TERRITORY',
dimension: '2026|population|all|all|pessoas',
state: 'divergent_values',
values: [
{
import_id: 'INTERNAL-IMPORT',
value: '1000.1234567890123',
data_kind: 'projected',
},
],
},
];
const html = renderToStaticMarkup(
React.createElement(Component, { evidence: data }),
);
assert.match(html, /Há valores divergentes entre séries/);
assert.doesNotMatch(
html,
/INTERNAL-TERRITORY|INTERNAL-IMPORT|2026\|population|1000\.1234567890123/,
);
});
test('commerce preparation carries the explicit sector and territory', () => {
const Page = load('pages/investment/demography.tsx', {
'@inertiajs/react': { router: {} },
'./shared': {
Frame: ({ children }) =>
React.createElement('main', null, children),
button: '',
},
}).default;
const html = renderToStaticMarkup(
React.createElement(Page, {
evidence: evidence([base()]),
filters: { territories: ['district-one'], sector: 'commerce' },
territories: [],
sectors: { commerce: 'Comércio e serviços', tourism: 'Turismo' },
entrySector: 'comercio-e-servicos',
}),
);
assert.match(
html,
/source=territory%3Adistrict-one&amp;sector=comercio-e-servicos/,
);
assert.doesNotMatch(html, /Hotelaria e alojamento|sector=turismo/);
assert.match(html, /Não há ideias documentadas compatíveis/);
});