refactor(space): separate satellite and mission layer components

This commit is contained in:
Sameh Khamis committed 2026-09-13 13:12:34 -07:00
1 parent 61db945b21
commit ce0568983a
44 files changed
+8767 -6095

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createSatelliteSource } from './source.js';
import { createSatellitesLayer } from './index.js';
test('satellite sources confine catalog groups and reject a cancelled body', async () => {
const controller = new AbortController();
let requests = 0;
const source = createSatelliteSource({
fetchImpl: async (url) => {
requests++;
assert.equal(url, '/api/celestrak/stations');
return {
ok: true,
status: 200,
text: async () => {
controller.abort();
return 'late catalog';
},
};
},
});
await assert.rejects(
source.readGroup('../active'),
/Unknown satellite group/,
);
assert.equal(requests, 0);
await assert.rejects(
source.readGroup('stations', { signal: controller.signal }),
{ name: 'AbortError' },
);
});
test('satellite factories keep control state separate and construct without requests', () => {
const source = {
readGroup() {
assert.fail('construction fetched a catalog');
},
};
const services = Object.fromEntries(
[
'picking',
'focus',
'readout',
'overlays',
'context',
'render',
'layerState',
].map((key) => [key, {}]),
);
services.layerState.isExplicitLayerStateOrigin = () => false;
const first = createSatellitesLayer({ source, services });
const second = createSatellitesLayer({ source, services });
first.setParams({ showPoints: false });
assert.equal(first.getParams().showPoints, false);
assert.equal(second.getParams().showPoints, true);
assert.notEqual(first.getStats(), second.getStats());
});