Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

test(director): cover observer failures in session activate and clear

Said Turksever811eb7835d2f
diff --git a/src/director/interactions/interactions.test.mjs b/src/director/interactions/interactions.test.mjs
index 496616516..6c13cecef 100644
--- a/src/director/interactions/interactions.test.mjs
+++ b/src/director/interactions/interactions.test.mjs
@@ -233,6 +233,37 @@ test('a throwing changed observer does not break session dispatch, activation, o
}
});
+test('an observer that always throws cannot stop activate or clear', () => {
+ const warnings = [];
+ const origWarn = console.warn;
+ console.warn = (...args) => warnings.push(args);
+ try {
+ const session = createInteractionSession({
+ execute: () => true,
+ changed: () => {
+ throw new Error('observer failed');
+ },
+ });
+ session.activate([{ id: 'a' }, { id: 'b' }]);
+ assert.deepEqual(session.getState(), {
+ active: true,
+ busy: false,
+ selected: null,
+ count: 2,
+ });
+ session.clear();
+ assert.deepEqual(session.getState(), {
+ active: false,
+ busy: false,
+ selected: null,
+ count: 0,
+ });
+ assert.equal(warnings.length, 3);
+ } finally {
+ console.warn = origWarn;
+ }
+});
+
test('settled pack shots cannot take the same-shot seek shortcut after Stop released geometry', async () => {
const { SceneDirector } = await import('../../scenes/director.js');
const shot = { id: 'shot', dataPackIds: ['pack'] };