Files
gods-eye-view/src/layers/feedDegradationI18n.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

85 lines
2.6 KiB
JavaScript

// The AIS degradation chip and the traffic "SIMULATED — <reason>" text read in
// the UI language; English keeps its wording.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { setLocale, translateKnown } from '../i18n/index.js';
import { deriveAisFeedError } from '../data/aisLiveVessels.js';
import { createModel } from './traffic/model.js';
test('AIS degraded-feed reasons are localized in es', () => {
setLocale('es');
try {
const cases = [
[
{ status: 'down', reconnectAttempt: 3 },
'feed down — retrying slowly (attempt 3)',
],
[{ status: 'missing-key' }, 'AISSTREAM_API_KEY not set'],
[
{ status: 'stale', silentForMs: 90000 },
'feed silent 90s — no AIS data',
],
[{ status: 'auth-failed' }, 'API key rejected — check AISSTREAM_API_KEY'],
[{ status: 'connecting' }, 'connecting to feed…'],
[{ status: 'closed' }, 'feed disconnected'],
];
for (const [payload, english] of cases) {
// The layer panel runs stats.error through translateKnown(); emulate it.
const shown = translateKnown(deriveAisFeedError(payload, 0));
assert.notEqual(shown, english, `status ${payload.status} still English`);
}
} finally {
setLocale('en');
}
});
test('traffic "SIMULATED — <reason>" is localized in es', () => {
setLocale('es');
try {
const { trafficFeedPresentation } = createModel({
state: {},
services: {},
parts: {},
source: {},
});
const degraded = trafficFeedPresentation({
liveMode: true,
flowError: 'TomTom daily budget reached',
});
const shown = translateKnown(degraded.error);
assert.notEqual(shown, 'SIMULATED — TomTom daily budget reached');
assert.ok(!shown.startsWith('SIMULATED'), `still English: ${shown}`);
} finally {
setLocale('en');
}
});
test('English degraded-feed wording is unchanged', () => {
setLocale('en');
assert.equal(
deriveAisFeedError({ status: 'down', reconnectAttempt: 3 }, 0),
'feed down — retrying slowly (attempt 3)',
);
assert.equal(
deriveAisFeedError({ status: 'reconnecting' }, 0),
'reconnecting to feed…',
);
assert.equal(
deriveAisFeedError({ status: 'missing-key' }, 0),
'AISSTREAM_API_KEY not set',
);
const { trafficFeedPresentation } = createModel({
state: {},
services: {},
parts: {},
source: {},
});
assert.equal(
trafficFeedPresentation({
liveMode: true,
flowError: 'TomTom daily budget reached',
}).error,
'SIMULATED — TomTom daily budget reached',
);
});