Files
gods-eye-view/src/ui/feedErrorI18n.test.mjs
T
German KhokhlovandClaude Opus 5.5 20f4cf3763 i18n: fix the LGTM review findings and tidy the branch texts
- i18n scanner: lastError sink, no false sinks on defaults and ternaries
- shared src/i18n/marker.js for modules that only mark strings
- wind field messages move to wind/fields.js; CITY_POIS imports from cityPois.js
- drop review IDs, change history and stale references from comments and docs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-16 21:00:28 +04:00

70 lines
2.1 KiB
JavaScript

// Flights / Military feed failure texts reach the DATA LAYERS row in the
// UI language; the feeds keep them in English.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { LayerPanel } from './layerPanel.js';
import { setLocale } from '../i18n/index.js';
import { httpError, LiveSourceError } from '../sources/live/contract.js';
const panel = LayerPanel.prototype;
function flightsRow(error) {
return panel._buildMetaText({
id: 'flights',
enabled: true,
stats: {
count: 0,
stale: true,
error,
status: 429,
retryInSec: 45,
source: 'OpenSky',
lastUpdate: Date.now(),
},
});
}
const cases = [
['OpenSky 429 anonymous', 'OpenSky rate limited (anonymous)'],
['OpenSky auth', 'OpenSky auth required'],
['generic 429', httpError({ status: 429 }, 'Flights').message],
['HTTP 503', httpError({ status: 503 }, 'Military aircraft').message],
[
'network error',
new LiveSourceError('unavailable', 'Flights network error').message,
],
['stale snapshot', 'Source snapshot 7 min old'],
['snapshot time unknown', 'Source snapshot time unavailable'],
['non-LiveSourceError', 'Live data unavailable'],
['malformed', 'Malformed OpenSky response'],
['malformed rows', 'Malformed adsb.lol aircraft rows'],
];
test('en: feed failure texts stay English', () => {
setLocale('en');
for (const [, message] of cases)
assert.equal(
flightsRow(message),
`STALE · OpenSky · ${message} · retry 45s`,
);
});
for (const locale of ['es', 'ru']) {
test(`${locale}: feed failure texts are translated in the layer row`, () => {
setLocale(locale);
try {
for (const [name, message] of cases) {
const row = flightsRow(message);
assert.ok(
!row.includes(message),
`${locale} ${name}: row still contains English detail: ${row}`,
);
}
assert.match(flightsRow('Source snapshot 7 min old'), /\b7\b/);
assert.match(flightsRow('Flights HTTP 503'), /\b503\b/);
} finally {
setLocale('en');
}
});
}