From 4688eca9af21c10ef32650beb97af4b02a4c54f5 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Fri, 11 Sep 2026 13:25:24 -0700 Subject: [PATCH] test: verify infrastructure consumer asset paths and imports --- package.json | 2 +- src/data/infrastructure.test.mjs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 59c277fb6..e2676c976 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/data/infrastructure.test.mjs b/src/data/infrastructure.test.mjs index fcc869747..416423636 100644 --- a/src/data/infrastructure.test.mjs +++ b/src/data/infrastructure.test.mjs @@ -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`); + } +});