Files
gods-eye-view/src/layers/wind/windUpstreamReason.test.mjs
T
German Khokhlov c079b329d0 Remove the weather and wind imagery fallbacks
Require engine.imagery for weather and wind and load the wind flow backend
from the layer manifest. Preserve Cesium's staging, frame retention, shell
ordering, wind fade and streamlines; Navara follows the same display policy.
Remove obsolete rendering modules and their three translated status keys.
Run every weather and wind display case on both the fake engine and the
headless Cesium engine, keeping the existing behavioural assertions.

Coupling: Cesium import files fall from 27 to 25, viewer lines from 1232 to
1177 and engine-name lines from 63 to 62. The explicit Cesium wind flow
backend deliberately raises renderer lines from 330 to 344 and extension
reads from 8 to 9; every other count stays unchanged.

Browser checks to run
GOOGLE_MAPS_API_KEY= CESIUM_ION_TOKEN= npm run dev -- --port 4291
node scripts/qa-contract-suite.mjs http://localhost:4291
node scripts/qa-weather-compare.mjs shoot http://localhost:4291 --out=qa-shots/weather-after

Compare weather and wind against the previous capture on both engines.
2026-11-07 12:16:27 +04:00

96 lines
2.9 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { createWindLayer, windStats } from './index.js';
import { createFakeEngine } from '../../globe/testing/fakeEngine.js';
import { setLocale, translateKnown } from '../../i18n/index.js';
import { windProxy } from '../../../server/providers/wind.js';
function harness(feed) {
const rendering = Object.fromEntries(
[
'attach',
'start',
'stop',
'clear',
'destroy',
'setField',
'setOptions',
].map((name) => [name, () => {}]),
);
rendering.getDiagnostics = () => ({});
const layer = createWindLayer({
feed,
createNativeRendering: () => rendering,
});
layer.init(null, { engine: createFakeEngine() });
layer.enable();
return layer;
}
async function serverManifestOnUpstreamFailure() {
let handler;
const failing = async () => {
throw new Error('upstream down');
};
windProxy({ models: { gfs: failing, ifs: failing } }).configureServer({
middlewares: { use: (_path, fn) => (handler = fn) },
});
let body = '';
await handler(
{ method: 'GET', url: '/manifest?model=gfs&overlay=none' },
{ writeHead() {}, end: (b) => (body = b), once() {}, removeListener() {} },
);
return JSON.parse(body);
}
test('en: the upstream failure reason reads as before', async () => {
const manifest = await serverManifestOnUpstreamFailure();
const layer = harness({ getSnapshot: async () => manifest });
await layer.update();
assert.equal(
layer.getRowControls().summary.status,
'Wind upstream unavailable',
);
});
for (const locale of ['es', 'ru']) {
test(`${locale}: upstream failure status is shown in the UI language`, async () => {
const manifest = await serverManifestOnUpstreamFailure();
assert.equal(manifest.reason, 'Wind upstream unavailable');
setLocale(locale);
try {
const layer = harness({ getSnapshot: async () => manifest });
await layer.update();
const status = layer.getRowControls().summary.status;
const stats = translateKnown(windStats(manifest).error);
assert.notEqual(status, 'Wind upstream unavailable');
assert.notEqual(stats, 'Wind upstream unavailable');
} finally {
setLocale('en');
}
});
test(`${locale}: a stale cached forecast is reported in the UI language`, async () => {
// Shape the server returns when a cached forecast is kept after a failure.
const manifest = {
model: 'gfs',
grid: { nx: 2, ny: 2 },
cycle: {
runIso: '2026-09-14T12:00:00Z',
validIso: '2026-09-14T18:00:00Z',
},
stale: true,
reason: 'Wind upstream unavailable',
};
setLocale(locale);
try {
const layer = harness({ getSnapshot: async () => manifest });
await layer.update();
const status = layer.getRowControls().summary.status;
assert.doesNotMatch(status, /[A-Za-z]{4,} upstream unavailable/);
} finally {
setLocale('en');
}
});
}