fix(voice): Navara refusals reach speech, analyst queries and stop_tracking

Review of 10a (low):
- The spoken answer to set_layer_visibility on a layer this engine lacks is
  the refusal's own sentence (why, and the switch to ?engine=cesium), not
  only "Couldn't turn on".
- analyst_query naming layers the catalog left out (no viewer) refuses with
  UNAVAILABLE_ON_ENGINE and the layer ids instead of answering zero.
- stop_tracking skips layers the engine does not have, so with nothing
  tracked it is a no-op success on Navara (it reported the absent military
  and satellites layers as failures).
Tests for each (the old code fails the last two); Cesium unchanged.
This commit is contained in:
German Khokhlov committed 2026-10-17 01:18:12 +04:00
1 parent 443c581280
commit 1dd3220812
3 files changed
+86 -1

No files matched your search

+51
View File
@@ -504,3 +504,54 @@ test('without a viewer a layer the engine lacks refuses instead of throwing', as
'a name no engine knows is still an unknown layer',
);
});
test('without a viewer analyst_query on a layer the engine lacks refuses', async () => {
const engine = engineOverAustin({ kind: 'navara' });
const runner = runnerOn(engine, {
dataManager: dataManagerWith({ flights: {} }),
});
const one = await runner('analyst_query', { layers: ['cctv'] });
assert.equal(one.ok, false);
assert.equal(one.code, UNAVAILABLE_ON_ENGINE);
assert.deepEqual(one.layerIds, ['cctv']);
assert.match(
one.error,
/^The cctv layer is not available on the Navara engine yet/,
);
const two = await runner('analyst_query', { layers: ['cctv', 'vessels'] });
assert.match(
two.error,
/^The cctv, ais-live-vessels layers are not available on the Navara engine yet\. Switch to the Cesium engine \(\?engine=cesium\) to use them\.$/,
);
});
test('stop_tracking with nothing tracked is a no-op success, also without the layers', async () => {
const engine = engineOverAustin({ kind: 'navara' });
const dataManager = dataManagerWith({
flights: { getTrackedInfo: () => null },
});
// As the manager answers: a layer it does not hold takes no params.
dataManager.setLayerParams = (id) => dataManager.layers.has(id);
const runner = runnerOn(engine, { dataManager });
const result = await runner('stop_tracking', {});
assert.equal(result.ok, true);
assert.deepEqual(result.released, []);
});
test('the spoken refusal of an unavailable layer carries its reason', async () => {
const { SPEECH_BUILDERS } = await import('./speech.js');
const engine = engineOverAustin({ kind: 'navara' });
const runner = runnerOn(engine, {
dataManager: dataManagerWith({ flights: {} }),
});
const result = await runner('set_layer_visibility', {
layerId: 'cctv',
enabled: true,
});
const speech = SPEECH_BUILDERS.set_layer_visibility(result, {
layerId: 'cctv',
enabled: true,
});
assert.equal(speech.say, result.error);
assert.match(speech.say, /Switch to the Cesium engine/);
});