mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
Merge origin/main into space-missions-fixes
Main's single click rule (the card or label on top takes the click, read once per click through clickCard and isUnderOtherCard in src/data/pickRegistry.js) covers a click on a Space Missions label: a mission marker label is an interactive world-overlay entry, so the host's hit test names it as the card on top for every other layer. The per-layer label guards in CCTV, Drone Airspace, FIRMS, Ghost Maps, News, Perimeters, Shipwrecks, Vessels, Wildlife Sightings, ALPR, Local ADS-B and the cockpit orbital focus are dropped for main's versions. The mission-label tests are kept on main's API: fakeInputUnderLabel now also names the label as the card on top, and each test shows a click on the label never acts on the card, camera, vessel, fire, reader, aircraft or report under it, and leaves the selection as it is. A launches test checks that a mission label is interactive and is the card on top for every other layer. Docs, changelog and the dispatcher's `overlay` note describe the merged behaviour. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
commit
0e5c5e624c
146 files changed
+9734
-1157
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { VESSEL_OVERLAY_SOURCE_ID } from '../../data/vesselLabels.js';
|
||||
import { clickCard } from '../../data/pickRegistry.js';
|
||||
import { fakeInputUnderLabel } from '../../input/testDoubles.mjs';
|
||||
import { createSelection } from './selection.js';
|
||||
|
||||
@@ -17,12 +18,18 @@ function recorder(calls) {
|
||||
);
|
||||
}
|
||||
|
||||
/** The vessel selection over a viewer whose clicks a label may take. */
|
||||
/** The vessel selection over a viewer whose clicks a Space Missions label
|
||||
* may take, with the vessel's card under every click. */
|
||||
function selectionHarness(t) {
|
||||
const viewer = { scene: { canvas: {}, pick: () => null } };
|
||||
const fake = fakeInputUnderLabel(viewer);
|
||||
t.after(() => fake.destroy());
|
||||
const vessel = { id: 'v1', name: 'NORTHERN STAR', lat: 0, lon: 0 };
|
||||
const fake = fakeInputUnderLabel(viewer, {
|
||||
beneath: () => ({
|
||||
sourceId: VESSEL_OVERLAY_SOURCE_ID,
|
||||
entryId: `vessel:${vessel.id}`,
|
||||
}),
|
||||
});
|
||||
t.after(() => fake.destroy());
|
||||
const focused = [];
|
||||
const calls = [];
|
||||
const state = {
|
||||
@@ -32,20 +39,11 @@ function selectionHarness(t) {
|
||||
selectedRecord: null,
|
||||
interactionKeyTarget: new EventTarget(),
|
||||
};
|
||||
const vesselState = {
|
||||
state,
|
||||
// The vessel's card lies under the click.
|
||||
_vesselOverlayHost: {
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
sourceId === VESSEL_OVERLAY_SOURCE_ID
|
||||
? { sourceId, entryId: `vessel:${vessel.id}` }
|
||||
: null,
|
||||
},
|
||||
};
|
||||
const vesselState = { state };
|
||||
const selection = createSelection({
|
||||
vesselState,
|
||||
services: {
|
||||
picking: { isOwnedByOtherLayer: () => false },
|
||||
picking: { isOwnedByOtherLayer: () => false, clickCard },
|
||||
worldFocus: { requestWorldFocus: (request) => focused.push(request.id) },
|
||||
context: recorder(calls),
|
||||
},
|
||||
@@ -68,7 +66,7 @@ function selectionHarness(t) {
|
||||
return { fake, state, vessel, focused };
|
||||
}
|
||||
|
||||
test("a click a label painted over a vessel's card takes never selects or focuses the vessel", (t) => {
|
||||
test("a click on a mission label over a vessel's card never selects or focuses the vessel", (t) => {
|
||||
const h = selectionHarness(t);
|
||||
h.fake.label.over = true;
|
||||
h.fake.click();
|
||||
@@ -76,14 +74,15 @@ test("a click a label painted over a vessel's card takes never selects or focuse
|
||||
assert.deepEqual(h.focused, [], 'the camera is not sent to the vessel');
|
||||
});
|
||||
|
||||
test('a click a label painted over the map takes lets go of the selected vessel', (t) => {
|
||||
test('a click on a mission label keeps the selected vessel', (t) => {
|
||||
const h = selectionHarness(t);
|
||||
// Off the label, a click on the card selects and focuses its vessel.
|
||||
h.fake.click();
|
||||
assert.equal(h.state.selectedRecord, h.vessel);
|
||||
assert.deepEqual(h.focused, ['v1']);
|
||||
// The label on top is its own click: the vessel stays selected.
|
||||
h.fake.label.over = true;
|
||||
h.fake.click();
|
||||
assert.equal(h.state.selectedRecord, null);
|
||||
assert.equal(h.state.selectedRecord, h.vessel);
|
||||
assert.deepEqual(h.focused, ['v1']);
|
||||
});
|
||||
Reference in new issue
Block a user