test: verify infrastructure consumer asset paths and imports

This commit is contained in:
Sameh Khamis committed 2026-09-11 13:28:55 -07:00
1 parent 142bf583f8
commit 4688eca9af
2 files changed
+32 -1

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
"name": "gods-eye-view",
"private": true,
"version": "0.1.1",
"description": "A real-time intelligence console for planet Earth \u2014 photorealistic 3D globe, live aircraft/ships/satellites/earthquakes/CCTV, and hands-free voice control. Runs in a browser.",
"description": "A real-time intelligence console for planet Earth — photorealistic 3D globe, live aircraft/ships/satellites/earthquakes/CCTV, and hands-free voice control. Runs in a browser.",
"type": "module",
"license": "MIT",
"author": "Bilawal Sidhu",
+31
View File
@@ -97,3 +97,34 @@ test('two viewers use their supplied contexts and dispose independently', async
assert.equal(hosts[1].records.size, 1);
assert.equal(instances[1].viewer.dataSources.length, 1);
});
test('consumer build includes only infrastructure code and resolves assets under a non-root base', async () => {
const { build } = await import('vite');
const { fileURLToPath } = await import('node:url');
const result = await build({
configFile: false,
logLevel: 'silent',
base: '/example/',
build: {
write: false,
assetsInlineLimit: 0,
rollupOptions: {
input: fileURLToPath(import.meta.resolve('gods-eye-view/infrastructure')),
external: ['cesium'],
preserveEntrySignatures: 'strict',
},
},
});
const output = result.output;
const entry = output.find(item => item.type === 'chunk' && item.isEntry);
const sources = Object.keys(entry.modules).filter(id => id.endsWith('.js'));
assert.deepEqual(sources.map(id => id.split('/').at(-1)).sort(), [
'infrastructure.js', 'localGeojsonCore.js', 'localGeojsonLod.js',
]);
assert.deepEqual(entry.imports, ['cesium'], 'the viewer supplies the same Cesium dependency');
for (const name of ['datacenters', 'dams']) {
const asset = output.find(item => item.type === 'asset' && item.fileName.includes(name));
assert.ok(asset, `${name} must be emitted`);
assert.ok(entry.code.includes(`/example/${asset.fileName}`), `${name} must retain the consumer base path`);
}
});