mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Never act on what lies under a mission label when it is clicked
A click on a Space Missions label reaches every click subscriber so they can let go of their selection, but the layers that test their own painted cards or pick the scene themselves still found what lay under the label: CCTV turned that camera on, FIRMS and Vessels selected and flew to theirs, News and Wildlife Sightings opened their item, Perimeters, Ghost Maps and Shipwrecks opened the card's link, ALPR selected its reader, and Local ADS-B drilled the scene itself and selected the aircraft. Each now skips its own test on such a click, and Local ADS-B drills through the click, so the click only releases selections, as a click on empty map or another layer's contact does. Ordinary clicks behave as before. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
8675ead171
commit
5feac417d6
22 files changed
+453
-72
No files matched your search
@@ -2,6 +2,7 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
import { fakeInputUnderLabel } from '../../input/testDoubles.mjs';
|
||||
import {
|
||||
createShipwrecksLayer,
|
||||
markerPixelSize,
|
||||
@@ -393,3 +394,51 @@ test('the page deadline subtracts the newest available source age from the limit
|
||||
);
|
||||
assert.equal(snapshotDeadline({ sources: both }, 0), 7 * DAY, 'defaults');
|
||||
});
|
||||
|
||||
test("a click a label painted over the open card takes never opens the card's link, and closes the card", async (t) => {
|
||||
let picked = null;
|
||||
const viewer = { scene: { canvas: {}, pick: () => picked } };
|
||||
bindFakeDraw(viewer);
|
||||
const fake = fakeInputUnderLabel(viewer);
|
||||
t.after(() => fake.destroy());
|
||||
const cards = [];
|
||||
const opened = [];
|
||||
let cardUnder = null;
|
||||
const layer = createShipwrecksLayer({
|
||||
source: { getSnapshot: () => Promise.resolve(snapshot([wreck('a')])) },
|
||||
overlayHost: {
|
||||
setEntries: (_source, entries) => cards.push(entries),
|
||||
setVisible() {},
|
||||
hitTest: () => (cardUnder ? { entryId: cardUnder } : null),
|
||||
},
|
||||
input: () => fake.input,
|
||||
picking,
|
||||
pointer: { isPointerFree: () => true },
|
||||
openExternal: (url) => opened.push(url),
|
||||
now: () => 1,
|
||||
});
|
||||
layer.init(viewer);
|
||||
t.after(() => layer.destroy());
|
||||
layer.enable();
|
||||
await layer.update();
|
||||
picked = { primitive: {}, id: { set: 'shipwrecks:', id: 'shipwreck:a' } };
|
||||
fake.click();
|
||||
const [card] = cards.at(-1);
|
||||
assert.equal(card.id, 'shipwreck-card:a');
|
||||
|
||||
// The open card lies under the label: the click opens nothing.
|
||||
picked = null;
|
||||
cardUnder = card.id;
|
||||
fake.label.over = true;
|
||||
fake.click();
|
||||
assert.deepEqual(opened, [], 'the link beneath the label is not opened');
|
||||
assert.deepEqual(cards.at(-1), [], 'the card is closed');
|
||||
|
||||
// Off the label, a click on the open card opens its link.
|
||||
fake.label.over = false;
|
||||
picked = { primitive: {}, id: { set: 'shipwrecks:', id: 'shipwreck:a' } };
|
||||
fake.click();
|
||||
picked = null;
|
||||
fake.click();
|
||||
assert.equal(opened.length, 1);
|
||||
});
|
||||
Reference in new issue
Block a user