fix(wildlife): draw what arrived when one sighting source fails

An iNaturalist rejection discarded a successful Acartia reply, and the
antimeridian Promise.all lost both halves when one failed. Each box now
settles independently; the failed part is reported on
sources.inaturalist (error and failed boxes), the layer keeps that
area's last iNaturalist rows and shows DEGRADED with retry timing, and
the update fails outright only when every requested source failed.
This commit is contained in:
Sameh Khamis committed 2026-11-05 16:06:41 -08:00
1 parent 3cb30c3f97
commit 5391687d46
5 files changed
+155 -5

No files matched your search

@@ -1568,6 +1568,47 @@ test('provider credits sit in the layer row, never on the globe; Acartia failure
h.layer.destroy();
});
test('an iNaturalist failure beside a good Acartia reply keeps both and reports degraded', async () => {
let inatHealthy = true;
const acartia = {
...base,
stableId: 'acartia:1',
origin: 'acartia',
iconic: 'Mammalia',
lon: -122.3,
provider: { name: 'Synthetic Provider', entity: null },
};
const failure = Object.assign(new Error('iNaturalist HTTP 502'), {
status: 502,
retryAfterSec: 30,
});
const h = harness({
getSnapshot: async () => [],
getSnapshotDetail: async ({ boxes }) => ({
rows: inatHealthy ? [base, acartia] : [acartia],
sources: {
inaturalist: inatHealthy
? { ok: true }
: { ok: false, error: failure, failedBoxes: boxes },
acartia: { ok: true },
},
}),
});
await h.update();
assert.equal(h.layer.getStats().count, 2);
inatHealthy = false;
await h.update();
// The failed iNaturalist area keeps its last rows; Acartia still refreshes.
assert.equal(h.layer.getStats().count, 2);
assert.equal(h.layer.getStats().error, 'iNaturalist HTTP 502');
assert.equal(layerFeedState(h.layer.getStats()), 'degraded');
assert.equal(
h.layer.getRowControls().info,
'iNaturalist contributors · Acartia 1 (Salish Sea) · licences per record',
);
h.layer.destroy();
});
test('ambient cards prefilter the horizon, spread over screen regions and retain visible slots', async () => {
const rows = Array.from({ length: 32 }, (_, i) => ({
...photographed,