mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
test(dams): run the Acaray and Yacyretá layer check on main's test doubles
The separate layer test built a fake viewer with the old Cesium interface, which fails on current main. Move it into src/data/infrastructure.test.mjs on the fake ground renderer and input port, with one table and one parse of dams.geojsonl for both checks. Compare source_url exactly and check retrieved_at, and cover the dams attribution and both new records in the find_infrastructure tests. Also trim the dataset README section (keep both dams as polygons), drop the outdated "does not refresh or relicense" sentence, keep provenance out of the License cell, rename the changelog fragment after the change, and restore the accent in the test name.
This commit is contained in:
1 parent
17b75e8896
commit
fa4b4adeae
8 files changed
+87
-137
No files matched your search
@@ -6,6 +6,7 @@ import { createInfrastructureLayers } from 'gods-eye-view/infrastructure';
|
||||
import { createLocalGeoJsonLayer } from 'gods-eye-view/infrastructure/geojson';
|
||||
import { fakeInput } from '../input/testDoubles.mjs';
|
||||
import { bindFakeGroundRenderer } from '../testSupport/fakeGroundRenderer.mjs';
|
||||
import { parseGeojsonLines } from '../sources/infrastructureData.js';
|
||||
|
||||
function services() {
|
||||
const records = new Map();
|
||||
@@ -34,6 +35,20 @@ function services() {
|
||||
};
|
||||
}
|
||||
|
||||
// Added from the OSM API, not the OpenInfraMap extract: [id, name, OSM
|
||||
// object, version]. Both must stay polygons: the Dams layer skips
|
||||
// LineStrings.
|
||||
const OSM_API_DAMS = [
|
||||
[262532166, 'Acaray', 'way/262532166', 7],
|
||||
[-5671745, 'Represa Yacyretá-Apipé', 'relation/5671745', 2],
|
||||
];
|
||||
const DAMS = parseGeojsonLines(
|
||||
readFileSync(
|
||||
new URL('./local_data/dams/dams.geojsonl', import.meta.url),
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
|
||||
test('package exports import without an application, DOM, fetch, or timers', () => {
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
@@ -100,29 +115,64 @@ test('dataset URLs still name the complete bundled sources', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('Acaray and Yacyreta retain unique OSM records in the current GeoJSONL bundle', () => {
|
||||
const folder = new URL('./local_data/dams/', import.meta.url);
|
||||
const lines = readFileSync(new URL('dams.geojsonl', folder), 'utf8')
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map(JSON.parse);
|
||||
for (const [id, name, version] of [
|
||||
[262532166, 'Acaray', 7],
|
||||
[-5671745, 'Represa Yacyretá-Apipé', 2],
|
||||
]) {
|
||||
const matches = lines.filter((feature) => feature.id === id);
|
||||
test('Acaray and Yacyretá appear once each with OSM provenance', () => {
|
||||
for (const [id, name, object, version] of OSM_API_DAMS) {
|
||||
const matches = DAMS.filter((feature) => feature.id === id);
|
||||
assert.equal(matches.length, 1);
|
||||
assert.equal(matches[0].properties.name, name);
|
||||
assert.equal(matches[0].properties.source_version, version);
|
||||
assert.equal(matches[0].properties.osm_id, id);
|
||||
assert.match(
|
||||
matches[0].properties.source_url,
|
||||
/^https:\/\/www.openstreetmap.org\//,
|
||||
const { properties } = matches[0];
|
||||
assert.equal(properties.name, name);
|
||||
assert.equal(properties.osm_id, id);
|
||||
assert.equal(properties.source_version, version);
|
||||
assert.equal(
|
||||
properties.source_url,
|
||||
`https://www.openstreetmap.org/${object}`,
|
||||
);
|
||||
assert.ok(Array.isArray(matches[0].geometry.coordinates));
|
||||
assert.equal(properties.retrieved_at, '2026-10-15');
|
||||
}
|
||||
});
|
||||
|
||||
test('Acaray and Yacyretá each get a stem, a selection context and an analyst record', async (t) => {
|
||||
const added = DAMS.filter((feature) =>
|
||||
OSM_API_DAMS.some(([id]) => id === feature.id),
|
||||
);
|
||||
t.mock.method(globalThis, 'fetch', async () => ({
|
||||
ok: true,
|
||||
text: async () =>
|
||||
added.map((feature) => JSON.stringify(feature)).join('\n'),
|
||||
}));
|
||||
const host = services();
|
||||
const layer = createLocalGeoJsonLayer(
|
||||
{
|
||||
id: 'local-dams',
|
||||
name: 'Dams',
|
||||
osmDerived: true,
|
||||
color: '#0088ff',
|
||||
url: '/dams.geojsonl',
|
||||
},
|
||||
host,
|
||||
);
|
||||
const viewer = {
|
||||
scene: { screenSpaceCameraController: { enableInputs: true } },
|
||||
};
|
||||
const fake = bindFakeGroundRenderer(viewer);
|
||||
fakeInput(viewer);
|
||||
t.after(() => layer.destroy(viewer));
|
||||
await layer.enable(viewer);
|
||||
const names = OSM_API_DAMS.map(([, name]) => name).sort();
|
||||
assert.equal(fake.set('stems').items.size, 2, 'both dams get a stem');
|
||||
assert.deepEqual(
|
||||
[...host.records.values()].map((record) => record.label).sort(),
|
||||
names,
|
||||
);
|
||||
assert.deepEqual(
|
||||
layer
|
||||
.getAnalystRecords()
|
||||
.map((record) => record.name)
|
||||
.sort(),
|
||||
names,
|
||||
);
|
||||
});
|
||||
|
||||
test('two viewers use their supplied contexts and dispose independently', async (t) => {
|
||||
t.mock.method(globalThis, 'fetch', async () => ({
|
||||
ok: true,
|
||||
|
||||
Reference in new issue
Block a user