Expose calendar duration and overlap before comparing territorial observations
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-13 22:54:49 +02:00
parent 39bddad091
commit 2bad72c042
4 changed files with 78 additions and 2 deletions
@@ -360,3 +360,31 @@ test('comparison delta: progressive selection stays inside the received filters
const single = render({ ...context, records: [row] });
assert.ok(!single.includes('Comparar duas observações'));
});
test('temporal delta: unequal duration and overlapping boundaries require review without annualising values', () => {
const first = {...row, description:'Synthetic source', measure_kind:'observed', period_start:'2024-01-01', period_end:'2024-12-31', value:'123.4500'};
const second = {...first, id:'second', period_start:'2025-01-01', period_end:'2025-12-31', value:'0'};
const before = JSON.stringify([first,second]);
assert.ok(compareObservations(first,second).issues.some(x=>x.includes('Duração dos períodos diferente')));
const boundary = {...second, period_start:'2024-12-31'};
assert.ok(compareObservations(first,boundary).issues.some(x=>x.includes('sobrepõem-se')));
const identical = {...first,id:'same-period'};
assert.equal(compareObservations(first,identical).state,'metadata_aligned');
const html = renderToStaticMarkup(React.createElement(Comparison,{first,second}));
assert.match(html,/Duração do período/);assert.match(html,/>366</);assert.match(html,/>365</);
assert.match(html,/123\.4500/);assert.match(html,/>0</);
assert.equal(JSON.stringify([first,second]),before);
});
test('temporal delta: missing invalid and inverted dates never become a duration', () => {
const first = {...row, description:'Synthetic', measure_kind:'observed'};
for (const change of [{period_start:null},{period_start:'2025'},{period_start:'2025-02-30'},{period_start:'2026-01-01'}]) {
const second = {...first,id:'invalid',...change};
const result = compareObservations(first,second);
assert.ok(result.issues.some(x=>x.includes('período incompleto ou inválido')));
assert.ok(!result.issues.some(x=>x.includes('Duração dos períodos diferente')));
const html = renderToStaticMarkup(React.createElement(Comparison,{first,second}));
assert.match(html,/Por confirmar/);assert.ok(!html.includes('NaN'));
}
});