mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Merge main (d49d3d10) into the renderer branch
This commit is contained in:
commit
489c316556
134 files changed
+4980
-229
No files matched your search
@@ -3,6 +3,7 @@ import assert from 'node:assert/strict';
|
||||
import { getLocale, setLocale } from '../../i18n/index.js';
|
||||
import { createModel } from './model.js';
|
||||
import { createQueries } from './queries.js';
|
||||
import { createCards } from './cards.js';
|
||||
|
||||
test('a FIRMS snapshot that ends at a set time names it instead of LIVE', (context) => {
|
||||
const now = 1800000000000;
|
||||
@@ -42,3 +43,60 @@ test('a FIRMS snapshot that ends at a set time names it instead of LIVE', (conte
|
||||
setLocale(previousLocale);
|
||||
}
|
||||
});
|
||||
|
||||
test('fire cards count ages from the end of the window shown, and from now when live', (context) => {
|
||||
const now = Date.UTC(2026, 10, 14, 12);
|
||||
context.mock.method(Date, 'now', () => now);
|
||||
// A window that ended months before now: its newest fire three hours earlier.
|
||||
const at = Date.UTC(2026, 7, 1, 12);
|
||||
const layerState = { _at: at };
|
||||
const model = createModel({ layerState, services: { anchors: {} } });
|
||||
const cell = {
|
||||
count: 4,
|
||||
maxFrp: 210,
|
||||
newestAcqMs: at - 3 * 3_600_000,
|
||||
latCell: 1,
|
||||
lonCell: 2,
|
||||
};
|
||||
const previousLocale = getLocale();
|
||||
try {
|
||||
setLocale('en');
|
||||
assert.equal(model.ageReferenceMs(), at);
|
||||
const card = model.buildCellCard({ cell, position: {} }, model.ageReferenceMs());
|
||||
assert.equal(card.details[0], 'max 210 MW · new 3h', 'not months old');
|
||||
|
||||
// The cards the scene shows use the same time.
|
||||
const entries = [];
|
||||
layerState._viewer = { canvas: { clientWidth: 800, clientHeight: 600 } };
|
||||
layerState._fireByCardId = new Map();
|
||||
layerState._selectedFire = null;
|
||||
layerState._labelCandidates = [{ cell, position: {} }];
|
||||
layerState._labelLodDistance = 0;
|
||||
const { rebuildAmbientLabels } = createCards({
|
||||
layerState,
|
||||
services: {},
|
||||
components: {
|
||||
model,
|
||||
rendering: {
|
||||
scenePorts: () => ({
|
||||
query: { project: () => ({ x: 400, y: 300 }), isOccluded: () => false },
|
||||
}),
|
||||
},
|
||||
},
|
||||
config: { overlayHost: { setEntries: (source, shown) => entries.push(...shown) } },
|
||||
});
|
||||
rebuildAmbientLabels();
|
||||
assert.equal(entries.length, 1);
|
||||
assert.equal(entries[0].details[0], 'max 210 MW · new 3h');
|
||||
|
||||
// Live, they count from now.
|
||||
layerState._at = null;
|
||||
cell.newestAcqMs = now - 5 * 3_600_000;
|
||||
assert.equal(model.ageReferenceMs(), now);
|
||||
entries.length = 0;
|
||||
rebuildAmbientLabels();
|
||||
assert.equal(entries[0].details[0], 'max 210 MW · new 5h');
|
||||
} finally {
|
||||
setLocale(previousLocale);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user