mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
fix(overlays): let only the topmost painted card act on a click
Card handlers hit-tested only their own source, so a card buried under another layer's card still acted, and a click on a selected quake card over a vessel or fire card made both layers act. Vessels, FIRMS, wildlife, news, ghost maps and shipwrecks now read the unfiltered topmost painted entry: their own card acts only when it is on top, and a click on another layer's card is that layer's, so it neither acts here nor clears a selection. A top news or wildlife card still acts over another layer's scene item, so it never goes dead over a flight trail or a directions route; a registered marker under a foreign card is still its layer's to select.
This commit is contained in:
1 parent
5bc31ce08a
commit
836daf82b3
14 files changed
+310
-43
No files matched your search
@@ -1847,12 +1847,17 @@ test('vessel interaction wire: a vessel with an id and no MMSI is selected by cl
|
||||
* only publishes rects for `interactive` entries, so a stub returning a hit is
|
||||
* the same contract a painted, actionable card presents.
|
||||
*/
|
||||
function hostWithCardHit(entryId) {
|
||||
function hostWithCardHit(entryId, topHit) {
|
||||
return {
|
||||
setEntries() {},
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
hitTest: () => (entryId ? { sourceId: 'ais-live-vessels', entryId } : null),
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
!sourceId && topHit
|
||||
? topHit
|
||||
: entryId
|
||||
? { sourceId: 'ais-live-vessels', entryId }
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1914,6 +1919,29 @@ test('vessel interaction wire: clicking the selected vessel card refocuses exact
|
||||
}
|
||||
});
|
||||
|
||||
test('vessel interaction wire: a covered card yields while a real vessel pick still focuses', () => {
|
||||
for (const ownPick of [false, true]) {
|
||||
const harness = installWireHarness(ownPick ? { id: makeRecord().mmsi } : null);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
_setVesselOverlayHostForTest(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`, {
|
||||
sourceId: 'earthquakes', entryId: 'quake:cover',
|
||||
}),
|
||||
);
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(requests.length, ownPick ? 1 : 0);
|
||||
assert.equal(aisLiveVesselsLayer.getSelectedInfo()?.mmsi, harness.record.mmsi);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('vessel interaction wire: an unknown card id preserves selection and never flies', () => {
|
||||
const harness = installWireHarness({
|
||||
primitive: {},
|
||||
|
||||
@@ -58,6 +58,7 @@ function harness({
|
||||
fires = [makeFire()],
|
||||
picked = null,
|
||||
cardHit = null,
|
||||
topCard = null,
|
||||
cameraPosition = null,
|
||||
withDataSource = false,
|
||||
withGlobe = false,
|
||||
@@ -85,7 +86,12 @@ function harness({
|
||||
setEntries: (sourceId, entries) => published.push(...entries),
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
hitTest: () => (cardHit ? { sourceId: 'firms', entryId: cardHit } : null),
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
!sourceId && topCard
|
||||
? topCard
|
||||
: cardHit
|
||||
? { sourceId: 'firms', entryId: cardHit }
|
||||
: null,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -153,6 +159,9 @@ function harness({
|
||||
(record) => record.kind === 'icons' && !record.disposed,
|
||||
),
|
||||
click: () => input.click({ x: 400, y: 300 }),
|
||||
cover: (hit) => {
|
||||
topCard = hit;
|
||||
},
|
||||
cleanup() {
|
||||
Cesium.SceneTransforms.worldToWindowCoordinates = priorProjection;
|
||||
if (hadWindow) globalThis.window = priorWindow;
|
||||
@@ -308,7 +317,11 @@ test('far-side detections cannot consume the bounded ambient-card cohort', () =>
|
||||
|
||||
test('clicking a fire sprite selects it and requests the camera transfer', () => {
|
||||
const fire = makeFire();
|
||||
const h = harness({ fires: [fire], picked: glowPick('firms-7') });
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
picked: glowPick('firms-7'),
|
||||
topCard: { sourceId: 'earthquakes', entryId: 'quake:cover' },
|
||||
});
|
||||
try {
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1);
|
||||
@@ -355,6 +368,34 @@ test('clicking a fire CARD behaves exactly like clicking its sprite', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('a covered fire card does not act, and keeps an existing selection', () => {
|
||||
const fire = makeFire();
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
cardHit: `fire:${fireDetectionKey(fire)}`,
|
||||
});
|
||||
try {
|
||||
// Covered by another layer's card from the start: nothing selects or flies.
|
||||
h.cover({ sourceId: 'earthquakes', entryId: 'quake:cover' });
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 0);
|
||||
assert.equal(h.layer.getSelectedInfo(), null);
|
||||
// Uncovered, the card selects; covered again, the click is the other
|
||||
// layer's and leaves that selection alone.
|
||||
h.cover(null);
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1);
|
||||
const selected = h.layer.getSelectedInfo();
|
||||
assert.ok(selected);
|
||||
h.cover({ sourceId: 'earthquakes', entryId: 'quake:cover' });
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1);
|
||||
assert.deepEqual(h.layer.getSelectedInfo(), selected);
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
// The voice model reads these labels as data (track_entity, get_entity_context,
|
||||
// pointer_context); the voice card translates them where it shows them.
|
||||
test('fire labels stay English data in a translated interface', () => {
|
||||
|
||||
@@ -49,11 +49,9 @@ export function createSelection({
|
||||
const cardHit = overlayHost.hitTest?.(
|
||||
event.screenPosition?.x,
|
||||
event.screenPosition?.y,
|
||||
{
|
||||
sourceId: FIRMS_OVERLAY_SOURCE_ID,
|
||||
},
|
||||
);
|
||||
if (cardHit) {
|
||||
if (cardHit.sourceId !== FIRMS_OVERLAY_SOURCE_ID) return;
|
||||
const carded = layerState._fireByCardId.get(cardHit.entryId);
|
||||
if (carded) selectAndFocusFire(carded);
|
||||
return;
|
||||
|
||||
@@ -710,9 +710,11 @@ export function createGhostMapsLayer({
|
||||
const cardHit = overlayHost.hitTest?.(
|
||||
event.screenPosition?.x,
|
||||
event.screenPosition?.y,
|
||||
{ sourceId: GHOSTMAPS_OVERLAY_SOURCE_ID },
|
||||
);
|
||||
if (cardHit && cardHit.entryId === _selectedCardId) {
|
||||
if (
|
||||
cardHit?.sourceId === GHOSTMAPS_OVERLAY_SOURCE_ID &&
|
||||
cardHit.entryId === _selectedCardId
|
||||
) {
|
||||
if (_selectedLink && openExternal) openExternal(_selectedLink);
|
||||
return;
|
||||
}
|
||||
@@ -729,6 +731,10 @@ export function createGhostMapsLayer({
|
||||
if (pickId && picking.isOwnedByOtherLayer(GHOSTMAPS_LAYER_ID, pickId))
|
||||
return;
|
||||
}
|
||||
// A covered card must neither open its source nor clear the selection.
|
||||
// A marker of ours under that card was already selected by the pick
|
||||
// check before this one.
|
||||
if (cardHit) return;
|
||||
if (_selectedKey) {
|
||||
clearSelection();
|
||||
render();
|
||||
|
||||
@@ -642,3 +642,54 @@ test('narrowing to a window the loaded data covers clears a failed wider reload'
|
||||
assert.equal(layer.getStats().error, null);
|
||||
assert.equal(layer.getStats().count, 1);
|
||||
});
|
||||
|
||||
test('a covered selected card yields while genuine GhostMaps markers still select', async (t) => {
|
||||
const cards = [];
|
||||
const opened = [];
|
||||
let painted = [];
|
||||
const { layer, viewer, click } = fixture(t, {
|
||||
reports: [
|
||||
{
|
||||
name: 'First',
|
||||
description: '<a href="https://example.com/first">Source</a>',
|
||||
},
|
||||
{
|
||||
name: 'Second',
|
||||
description: '<a href="https://example.com/second">Source</a>',
|
||||
},
|
||||
],
|
||||
controls: {
|
||||
overlayHost: {
|
||||
setEntries: (_id, entries) => cards.push(entries),
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
painted.find((hit) => !sourceId || hit.sourceId === sourceId) ?? null,
|
||||
},
|
||||
picking: { resolvePickId: (picked) => picked },
|
||||
openExternal: (url) => opened.push(url),
|
||||
},
|
||||
});
|
||||
await layer.update(viewer);
|
||||
click('ghostmaps:cip:0:0');
|
||||
const first = cards.at(-1)[0];
|
||||
const foreign = {
|
||||
sourceId: 'earthquake-card',
|
||||
entryId: 'earthquake-card:ak1',
|
||||
};
|
||||
painted = [foreign, { sourceId: 's2-ghostmaps', entryId: first.id }];
|
||||
click(null);
|
||||
assert.deepEqual(opened, []);
|
||||
assert.equal(cards.at(-1)[0].id, first.id);
|
||||
click('ghostmaps:cip:1:0');
|
||||
const second = cards.at(-1)[0];
|
||||
assert.notEqual(
|
||||
second.id,
|
||||
first.id,
|
||||
'an actual marker still selects beneath the foreign card',
|
||||
);
|
||||
painted = [{ sourceId: 's2-ghostmaps', entryId: second.id }];
|
||||
click(null);
|
||||
assert.deepEqual(opened, ['https://example.com/second']);
|
||||
painted = [];
|
||||
click(null);
|
||||
assert.deepEqual(cards.at(-1), [], 'bare map still clears the selection');
|
||||
});
|
||||
@@ -1348,10 +1348,10 @@ export function createNewsLayer({
|
||||
clickOff = inputFor(viewer).onClick((event) => {
|
||||
const at = event?.screenPosition;
|
||||
if (!enabled || destroyed || !isPointerFree() || !at) return;
|
||||
const card = hitTestOverlay(at.x, at.y, {
|
||||
sourceId: NEWS_OVERLAY_SOURCE_ID,
|
||||
});
|
||||
if (card?.entry?.activate) {
|
||||
// The topmost painted entry decides: our own card acts; one covered by
|
||||
// another layer's card does not.
|
||||
const card = hitTestOverlay(at.x, at.y);
|
||||
if (card?.sourceId === NEWS_OVERLAY_SOURCE_ID && card.entry?.activate) {
|
||||
card.entry.activate();
|
||||
return;
|
||||
}
|
||||
@@ -1408,6 +1408,8 @@ export function createNewsLayer({
|
||||
return;
|
||||
}
|
||||
if (id && isOwnedByOtherLayer(NEWS_LAYER_ID, id)) return;
|
||||
// Another layer's card on top is that layer's click, not empty map.
|
||||
if (card) return;
|
||||
if (selectedId && !picked?.id) layer.setParams({ clear: true });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,6 +5,13 @@ import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs';
|
||||
import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs';
|
||||
import { NEWS_KEY_PROVIDERS, createNewsLayer } from './index.js';
|
||||
import {
|
||||
findPickOwner,
|
||||
registerPickOwner,
|
||||
unregisterPickOwner,
|
||||
} from '../../data/pickRegistry.js';
|
||||
// Registers the shared `gev-trail:` no-op owner, as the app does.
|
||||
import '../../data/trailRenderer.js';
|
||||
import { getSelectedEntityContext } from '../../data/contextStore.js';
|
||||
|
||||
const NOW = Date.parse('2026-10-28T10:00:00Z');
|
||||
@@ -51,6 +58,7 @@ function fixture(
|
||||
now = () => NOW,
|
||||
quality,
|
||||
pictureCards,
|
||||
hitTestOverlay = () => null,
|
||||
} = {},
|
||||
) {
|
||||
const calls = { feed: [], hotspots: 0, outline: 0 };
|
||||
@@ -141,7 +149,7 @@ function fixture(
|
||||
source,
|
||||
overlayHost,
|
||||
inputFor: () => input,
|
||||
hitTestOverlay: () => null,
|
||||
hitTestOverlay,
|
||||
now,
|
||||
matchMedia: () => ({ matches: reduced }),
|
||||
getViewCentre: () => centre(),
|
||||
@@ -1285,6 +1293,57 @@ test('a click on a marker selects its report, on a beacon chooses its hotspot, o
|
||||
assert.equal(clickHandlers.size, 0);
|
||||
});
|
||||
|
||||
test('a covered news card yields; the top news card acts over a flight trail', async (t) => {
|
||||
let hits = [];
|
||||
const { layer, items, entries, click, flights } = fixture(t, {
|
||||
height: 500_000,
|
||||
hitTestOverlay: (_x, _y, { sourceId } = {}) =>
|
||||
hits.find((hit) => !sourceId || hit.sourceId === sourceId) || null,
|
||||
});
|
||||
layer.enable();
|
||||
await layer.update();
|
||||
await flush();
|
||||
const marker = [...items('points'), ...items('icons')].find((item) =>
|
||||
String(item.id).startsWith('news:report:major~'),
|
||||
);
|
||||
click({ set: 'news:1:points', id: marker.id, surface: false });
|
||||
const card = entries.flat().find((entry) => entry.activate);
|
||||
assert.ok(card, 'an actionable news card was published');
|
||||
let activations = 0;
|
||||
const activate = card.activate;
|
||||
card.activate = () => {
|
||||
activations++;
|
||||
return activate();
|
||||
};
|
||||
hits = [
|
||||
{ sourceId: 'earthquakes', entryId: 'quake:cover' },
|
||||
{ sourceId: 'news', entry: card },
|
||||
];
|
||||
const before = layer.getRowControls().feed;
|
||||
const flightCount = flights.length;
|
||||
click(null);
|
||||
assert.equal(activations, 0, 'a covered news card does not activate');
|
||||
assert.equal(layer.getRowControls().feed.selected.id, 'major');
|
||||
assert.deepEqual(layer.getRowControls().feed.filters, before.filters);
|
||||
assert.equal(flights.length, flightCount);
|
||||
layer.setParams({ clear: true });
|
||||
click({ set: 'news:1:points', id: marker.id, surface: false });
|
||||
assert.equal(layer.getRowControls().feed.selected.id, 'major');
|
||||
hits.shift();
|
||||
click(null);
|
||||
assert.equal(activations, 1, 'the unobscured news card acts once');
|
||||
// A flight trail is registered so every layer reads a click on it as a
|
||||
// no-op (src/data/trailRenderer.js). Under the top news card it must not
|
||||
// make the card dead.
|
||||
assert.equal(findPickOwner('gev-trail:fl-a1b2c3:head'), 'trails');
|
||||
click({
|
||||
set: 'trail:1:lines',
|
||||
id: 'gev-trail:fl-a1b2c3:head',
|
||||
surface: false,
|
||||
});
|
||||
assert.equal(activations, 2, 'the news card acts over a flight trail');
|
||||
});
|
||||
|
||||
test('zoomed out, a hotspot is one beacon; off, nothing draws; destroyed, the sets go', async (t) => {
|
||||
const { layer, items } = fixture(t);
|
||||
assert.deepEqual(items('points'), []);
|
||||
|
||||
@@ -278,10 +278,11 @@ export function createShipwrecksLayer({
|
||||
_clickHandler = clicks.onClick((click) => {
|
||||
if (pointer && !pointer.isPointerFree()) return;
|
||||
const at = click.screenPosition;
|
||||
const cardHit = overlayHost.hitTest?.(at?.x, at?.y, {
|
||||
sourceId: SHIPWRECKS_OVERLAY_SOURCE_ID,
|
||||
});
|
||||
if (cardHit && cardHit.entryId === _selectedCardId) {
|
||||
const cardHit = overlayHost.hitTest?.(at?.x, at?.y);
|
||||
if (
|
||||
cardHit?.sourceId === SHIPWRECKS_OVERLAY_SOURCE_ID &&
|
||||
cardHit.entryId === _selectedCardId
|
||||
) {
|
||||
if (_selectedLink) openExternal(_selectedLink);
|
||||
return;
|
||||
}
|
||||
@@ -299,6 +300,10 @@ export function createShipwrecksLayer({
|
||||
}
|
||||
if (pickId && picking.isOwnedByOtherLayer(SHIPWRECKS_LAYER_ID, pickId))
|
||||
return;
|
||||
// A covered card must neither open its source nor clear the selection.
|
||||
// A marker of ours under that card was already selected by the pick
|
||||
// check before this one.
|
||||
if (cardHit) return;
|
||||
if (_selectedId) {
|
||||
clearSelection();
|
||||
render();
|
||||
|
||||
@@ -36,7 +36,7 @@ function deferred() {
|
||||
return { promise, resolve };
|
||||
}
|
||||
|
||||
function harness({ snapshots, now = () => 1 } = {}) {
|
||||
function harness({ snapshots, now = () => 1, cardHit = () => null } = {}) {
|
||||
const cards = [];
|
||||
const handlers = [];
|
||||
const opened = [];
|
||||
@@ -59,7 +59,7 @@ function harness({ snapshots, now = () => 1 } = {}) {
|
||||
overlayHost: {
|
||||
setEntries: (_source, entries) => cards.push(entries),
|
||||
setVisible() {},
|
||||
hitTest: () => null,
|
||||
hitTest: cardHit,
|
||||
},
|
||||
// The globe's clicks: one listener per click handler installed.
|
||||
input: () => ({
|
||||
@@ -393,3 +393,45 @@ test('the page deadline subtracts the newest available source age from the limit
|
||||
);
|
||||
assert.equal(snapshotDeadline({ sources: both }, 0), 7 * DAY, 'defaults');
|
||||
});
|
||||
|
||||
test('a covered selected card yields while genuine wreck markers still select', async () => {
|
||||
let painted = [];
|
||||
const h = harness({
|
||||
snapshots: [
|
||||
snapshot([
|
||||
wreck('a', { url: 'https://example.com/a' }),
|
||||
wreck('b', { url: 'https://example.com/b' }),
|
||||
]),
|
||||
],
|
||||
cardHit: (_x, _y, { sourceId } = {}) =>
|
||||
painted.find((hit) => !sourceId || hit.sourceId === sourceId) ?? null,
|
||||
});
|
||||
try {
|
||||
h.layer.enable();
|
||||
await h.layer.update();
|
||||
const click = () => h.handlers[0].click({ screenPosition: { x: 1, y: 1 } });
|
||||
h.pick('a');
|
||||
click();
|
||||
const first = h.lastCard()[0];
|
||||
painted = [
|
||||
{ sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' },
|
||||
{ sourceId: 'shipwrecks', entryId: first.id },
|
||||
];
|
||||
h.pick(null);
|
||||
click();
|
||||
assert.deepEqual(h.opened, []);
|
||||
assert.equal(h.lastCard()[0].id, first.id);
|
||||
h.pick('b');
|
||||
click();
|
||||
assert.equal(h.lastCard()[0].id, 'shipwreck-card:b');
|
||||
painted = [{ sourceId: 'shipwrecks', entryId: 'shipwreck-card:b' }];
|
||||
h.pick(null);
|
||||
click();
|
||||
assert.deepEqual(h.opened, ['https://example.com/b']);
|
||||
painted = [];
|
||||
click();
|
||||
assert.deepEqual(h.lastCard(), [], 'bare map still clears the selection');
|
||||
} finally {
|
||||
h.layer.destroy();
|
||||
}
|
||||
});
|
||||
@@ -68,14 +68,12 @@ export function createSelection({
|
||||
? vesselState._vesselOverlayHost.hitTest?.(
|
||||
event.screenPosition?.x,
|
||||
event.screenPosition?.y,
|
||||
{
|
||||
...(cycloneBackground
|
||||
? {}
|
||||
: { sourceId: VESSEL_OVERLAY_SOURCE_ID }),
|
||||
},
|
||||
)
|
||||
: null;
|
||||
if (cycloneBackground && cardHit?.sourceId !== VESSEL_OVERLAY_SOURCE_ID)
|
||||
if (
|
||||
(cardHit && cardHit.sourceId !== VESSEL_OVERLAY_SOURCE_ID) ||
|
||||
(cycloneBackground && !cardHit)
|
||||
)
|
||||
return;
|
||||
if (!record && cardHit) {
|
||||
const id = String(cardHit.entryId || '').startsWith('vessel:')
|
||||
|
||||
@@ -196,8 +196,9 @@ function harness(
|
||||
},
|
||||
setVisible: (id, value) => overlay.visible.set(id, value),
|
||||
clearSource: (id) => overlay.entries.delete(id),
|
||||
hitTest: (_x, _y, { sourceId }) =>
|
||||
cardHit?.sourceId === sourceId ? cardHit : null,
|
||||
// As the host does: unfiltered, the topmost entry.
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
!sourceId || cardHit?.sourceId === sourceId ? cardHit : null,
|
||||
},
|
||||
input: () => ({
|
||||
onClick(fn) {
|
||||
|
||||
@@ -483,17 +483,10 @@ export function createSelection({ state, services, parts }) {
|
||||
if (!state.enabled || services.pointer?.isPointerFree?.() === false)
|
||||
return;
|
||||
const at = click.screenPosition;
|
||||
const hit =
|
||||
overlay?.hitTest?.(at?.x, at?.y, {
|
||||
sourceId: WILDLIFE_SELECTED_SOURCE_ID,
|
||||
}) ||
|
||||
overlay?.hitTest?.(at?.x, at?.y, {
|
||||
sourceId: WILDLIFE_OVERLAY_SOURCE_ID,
|
||||
}) ||
|
||||
overlay?.hitTest?.(at?.x, at?.y, {
|
||||
sourceId: WILDLIFE_LABEL_SOURCE_ID,
|
||||
});
|
||||
if (hit) {
|
||||
// The topmost painted entry decides: our own card or label acts; one
|
||||
// covered by another layer's card does not.
|
||||
const hit = overlay?.hitTest?.(at?.x, at?.y);
|
||||
if (hit && sourceIds.includes(hit.sourceId)) {
|
||||
hit.entry?.activate?.();
|
||||
return;
|
||||
}
|
||||
@@ -516,6 +509,8 @@ export function createSelection({ state, services, parts }) {
|
||||
services.picking?.isOwnedByOtherLayer?.('wildlife-sightings', id)
|
||||
)
|
||||
return;
|
||||
// Another layer's card on top is that layer's click, not empty map.
|
||||
if (hit) return;
|
||||
clearAndRebuild();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ function fixture(sighting = row, extraServices = {}) {
|
||||
const seen = [];
|
||||
const painted = new Set();
|
||||
let hit = null;
|
||||
let coveringHit = null;
|
||||
let projections = 0;
|
||||
let click;
|
||||
const state = {
|
||||
@@ -49,8 +50,12 @@ function fixture(sighting = row, extraServices = {}) {
|
||||
setEntries: (id, value) => entries.set(id, value),
|
||||
clearSource: (id) => entries.delete(id),
|
||||
setVisible() {},
|
||||
hitTest: (_x, _y, { sourceId }) =>
|
||||
hit?.sourceId === sourceId ? hit : null,
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
sourceId
|
||||
? hit?.sourceId === sourceId
|
||||
? hit
|
||||
: null
|
||||
: coveringHit || hit,
|
||||
},
|
||||
now: () => row.observedAt + 60_000,
|
||||
project: (_scene, anchor) => {
|
||||
@@ -94,6 +99,9 @@ function fixture(sighting = row, extraServices = {}) {
|
||||
?.find((entry) => entry.id === entryId);
|
||||
hit = entry ? { sourceId, entryId, entry } : null;
|
||||
},
|
||||
cover(value) {
|
||||
coveringHit = value;
|
||||
},
|
||||
paint(ids) {
|
||||
painted.clear();
|
||||
for (const id of ids) painted.add(id);
|
||||
@@ -179,6 +187,37 @@ test('selected photo and name cards use the selected lane, select on click and n
|
||||
}
|
||||
});
|
||||
|
||||
test('a covered sighting label yields; the top label acts over trails and other scene items', () => {
|
||||
const f = fixture(row, {
|
||||
// Registered owners, as the app has them: an aircraft, and the flight
|
||||
// trails every layer reads as a no-op (src/data/trailRenderer.js).
|
||||
picking: {
|
||||
isOwnedByOtherLayer: (_layer, id) =>
|
||||
id === 'other:aircraft' || String(id).startsWith('gev-trail:'),
|
||||
},
|
||||
});
|
||||
f.selection.install();
|
||||
f.selection.refreshAmbient();
|
||||
f.hit('wildlife-sightings-labels', 'wildlife-sightings-label:inat:123');
|
||||
f.click(null);
|
||||
assert.equal(f.flights.length, 1);
|
||||
f.cover({ sourceId: 'earthquakes', entryId: 'quake:cover' });
|
||||
f.click(null);
|
||||
assert.equal(f.flights.length, 1);
|
||||
assert.equal(f.state.selectedRow, row);
|
||||
f.click();
|
||||
assert.equal(f.flights.length, 2, 'an actual sighting remains selectable');
|
||||
f.cover(null);
|
||||
// The top label acts over a flight trail: never a dead click.
|
||||
f.click('gev-trail:fl-a1b2c3:head');
|
||||
assert.equal(f.flights.length, 3, 'the label acts over a flight trail');
|
||||
// And over another layer's scene item, as on main.
|
||||
f.click('other:aircraft');
|
||||
assert.equal(f.flights.length, 4, 'the top label acts');
|
||||
assert.equal(f.state.selectedRow, row);
|
||||
f.selection.remove();
|
||||
});
|
||||
|
||||
test('nearby duplicate display names yield to painted cards and higher-ranked labels using cached screens', () => {
|
||||
const low = {
|
||||
...row,
|
||||
|
||||
@@ -128,8 +128,10 @@ function fixture(
|
||||
now: () => NOW,
|
||||
overlayHost: {
|
||||
setEntries: (id, entries) => overlays.set(id, entries),
|
||||
hitTest: (_x, _y, { sourceId }) =>
|
||||
hit?.sourceId === sourceId ? hit : null,
|
||||
// As the host does: unfiltered, the topmost entry; filtered, only
|
||||
// an entry of that source.
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
hit && (!sourceId || hit.sourceId === sourceId) ? hit : null,
|
||||
},
|
||||
input: () => ({
|
||||
onClick(fn) {
|
||||
|
||||
Reference in new issue
Block a user