fix(cyclones): cards leave the map with their storms; null advisory values are left out

The world overlay drew on desynchronized 2D contexts. After a frame that
only clears, Chrome could present an earlier buffer, so storm cards and
forecast lead-hour labels stayed on screen when a snapshot without storms
(or an unavailable one) replaced them, although the overlay held no entries
and cleared every frame. Both overlay surfaces now use ordinary contexts.

The storm readout no longer prints "Unavailable" for a null value: an
advisory without pressure shows only its maximum sustained wind, one
without wind only its pressure, and one without either has no intensity
line. The advisory link stays hidden when an advisory has no link.
This commit is contained in:
Sameh Khamis committed 2026-11-14 16:56:09 -08:00
1 parent 9b8f45e62b
commit 7b4b4d4184
17 files changed
+128 -16

No files matched your search

+25 -1
View File
@@ -110,6 +110,7 @@ function installMockEnvironment({
} = {}) {
const byId = new Map();
const paintTrace = [];
const contextRequests = [];
const ctx = mockContext('shared', paintTrace);
const detectionCtx = mockContext('detection', paintTrace);
const layoutReads = { canvasWidth: 0, canvasHeight: 0, boundingClientRect: 0 };
@@ -184,8 +185,9 @@ function installMockEnvironment({
return this._rect;
}
getContext() {
getContext(type, options) {
if (this.tagName !== 'CANVAS') return null;
contextRequests.push({ id: this.id, type, options });
return this.id === 'world-overlay-detection-surface' ? detectionCtx : ctx;
}
@@ -400,6 +402,7 @@ function installMockEnvironment({
ctx,
detectionCtx,
paintTrace,
contextRequests,
document,
window,
postRender,
@@ -2623,3 +2626,24 @@ test('the queued-card index stays bounded while card identities churn', () => {
env.cleanup();
}
});
test('both overlay surfaces draw on synchronized 2D contexts', () => {
// A desynchronized context can show an earlier buffer after a frame that
// only clears: a card removed from its source stayed on screen until
// something painted over it.
const env = installMockEnvironment();
try {
initWorldOverlay(env.viewer);
const ids = env.contextRequests.map((request) => request.id).sort();
assert.deepEqual(ids, [
'world-overlay-canvas',
'world-overlay-detection-surface',
]);
for (const request of env.contextRequests) {
assert.equal(request.type, '2d');
assert.notEqual(request.options?.desynchronized, true, request.id);
}
} finally {
env.cleanup();
}
});