Files
gods-eye-view/src/layers/radio/interaction.test.mjs
T
Sameh Khamis 045267c841 Keep the radio layer's Cesium entities and picks in its rendering part
The radio interaction, selection and navigation parts had left the
Cesium allow-list but still read pick objects, toggled entity
visibility, removed the selection entity, re-ran clustering and read the
Cesium camera. Navigation now reads the camera port's pose; the rest
moves into the rendering part.
2026-11-07 01:04:46 -08:00

62 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test';
import assert from 'node:assert/strict';
import { createInteraction } from './interaction.js';
import { RADIO_PICK_WINDOW_PX } from './policy.js';
import { radioStationIdFromPick } from './rendering.js';
function interaction() {
const state = { _stationById: new Map([['kexp', {}]]) };
return createInteraction({
state,
services: {
picking: {
resolvePickId: (picked) => picked?.id ?? null,
isOwnedByOtherLayer: (layer, id) => id === 'flight-1',
registerPickOwner() {},
unregisterPickOwner() {},
},
overlays: { setOverlaySourceVisible() {} },
},
parts: { rendering: { radioStationIdFromPick } },
});
}
/** A click event whose drill answers only with the window it is asked for. */
function clickEvent({ pick, windowHits = [] }) {
const drills = [];
return {
drills,
pick,
drill(limit, width, height) {
drills.push([limit, width, height]);
return width === RADIO_PICK_WINDOW_PX && height === RADIO_PICK_WINDOW_PX
? windowHits
: [];
},
};
}
test('a near miss finds the station through one windowed drill', () => {
const { pickedRadioStationAt } = interaction();
const event = clickEvent({
pick: undefined,
windowHits: [{ id: 'tile' }, { id: 'radio:kexp' }],
});
assert.equal(pickedRadioStationAt(event), 'kexp');
assert.deepEqual(event.drills, [
[16, RADIO_PICK_WINDOW_PX, RADIO_PICK_WINDOW_PX],
]);
});
test('a direct hit needs no drill, and another layer’s contact keeps its click', () => {
const { pickedRadioStationAt } = interaction();
const direct = clickEvent({ pick: { id: 'radio:kexp' } });
assert.equal(pickedRadioStationAt(direct), 'kexp');
assert.deepEqual(direct.drills, []);
const other = clickEvent({
pick: { id: 'flight-1' },
windowHits: [{ id: 'radio:kexp' }],
});
assert.equal(pickedRadioStationAt(other), null);
});