mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 07:42:23 +00:00
Layer state keeps only layers the application registered
An application built with fewer layers no longer restores, stores or shares a layer it does not have when a link or saved state from a build that has it names that layer. LayerStateCoordinator drops unregistered enabled-layer ids before normalizing, so dependent options (a tracked selection) go with them. An application with every layer registered is unchanged.
This commit is contained in:
1 parent
7ee7dc26b8
commit
e9346cef19
3 files changed
+98
-9
No files matched your search
@@ -3121,3 +3121,70 @@ test('Active Fires: the codec accepts whole megawatts in bounds and the three co
|
||||
confidence: 'nominal',
|
||||
});
|
||||
});
|
||||
|
||||
// An application built without a layer (a smaller catalog) receives a link or
|
||||
// saved state from a build that has it: the layer is neither restored nor
|
||||
// stored nor carried into the links this application shares.
|
||||
function managerWithout(withheld) {
|
||||
const manager = new DataLayerManager({});
|
||||
for (const id of REGISTERED_LAYER_IDS)
|
||||
if (!withheld.includes(id)) manager.register(fakeLayer(id));
|
||||
manager.finalizeRegistrations(
|
||||
LAYER_STATE_REGISTRY.filter(({ id }) => !withheld.includes(id)),
|
||||
);
|
||||
return manager;
|
||||
}
|
||||
|
||||
test('layers the application did not register are never restored, stored or shared', async () => {
|
||||
const manager = managerWithout(['earthquakes']);
|
||||
const storage = memoryStorage();
|
||||
const share = shareSink();
|
||||
const coordinator = new LayerStateCoordinator(manager, share, { storage });
|
||||
const incoming = createDefaultLayerState();
|
||||
incoming.enabledLayerIds = ['earthquakes', 'traffic'];
|
||||
await coordinator.start({ shareLayerState: incoming });
|
||||
|
||||
assert.deepEqual(coordinator.getDurableState().enabledLayerIds, ['traffic']);
|
||||
assert.deepEqual(share.provider().enabledLayerIds, ['traffic']);
|
||||
assert.equal(manager.layers.has('earthquakes'), false);
|
||||
|
||||
await manager.setEnabled('cctv', true, { origin: 'user' });
|
||||
const [[, written]] = storage.writes;
|
||||
assert.deepEqual(parseStoredLayerState(written).enabledLayerIds, [
|
||||
'cctv',
|
||||
'traffic',
|
||||
]);
|
||||
assert.deepEqual(share.provider().enabledLayerIds, ['cctv', 'traffic']);
|
||||
|
||||
await coordinator.applyShareLayerState({ shareLayerState: incoming });
|
||||
assert.deepEqual(coordinator.getDurableState().enabledLayerIds, ['traffic']);
|
||||
coordinator.destroy();
|
||||
|
||||
const saved = createDefaultLayerState();
|
||||
saved.enabledLayerIds = ['earthquakes', 'traffic'];
|
||||
const local = new LayerStateCoordinator(
|
||||
managerWithout(['earthquakes']),
|
||||
shareSink(),
|
||||
{ storage: memoryStorage(serializeStoredLayerState(saved)) },
|
||||
);
|
||||
await local.start();
|
||||
assert.equal(local.source, 'local');
|
||||
assert.deepEqual(local.getDurableState().enabledLayerIds, ['traffic']);
|
||||
local.destroy();
|
||||
});
|
||||
|
||||
test('an application with every layer registered keeps every requested layer', async () => {
|
||||
const coordinator = new LayerStateCoordinator(
|
||||
productionManager(),
|
||||
shareSink(),
|
||||
{ storage: memoryStorage() },
|
||||
);
|
||||
const incoming = createDefaultLayerState();
|
||||
incoming.enabledLayerIds = ['earthquakes', 'traffic'];
|
||||
await coordinator.start({ shareLayerState: incoming });
|
||||
assert.deepEqual(coordinator.getDurableState().enabledLayerIds, [
|
||||
'earthquakes',
|
||||
'traffic',
|
||||
]);
|
||||
coordinator.destroy();
|
||||
});
|
||||
Reference in new issue
Block a user