feat: filter public map indicators by indicator and reference period
This commit is contained in:
@@ -28,6 +28,7 @@ compileFunction(compiled, ['require', 'module', 'exports'])(
|
||||
module.exports,
|
||||
);
|
||||
const Component = module.exports.default;
|
||||
const filterIndicators = module.exports.filterMapIndicators;
|
||||
const row = {
|
||||
id: '1',
|
||||
zone_id: 'park-a',
|
||||
@@ -146,3 +147,75 @@ test('unknown values, disputes, missing metadata, incomplete coverage and exclud
|
||||
/Não foi possível consultar os indicadores/,
|
||||
);
|
||||
});
|
||||
|
||||
test('indicator and inclusive temporal overlap filters preserve exact source values without mutation', () => {
|
||||
const records = [
|
||||
row,
|
||||
{
|
||||
...row,
|
||||
id: 'prior',
|
||||
period_start: '2024-01-01',
|
||||
period_end: '2024-12-31',
|
||||
},
|
||||
{
|
||||
...row,
|
||||
id: 'production',
|
||||
indicator: 'production',
|
||||
value: '1234567890123.456789',
|
||||
},
|
||||
];
|
||||
const before = JSON.stringify(records);
|
||||
assert.deepEqual(
|
||||
filterIndicators(records, 'employment', '2025-12-31', '2026-01-01').map(
|
||||
(item) => item.id,
|
||||
),
|
||||
['1'],
|
||||
);
|
||||
assert.deepEqual(
|
||||
filterIndicators(records, 'all', '', '2024-01-01').map(
|
||||
(item) => item.id,
|
||||
),
|
||||
['prior'],
|
||||
);
|
||||
assert.equal(
|
||||
filterIndicators(records, 'production', '2025-01-01', '').at(0).value,
|
||||
'1234567890123.456789',
|
||||
);
|
||||
assert.equal(
|
||||
filterIndicators(records, 'all', '2026-01-01', '2025-01-01').length,
|
||||
0,
|
||||
);
|
||||
assert.equal(JSON.stringify(records), before);
|
||||
});
|
||||
|
||||
test('missing, partial, invalid and inverted source periods are visible unfiltered but never inferred from source date', () => {
|
||||
const records = [
|
||||
{ ...row, id: 'missing', period_start: null },
|
||||
{ ...row, id: 'partial', period_start: '2025' },
|
||||
{ ...row, id: 'invalid', period_start: '2025-02-30' },
|
||||
{ ...row, id: 'inverted', period_start: '2026-01-01' },
|
||||
{ ...row, id: 'unknown', value: null, knowledge: 'unknown' },
|
||||
{ ...row, id: 'disputed', knowledge: 'disputed' },
|
||||
];
|
||||
assert.equal(filterIndicators(records, 'all', '', '').length, 6);
|
||||
assert.deepEqual(
|
||||
filterIndicators(records, 'all', '2025-01-01', '2025-12-31').map(
|
||||
(item) => item.id,
|
||||
),
|
||||
['unknown', 'disputed'],
|
||||
);
|
||||
assert.equal(
|
||||
filterIndicators([row], 'all', '2026-01-15', '2026-01-15').length,
|
||||
0,
|
||||
);
|
||||
});
|
||||
|
||||
test('quantitative filters are labelled, scoped and explain source date and coverage limits', () => {
|
||||
const html = render(context);
|
||||
assert.match(html, /Filtrar observações do contexto territorial/);
|
||||
assert.match(html, /Período de referência — desde/);
|
||||
assert.match(html, /Período de referência — até/);
|
||||
assert.match(html, /A data da fonte não substitui o período de referência/);
|
||||
assert.match(html, /não alteram oportunidades ou limites de cobertura/);
|
||||
assert.match(html, /Limpar filtros dos indicadores/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user