mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
Main brings the reviewed one-time-control and timeline-mark changes. They keep this branch's renderer work: earthquakes draw through the draw port and register their strong quakes as marks; the weather clock keeps `follows` beside `world`; the weather layer measures ages and delays from the timeline time; the Visual panel keeps its sky and weather groups under Effects. Tests that moved time through the weather clock now move it on the world clock.
This commit is contained in:
commit
0ecbfbecd0
123 files changed
+5917
-1471
No files matched your search
+311
-106
@@ -1,8 +1,9 @@
|
||||
import test from 'node:test';
|
||||
import test, { afterEach } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createWeatherRendering, READY_WAKE_MS } from './rendering.js';
|
||||
import { createWeatherLayer } from './index.js';
|
||||
import { createWeatherClock } from './clock.js';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { Color, ImageryLayerCollection, GeographicTilingScheme } from 'cesium';
|
||||
import { NO_IMAGERY_HOST } from './imageryHost.js';
|
||||
@@ -41,6 +42,16 @@ const deferred = () => {
|
||||
const flush = async () => {
|
||||
for (let i = 0; i < 30; i++) await Promise.resolve();
|
||||
};
|
||||
// Time moves on the world clock the weather clock follows, as the timeline
|
||||
// moves it.
|
||||
const seekTo = (clock, time) => {
|
||||
clock.world.seek(Date.parse(time));
|
||||
return flush();
|
||||
};
|
||||
const goLive = (clock) => {
|
||||
clock.world.goLive();
|
||||
return flush();
|
||||
};
|
||||
function event() {
|
||||
const listeners = new Set();
|
||||
return {
|
||||
@@ -557,12 +568,22 @@ test('failed and timed-out stages retain the previous observation; a healthy rep
|
||||
h.rendering.clear();
|
||||
});
|
||||
|
||||
// A layer built without a clock keeps its own on the page's world clock:
|
||||
// each test leaves that clock live, with no layer of its own on it.
|
||||
const harnessed = new Set();
|
||||
afterEach(() => {
|
||||
for (const layer of harnessed) layer.destroy();
|
||||
harnessed.clear();
|
||||
worldClock.goLive();
|
||||
worldClock.setRate(1);
|
||||
});
|
||||
function layerHarness({
|
||||
clock,
|
||||
reducedMotion = false,
|
||||
feed,
|
||||
id,
|
||||
eventTarget = target(),
|
||||
enable = true,
|
||||
} = {}) {
|
||||
const stages = [];
|
||||
const motion = target({ matches: reducedMotion });
|
||||
@@ -637,7 +658,8 @@ function layerHarness({
|
||||
createRendering: () => rendering,
|
||||
});
|
||||
layer.init(viewer);
|
||||
layer.enable();
|
||||
if (enable) layer.enable();
|
||||
harnessed.add(layer);
|
||||
return {
|
||||
layer,
|
||||
rendering,
|
||||
@@ -651,72 +673,189 @@ function layerHarness({
|
||||
};
|
||||
}
|
||||
|
||||
test('history has one owned timer, stops while hidden, and releases all work on disable/destroy', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
test('without a clock the layer keeps one of its own on the world clock and lets it go on destroy', async () => {
|
||||
const h = layerHarness();
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
assert.equal(worldClock.follows('weather-radar'), true);
|
||||
// The frames span the timeline's time; they are not marks on it.
|
||||
assert.deepEqual(worldClock.coverage(), {
|
||||
start: Date.parse(times[0]),
|
||||
end: Date.parse(times.at(-1)),
|
||||
marks: [],
|
||||
markDetails: [],
|
||||
});
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, true);
|
||||
t.mock.timers.tick(2000);
|
||||
assert.equal(h.stages.length, 2);
|
||||
assert.equal(
|
||||
h.layer.getDiagnostics().timerActive,
|
||||
false,
|
||||
'next timer waits for stage settlement',
|
||||
);
|
||||
h.stages[1].finish();
|
||||
await flush();
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, true);
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.equal(worldClock.getState().stepping, false);
|
||||
assert.equal(h.layer.getDiagnostics().playing, true);
|
||||
h.documentRef.hidden = true;
|
||||
h.documentRef.emit('visibilitychange');
|
||||
assert.equal(h.layer.getDiagnostics().playing, false);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
t.mock.timers.tick(20_000);
|
||||
assert.equal(h.stages.length, 2);
|
||||
await flush();
|
||||
assert.equal(worldClock.isPlaying(), true, 'hiding suspends the layer only');
|
||||
h.documentRef.hidden = false;
|
||||
h.documentRef.emit('visibilitychange');
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
h.layer.disable();
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
assert.equal(h.layer.getDiagnostics().historyFrames, 0);
|
||||
t.mock.timers.tick(20_000);
|
||||
assert.equal(h.stages.length, 2);
|
||||
h.layer.destroy();
|
||||
assert.equal(worldClock.follows('weather-radar'), false);
|
||||
assert.equal(h.documentRef.size, 0);
|
||||
assert.equal(h.motion.size, 0);
|
||||
assert.equal(h.moveEnd.size, 0);
|
||||
assert.ok(h.clears() >= 1);
|
||||
});
|
||||
|
||||
test('reduced motion blocks autoplay but permits manual history and stops newly suspended playback', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
test('a layer without a clock leaves the world clock alone until enabled, and never sends it live', async (t) => {
|
||||
const past = Date.parse(times[0]) - 3_600_000;
|
||||
worldClock.seek(past);
|
||||
const subscribe = t.mock.method(worldClock, 'subscribe');
|
||||
const gate = t.mock.method(worldClock, 'gate');
|
||||
const h = layerHarness({ enable: false });
|
||||
h.layer.getRowControls();
|
||||
h.layer.getDiagnostics();
|
||||
h.layer.setParams({ play: true, step: -1 });
|
||||
assert.equal(subscribe.mock.callCount(), 0, 'off, no clock is built');
|
||||
assert.equal(gate.mock.callCount(), 0);
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
h.layer.destroy();
|
||||
harnessed.delete(h.layer);
|
||||
assert.equal(worldClock.now(), past, 'never on, the world is where it was');
|
||||
assert.equal(worldClock.isLive(), false);
|
||||
|
||||
const on = layerHarness({ enable: false });
|
||||
on.layer.enable();
|
||||
assert.equal(subscribe.mock.callCount(), 1, 'built on first enable');
|
||||
const update = on.layer.update();
|
||||
await flush();
|
||||
on.stages.at(-1)?.finish();
|
||||
await update;
|
||||
on.layer.disable();
|
||||
on.layer.enable();
|
||||
assert.equal(subscribe.mock.callCount(), 1, 'built once');
|
||||
on.layer.destroy();
|
||||
harnessed.delete(on.layer);
|
||||
assert.equal(
|
||||
worldClock.isLive(),
|
||||
false,
|
||||
'its own clock does not send it live',
|
||||
);
|
||||
assert.equal(worldClock.now(), past);
|
||||
});
|
||||
|
||||
test('destroyed, a layer without a clock stays off: enabling it builds no clock', (t) => {
|
||||
const subscribe = t.mock.method(worldClock, 'subscribe');
|
||||
const h = layerHarness();
|
||||
assert.equal(subscribe.mock.callCount(), 1, 'its clock, built on enable');
|
||||
h.layer.destroy();
|
||||
harnessed.delete(h.layer);
|
||||
h.layer.enable();
|
||||
assert.equal(subscribe.mock.callCount(), 1, 'no clock built after destroy');
|
||||
assert.equal(worldClock.follows('weather-radar'), false);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
});
|
||||
|
||||
test('with no frames yet there is no timeline, and a row plays nothing', () => {
|
||||
worldClock.setRate(604_800);
|
||||
const h = layerHarness({
|
||||
feed: { getSnapshot: () => new Promise(() => {}) },
|
||||
});
|
||||
void h.layer.update();
|
||||
assert.equal(worldClock.coverage(), null);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isLive(), true);
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
});
|
||||
|
||||
test('a row plays at the speed the world clock keeps, from the start at the end of the covered time', async () => {
|
||||
const h = layerHarness();
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
// A speed chosen on the timeline, while live.
|
||||
worldClock.setRate(3_600);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.equal(worldClock.getRate(), 3_600, 'played at the speed chosen');
|
||||
assert.ok(
|
||||
worldClock.now() - Date.parse(times[0]) < 3_600_000,
|
||||
'live, play starts at the start of the covered time',
|
||||
);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
// Paused at the end of the covered time (it reaches to now), play starts
|
||||
// again from the start, as the timeline's does.
|
||||
worldClock.seek(worldClock.wallNow() + 1_000);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.ok(worldClock.now() - Date.parse(times[0]) < 3_600_000);
|
||||
assert.equal(worldClock.getRate(), 3_600);
|
||||
worldClock.pause();
|
||||
});
|
||||
|
||||
test('reduced motion offers no play; steps still move the world clock from frame to frame', async () => {
|
||||
const h = layerHarness({ reducedMotion: true });
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
assert.equal(
|
||||
h.layer.getRowControls().chips.some((chip) => chip.id === 'play'),
|
||||
false,
|
||||
);
|
||||
h.layer.setParams({ step: -1 });
|
||||
assert.equal(h.stages[1].time, times[1]);
|
||||
h.stages[1].finish();
|
||||
await flush();
|
||||
h.motion.matches = false;
|
||||
h.motion.emit('change');
|
||||
// Play, which the row does not offer, does nothing while it is suspended.
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(h.layer.getDiagnostics().playing, true);
|
||||
h.motion.matches = true;
|
||||
h.motion.emit('change');
|
||||
assert.equal(h.layer.getDiagnostics().playing, false);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
h.layer.destroy();
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
assert.equal(worldClock.isLive(), true);
|
||||
// A step back from live goes to the newest frame, and the next one back
|
||||
// to the frame before it.
|
||||
h.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(worldClock.now(), Date.parse(times[2]));
|
||||
h.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(worldClock.now(), Date.parse(times[1]));
|
||||
assert.equal(h.stages.at(-1).time, times[1]);
|
||||
});
|
||||
|
||||
test('a row steps forward and plays from a past time through the world clock', async () => {
|
||||
const h = layerHarness();
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
worldClock.seek(Date.parse(times[0]));
|
||||
await flush();
|
||||
h.layer.setParams({ step: 1 });
|
||||
assert.equal(worldClock.now(), Date.parse(times[1]));
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
await flush();
|
||||
assert.equal(h.stages.at(-1).time, times[1]);
|
||||
h.layer.setParams({ step: 1 });
|
||||
assert.equal(worldClock.now(), Date.parse(times[2]));
|
||||
h.layer.setParams({ step: 1 });
|
||||
assert.equal(
|
||||
worldClock.now(),
|
||||
Date.parse(times[2]),
|
||||
'no frame after the newest',
|
||||
);
|
||||
worldClock.seek(Date.parse(times[1]));
|
||||
await flush();
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.equal(worldClock.getState().stepping, false);
|
||||
assert.ok(
|
||||
worldClock.now() - Date.parse(times[1]) < 1_000,
|
||||
'away from live, play goes on from the time shown',
|
||||
);
|
||||
h.layer.setParams({ step: 1 });
|
||||
assert.equal(worldClock.isPlaying(), false, 'a step holds play');
|
||||
assert.equal(worldClock.now(), Date.parse(times[2]));
|
||||
});
|
||||
|
||||
test('disable invalidates an abort-insensitive source result and an already staged frame', async (t) => {
|
||||
@@ -745,7 +884,6 @@ test('disable invalidates an abort-insensitive source result and an already stag
|
||||
await next;
|
||||
await flush();
|
||||
assert.equal(h.layer.getStats().count, 0);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
assert.equal(h.layer.getStats().loading, false);
|
||||
h.layer.destroy();
|
||||
});
|
||||
@@ -804,7 +942,6 @@ test('update cancellation reaches imagery after source acquisition has completed
|
||||
assert.equal(h.stages[0].signal.aborted, true);
|
||||
assert.equal(h.layer.getStats().count, 0);
|
||||
assert.equal(h.layer.getStats().loading, false);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
h.layer.destroy();
|
||||
});
|
||||
|
||||
@@ -912,21 +1049,22 @@ test('coverage navigation requires the shared shell handoff and detaches cleanly
|
||||
h.layer.destroy();
|
||||
});
|
||||
|
||||
test('manifest refresh during a manual history stage does not strand loading controls', async () => {
|
||||
test('manifest refresh during a history stage restages the same time and does not strand loading controls', async () => {
|
||||
const h = layerHarness();
|
||||
const first = h.layer.update();
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await first;
|
||||
h.layer.setParams({ step: -1 });
|
||||
worldClock.seek(Date.parse(times[1]));
|
||||
await flush();
|
||||
assert.equal(h.layer.getStats().loading, true);
|
||||
await h.layer.update();
|
||||
assert.equal(
|
||||
h.stages.length,
|
||||
2,
|
||||
'metadata refresh preserves the staged manual selection',
|
||||
);
|
||||
h.stages[1].finish();
|
||||
const refreshed = h.layer.update();
|
||||
await flush();
|
||||
assert.equal(h.stages.length, 3);
|
||||
assert.equal(h.stages[1].signal.aborted, true);
|
||||
assert.equal(h.stages[2].time, times[1], 'the refresh keeps the time');
|
||||
h.stages[2].finish();
|
||||
await refreshed;
|
||||
await flush();
|
||||
assert.equal(h.layer.getStats().loading, false);
|
||||
assert.equal(h.layer.getStats().observedAt, times[1]);
|
||||
@@ -956,7 +1094,8 @@ test('historical observations do not relabel a fresh lightning feed as stale', a
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await first;
|
||||
h.layer.setParams({ step: -1 });
|
||||
worldClock.seek(Date.parse(old));
|
||||
await flush();
|
||||
h.stages[1].finish();
|
||||
await flush();
|
||||
assert.equal(h.layer.getStats().stale, false);
|
||||
@@ -1313,8 +1452,7 @@ test('404 fails a frame without retry', async () => {
|
||||
h.rendering.clear();
|
||||
});
|
||||
|
||||
test('no host pauses history, refreshes metadata, and restores retained time and playback', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
test('no host holds the shown history frame, refreshes metadata, and restores the retained time', async () => {
|
||||
let refreshes = 0;
|
||||
const h = layerHarness({
|
||||
feed: {
|
||||
@@ -1330,28 +1468,23 @@ test('no host pauses history, refreshes metadata, and restores retained time and
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
h.layer.setParams({ play: true });
|
||||
t.mock.timers.tick(2000);
|
||||
worldClock.seek(Date.parse(times[0]));
|
||||
await flush();
|
||||
assert.equal(h.stages.length, 2);
|
||||
h.stages[1].finish();
|
||||
await flush();
|
||||
host = { collection: null, kind: 'none' };
|
||||
h.eventTarget.emit('gev:map-stack-changed');
|
||||
await flush();
|
||||
assert.equal(h.layer.getDiagnostics().playing, false);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
assert.equal(h.layer.getRowControls().summary.status, NO_IMAGERY_HOST);
|
||||
assert.equal(h.layer.getRowControls().info, NO_IMAGERY_HOST);
|
||||
await h.layer.update();
|
||||
assert.equal(refreshes, 2);
|
||||
t.mock.timers.tick(10_000);
|
||||
assert.equal(h.stages.length, 2);
|
||||
assert.equal(h.layer.getDiagnostics().time, times[2]);
|
||||
assert.equal(h.stages.length, 2, 'nothing stages without a host');
|
||||
host = { collection: {}, kind: 'globe' };
|
||||
h.eventTarget.emit('gev:map-stack-changed');
|
||||
assert.equal(h.layer.getDiagnostics().playing, true);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, true);
|
||||
t.mock.timers.tick(2000);
|
||||
assert.equal(h.stages.length, 3);
|
||||
assert.equal(h.stages[2].time, times[0]);
|
||||
await flush();
|
||||
assert.equal(h.stages.at(-1).time, times[0], 'the retained time restages');
|
||||
h.layer.destroy();
|
||||
assert.equal(h.eventTarget.size, 0);
|
||||
});
|
||||
@@ -1465,25 +1598,21 @@ for (const [id, product] of [
|
||||
const [shell] = h.shells();
|
||||
assert.equal(shell.show, true);
|
||||
|
||||
layer.setParams({ play: true });
|
||||
t.mock.timers.tick(2000);
|
||||
worldClock.seek(Date.parse(times[0]));
|
||||
await flush();
|
||||
assert.equal(
|
||||
layer.getDiagnostics().time,
|
||||
times[0],
|
||||
'history advances at street level',
|
||||
'history moves at street level',
|
||||
);
|
||||
camera.positionCartographic.height = 59_999;
|
||||
camera.moveEnd.emit();
|
||||
assert.equal(shell.show, true, 'no height gate');
|
||||
assert.equal(layer.getDiagnostics().playing, true);
|
||||
assert.equal(layer.getDiagnostics().timerActive, true);
|
||||
|
||||
host = { collection: null, kind: 'none' };
|
||||
events.emit('gev:map-stack-changed');
|
||||
assert.equal(shell.show, false);
|
||||
assert.equal(layer.getRowControls().summary.status, NO_IMAGERY_HOST);
|
||||
assert.equal(layer.getDiagnostics().timerActive, false);
|
||||
host = { collection: h.viewer.imageryLayers, kind: 'globe' };
|
||||
events.emit('gev:map-stack-changed');
|
||||
assert.equal(shell.destroyed, true);
|
||||
@@ -1675,10 +1804,12 @@ test('satellite mode chips restage history without changing time or latest-follo
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
h.layer.setParams({ step: -1 });
|
||||
worldClock.seek(Date.parse(times[1]));
|
||||
await flush();
|
||||
h.stages[1].finish();
|
||||
await flush();
|
||||
h.layer.setParams({ infrared: 'full' });
|
||||
await flush();
|
||||
assert.equal(h.stages[2].time, times[1]);
|
||||
assert.equal(h.stages[2].infrared, 0);
|
||||
assert.equal(h.layer.getParams().infrared, 0);
|
||||
@@ -1802,7 +1933,7 @@ test('a delayed installation failure retains the replacement and does not throw
|
||||
h.rendering.clear();
|
||||
});
|
||||
|
||||
test('one row steps every registered observation; missing frames hide and latest restores each product', async (t) => {
|
||||
test('a row steps the world clock through every registered observation; missing frames hide and latest goes live', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
const radar = layerHarness({ clock });
|
||||
const satellite = layerHarness({
|
||||
@@ -1835,6 +1966,14 @@ test('one row steps every registered observation; missing frames hide and latest
|
||||
.chips.filter(({ id }) =>
|
||||
['previous', 'play', 'next', 'latest'].includes(id),
|
||||
);
|
||||
// A step back from live goes to the newest frame, and the next one back
|
||||
// to the frame before it.
|
||||
radar.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(clock.getState().target, times[2]);
|
||||
assert.equal(clock.world.isPlaying(), false);
|
||||
for (const h of [radar, satellite]) h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
radar.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(clock.getState().target, times[1]);
|
||||
@@ -1886,6 +2025,33 @@ test('one row steps every registered observation; missing frames hide and latest
|
||||
assert.equal(clock.getState().products.length, 1);
|
||||
});
|
||||
|
||||
test('a row’s play and latest move the world clock as its timeline does', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
const { world } = clock;
|
||||
const h = layerHarness({ clock });
|
||||
t.after(() => {
|
||||
h.layer.destroy();
|
||||
clock.destroy();
|
||||
});
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await update;
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(world.isPlaying(), true);
|
||||
assert.equal(world.getState().stepping, false, 'the world plays on its own');
|
||||
assert.ok(
|
||||
world.now() - Date.parse(times[0]) < 1_000,
|
||||
'from the start when live',
|
||||
);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(world.isPlaying(), false);
|
||||
h.layer.setParams({ latest: true });
|
||||
assert.equal(world.isLive(), true);
|
||||
await flush();
|
||||
assert.equal(clock.getState().mode, 'latest');
|
||||
});
|
||||
|
||||
test('history manifest expiry hides imagery without jumping to latest; host resume keeps the target', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
let value = snapshot;
|
||||
@@ -1898,7 +2064,7 @@ test('history manifest expiry hides imagery without jumping to latest; host resu
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await update;
|
||||
const history = clock.setTarget(times[0]);
|
||||
const history = seekTo(clock, times[0]);
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await history;
|
||||
@@ -1967,7 +2133,7 @@ test('satellite global selection uses the three-hour gap and preserves the share
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await update;
|
||||
await clock.setTarget(times[0]);
|
||||
await seekTo(clock, times[0]);
|
||||
assert.equal(
|
||||
h.layer.getDiagnostics().hidden,
|
||||
true,
|
||||
@@ -2026,7 +2192,8 @@ test('satellite clouds from an hourly feed draw all through each hour and read l
|
||||
);
|
||||
|
||||
// Forty-five minutes past a frame, between it and the next, it still shows.
|
||||
const between = clock.setTarget(
|
||||
const between = seekTo(
|
||||
clock,
|
||||
new Date(Date.parse(hourly[0]) + 45 * 60_000).toISOString(),
|
||||
);
|
||||
await flush();
|
||||
@@ -2037,7 +2204,7 @@ test('satellite clouds from an hourly feed draw all through each hour and read l
|
||||
|
||||
// Live again (a past time judges delay from the timeline's time), past
|
||||
// one and a half hours it reads late.
|
||||
const live = clock.latest();
|
||||
const live = goLive(clock);
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await live;
|
||||
@@ -2059,11 +2226,11 @@ test('switching to history cancels a still-loading latest refresh and a later ta
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
const latest = h.stages.at(-1);
|
||||
const oldHistory = clock.setTarget(times[0]);
|
||||
const oldHistory = seekTo(clock, times[0]);
|
||||
await flush();
|
||||
assert.equal(latest.signal.aborted, true);
|
||||
const oldStage = h.stages.at(-1);
|
||||
const current = clock.setTarget(times[1]);
|
||||
const current = seekTo(clock, times[1]);
|
||||
await flush();
|
||||
assert.equal(oldStage.signal.aborted, true);
|
||||
h.stages.at(-1).finish();
|
||||
@@ -2373,8 +2540,9 @@ test('failed prefetch leaves the current frame and errors unchanged and releases
|
||||
assert.deepEqual(h.rendering.getDiagnostics(), before);
|
||||
});
|
||||
|
||||
test('layer warms the next advertised observation only after a successful playing frame, wrapping at the end', async (t) => {
|
||||
test('as the world plays, the layer warms the next advertised observation after each frame that shows', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
const { world } = clock;
|
||||
const h = layerHarness({ clock });
|
||||
const warmed = [];
|
||||
let cancels = 0;
|
||||
@@ -2392,45 +2560,45 @@ test('layer warms the next advertised observation only after a successful playin
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await updated;
|
||||
assert.equal(warmed.length, 0);
|
||||
const play = clock.play();
|
||||
await seekTo(clock, times[0]);
|
||||
h.stages.at(-1).finish();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 0, 'paused, nothing is warmed');
|
||||
world.play({ rate: 1e-9, continuous: true });
|
||||
assert.equal(clock.getState().advancing, true);
|
||||
await seekTo(clock, times[1]);
|
||||
assert.equal(warmed.length, 0, 'still staging');
|
||||
h.stages.at(-1).finish();
|
||||
await play;
|
||||
await flush();
|
||||
assert.deepEqual(
|
||||
warmed.map(({ time }) => time),
|
||||
[times[0]],
|
||||
[times[2]],
|
||||
);
|
||||
assert.deepEqual(warmed[0].options, { infrared: 100 });
|
||||
const next = clock.setTarget(times[0]);
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await next;
|
||||
assert.deepEqual(
|
||||
warmed.map(({ time }) => time),
|
||||
[times[0], times[1]],
|
||||
);
|
||||
const failed = clock.setTarget(times[1]);
|
||||
await flush();
|
||||
await seekTo(clock, times[0]);
|
||||
h.stages.at(-1).finish(false);
|
||||
await failed;
|
||||
assert.equal(warmed.length, 2);
|
||||
const priorCancels = cancels;
|
||||
clock.pause();
|
||||
assert.ok(cancels > priorCancels);
|
||||
const paused = clock.setTarget(times[2]);
|
||||
await flush();
|
||||
assert.equal(warmed.length, 1, 'a failed frame warms nothing');
|
||||
await seekTo(clock, times[2]);
|
||||
h.stages.at(-1).finish();
|
||||
await paused;
|
||||
assert.equal(warmed.length, 2);
|
||||
await clock.play();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 1, 'the world plays on past the newest frame');
|
||||
const priorCancels = cancels;
|
||||
world.pause();
|
||||
await flush();
|
||||
assert.ok(cancels > priorCancels);
|
||||
await seekTo(clock, times[1]);
|
||||
h.stages.at(-1).finish();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 1);
|
||||
world.play({ rate: 1e-9, continuous: true });
|
||||
h.documentRef.hidden = true;
|
||||
h.documentRef.emit('visibilitychange');
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 2, 'hidden products do not prefetch');
|
||||
assert.equal(warmed.length, 1, 'hidden products do not prefetch');
|
||||
world.goLive();
|
||||
});
|
||||
|
||||
for (const product of ['radar', 'clouds-regional', 'lightning']) {
|
||||
@@ -2767,7 +2935,7 @@ test('at a past time a frame is aged and its source judged delayed from the time
|
||||
|
||||
// Years later, the world clock is moved back to the newest frame.
|
||||
Date.now.mock.mockImplementation(() => Date.parse('2032-01-01T00:00:00Z'));
|
||||
void clock.setTarget(times[2]);
|
||||
void seekTo(clock, times[2]);
|
||||
await flush();
|
||||
h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
@@ -2778,10 +2946,47 @@ test('at a past time a frame is aged and its source judged delayed from the time
|
||||
assert.equal(h.layer.getStats().stale, false);
|
||||
|
||||
// Ten minutes after the newest frame, the frame is ten minutes old.
|
||||
void clock.setTarget('2026-09-15T20:20:00.000Z');
|
||||
void seekTo(clock, '2026-09-15T20:20:00.000Z');
|
||||
await flush();
|
||||
h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
assert.match(h.layer.getRowControls().summary.detail, /10m ago · nearest/);
|
||||
assert.equal(h.layer.getRowControls().summary.status, null);
|
||||
});
|
||||
|
||||
test('a feed names the source behind each product, before any manifest does', (t) => {
|
||||
t.mock.method(console, 'warn', () => {});
|
||||
const quiet = {
|
||||
documentRef: target({ hidden: false }),
|
||||
eventTarget: target(),
|
||||
matchMedia: () => target({ matches: false }),
|
||||
};
|
||||
const asked = [];
|
||||
const feed = {
|
||||
getSnapshot: async () => snapshot,
|
||||
sourceName(kind) {
|
||||
asked.push(kind);
|
||||
if (kind === 'satellite') throw new Error('no name');
|
||||
return kind === 'radar' ? ' NOAA MRMS ' : 'NOAA\u200b GLM';
|
||||
},
|
||||
};
|
||||
const radar = createWeatherLayer({ ...quiet, feed, id: 'weather-radar' });
|
||||
assert.equal(radar.source, 'NOAA MRMS');
|
||||
const stats = radar.getStats();
|
||||
assert.equal(stats.source, 'NOAA MRMS');
|
||||
assert.equal(stats.sourceVerbatim, true);
|
||||
// A name a manifest could not carry, or a failing call, leaves nowCOAST, as
|
||||
// does a feed with no names.
|
||||
for (const id of ['weather-lightning', 'weather-satellite']) {
|
||||
const layer = createWeatherLayer({ ...quiet, feed, id });
|
||||
assert.equal(layer.source, 'NOAA nowCOAST · OBSERVED', id);
|
||||
assert.equal(layer.getStats().source, 'NOAA nowCOAST', id);
|
||||
assert.equal(layer.getStats().sourceVerbatim, undefined, id);
|
||||
}
|
||||
assert.deepEqual(asked, ['radar', 'lightning', 'satellite']);
|
||||
const unnamed = createWeatherLayer({
|
||||
...quiet,
|
||||
feed: { getSnapshot: async () => snapshot },
|
||||
});
|
||||
assert.equal(unnamed.source, 'NOAA nowCOAST · OBSERVED');
|
||||
});
|
||||
Reference in new issue
Block a user