mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Station dots and the selected-station highlight are now two point draw sets, picked through the draw hit, and the layer follows the camera through the camera port at its own threshold instead of the shared percentageChanged ledger. Altitude and view centre come from the camera pose and view rectangle. All five bikeshare files leave the Cesium allow-list. The Cesium draw port now keeps a rebuilt host in its place in the scene instead of re-adding it on top, tags hosts with their set id so sprite order can raise a draw set (registerSpriteSet), and restyles unclamped points in place when they have not moved, so a status poll or selection no longer rebuilds every station. Other draw-port layers (cyclone markers, earthquake discs) now also keep their first-build slot rather than jumping above the sprite layers on each rebuild.
90 lines
3.2 KiB
JavaScript
90 lines
3.2 KiB
JavaScript
import test from 'node:test';
|
||
import assert from 'node:assert/strict';
|
||
import { fromDegrees } from '../geo/ellipsoid.js';
|
||
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
|
||
import {
|
||
BIKESHARE_SELECTED_OVERLAY_SOURCE_OPTIONS,
|
||
_clearBikeshareSelectionForTest,
|
||
_selectBikeshareStationForTest,
|
||
_setBikeshareSelectionStateForTest,
|
||
createBikeshareSelectedOverlayEntry,
|
||
} from './bikeshare.js';
|
||
|
||
function makeRecord() {
|
||
return {
|
||
stationId: '3790',
|
||
stationName: 'Congress & 6th',
|
||
bikesAvailable: 7,
|
||
docksAvailable: 4,
|
||
capacity: 11,
|
||
isInstalled: true,
|
||
isRenting: false,
|
||
isReturning: true,
|
||
key: 'austin-capmetro:3790',
|
||
position: fromDegrees(-97.7431, 30.2672, 2),
|
||
pixelSize: 8,
|
||
color: [0, 1, 0, 1],
|
||
};
|
||
}
|
||
|
||
test('selected bikeshare entry preserves source copy and protected-lane policy', () => {
|
||
const record = makeRecord();
|
||
const entry = createBikeshareSelectedOverlayEntry('austin-capmetro:3790', record);
|
||
assert.equal(entry.position, record.position);
|
||
assert.equal(entry.title, 'Congress & 6th');
|
||
assert.deepEqual(entry.details, [
|
||
'🚲 7 avail · 4 docks · 11 cap',
|
||
'⚠️ Not renting',
|
||
]);
|
||
assert.equal(entry.variant, 'selected');
|
||
assert.equal(entry.selected, true);
|
||
assert.equal(entry.protected, true);
|
||
assert.equal(entry.paintLane, 'selected');
|
||
assert.equal(entry.collisionGroup, 'ambient-card');
|
||
assert.equal(entry.edgeFade, 'keyhole');
|
||
assert.equal(entry.horizonCull, true);
|
||
});
|
||
|
||
test('real station select/clear path publishes one card and draws no native label', () => {
|
||
const calls = [];
|
||
const overlayHost = {
|
||
setEntries: (...args) => calls.push(['entries', ...args]),
|
||
setVisible: (...args) => calls.push(['visible', ...args]),
|
||
clearSource: (...args) => calls.push(['clear', ...args]),
|
||
};
|
||
const key = 'austin-capmetro:3790';
|
||
const record = makeRecord();
|
||
const viewer = {};
|
||
const { draw, unbind } = bindFakeDraw(viewer);
|
||
_setBikeshareSelectionStateForTest({ viewer, key, record, overlayHost });
|
||
const live = (suffix) =>
|
||
[...draw.sets.values()].find((set) => !set.disposed && set.spec.id.endsWith(suffix));
|
||
const stations = live(':stations');
|
||
const selected = live(':selected');
|
||
try {
|
||
_selectBikeshareStationForTest(key);
|
||
assert.equal(stations.items.get(key).show, false, 'the station’s own dot is hidden');
|
||
assert.equal(selected.items.size, 1, 'one highlight dot replaces it');
|
||
const [highlight] = selected.items.values();
|
||
assert.equal(highlight.pos, record.position);
|
||
assert.deepEqual(highlight.color, [0, 1, 1, 1], 'cyan');
|
||
assert.equal(highlight.pixelSize, 14);
|
||
assert.equal(highlight.disableDepthTest, Infinity);
|
||
|
||
const publication = calls.find(([type]) => type === 'entries');
|
||
assert.ok(publication);
|
||
assert.equal(publication[1], 'bikeshare-selected');
|
||
assert.equal(publication[2].length, 1);
|
||
assert.equal(publication[2][0].position, record.position);
|
||
assert.deepEqual(publication[3], BIKESHARE_SELECTED_OVERLAY_SOURCE_OPTIONS);
|
||
|
||
_clearBikeshareSelectionForTest();
|
||
assert.equal(stations.items.get(key).show, true);
|
||
assert.equal(selected.items.size, 0);
|
||
assert.deepEqual(calls.at(-1), ['clear', 'bikeshare-selected']);
|
||
} finally {
|
||
_clearBikeshareSelectionForTest();
|
||
unbind();
|
||
}
|
||
});
|