feat: show immediate administrative subdivisions and map coverage gaps
This commit is contained in:
@@ -81,7 +81,9 @@ await test('catalogue composes one map with the same opportunity data and separa
|
||||
'./interactive-investment-map': { default: Map },
|
||||
'./territory-geometry-preview': { TerritoryGeometryDetails: Info },
|
||||
'./use-territory-geometry': {
|
||||
useTerritoryGeometry: (id) => {
|
||||
useTerritoryGeometry: (id, endpoint, children) => {
|
||||
assert.equal(endpoint, undefined);
|
||||
assert.equal(children, true);
|
||||
requests.push(id);
|
||||
return { context: { areas: [boundary] }, error: '' };
|
||||
},
|
||||
@@ -125,9 +127,9 @@ await test('territorial request changes discard old boundaries immediately and i
|
||||
const { useTerritoryGeometry } = load('use-territory-geometry.ts', {
|
||||
react: hooks,
|
||||
});
|
||||
const render = (id) => {
|
||||
const render = (id, children = false) => {
|
||||
cursor = 0;
|
||||
return useTerritoryGeometry(id);
|
||||
return useTerritoryGeometry(id, undefined, children);
|
||||
};
|
||||
render('a');
|
||||
const cleanup = effect();
|
||||
@@ -150,6 +152,22 @@ await test('territorial request changes discard old boundaries immediately and i
|
||||
assert.equal(render(undefined).context, null);
|
||||
assert.equal(pending[0].options.signal.aborted, true);
|
||||
assert.equal(pending.length, 2);
|
||||
assert.equal(render('b', true).context, null);
|
||||
effect();
|
||||
assert.match(pending[2].url, /include_children=1/);
|
||||
pending[2].resolve({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
areas: [boundary],
|
||||
child_coverage: { registered_count: 2 },
|
||||
}),
|
||||
});
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
assert.equal(
|
||||
render('b', true).context.child_coverage.registered_count,
|
||||
2,
|
||||
);
|
||||
assert.equal(render('b', false).context, null);
|
||||
} finally {
|
||||
globalThis.fetch = previousFetch;
|
||||
}
|
||||
@@ -452,3 +470,37 @@ await test('partnership catalogue has one contextual map and keeps the applied t
|
||||
assert.equal(maps()[0].props.territoryId, 'a');
|
||||
assert.equal(maps()[0].props.points, props.mapPoints);
|
||||
});
|
||||
|
||||
await test('administrative coverage identifies lower-level subdivisions and distinguishes absent geometry from absent territory', () => {
|
||||
const Details = load('territory-geometry-preview.tsx', {
|
||||
'./interactive-investment-map': { default: () => null },
|
||||
'./use-territory-geometry': {},
|
||||
}).TerritoryGeometryDetails;
|
||||
const html = renderToStaticMarkup(
|
||||
React.createElement(Details, {
|
||||
error: '',
|
||||
context: {
|
||||
selected_geometry_available: false,
|
||||
context_geometry_count: 1,
|
||||
truncated: true,
|
||||
child_coverage: {
|
||||
location_type: 'district',
|
||||
registered_count: 3,
|
||||
represented_count: 1,
|
||||
},
|
||||
areas: [
|
||||
{
|
||||
...boundary,
|
||||
selected_territory: false,
|
||||
child_territory: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
);
|
||||
assert.match(html, /1 de 3 referências acessíveis/);
|
||||
assert.match(html, /Subdivisão do território seleccionado/);
|
||||
assert.match(html, /não significa inexistência do território/);
|
||||
assert.match(html, /100 geometrias e 500 subdivisões/);
|
||||
assert.doesNotMatch(html, /apenas limites dos níveis superiores/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user