Files
gods-eye-view/src/ui/radioPresentation.playbackError.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

72 lines
1.9 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { setLocale } from '../i18n/index.js';
import { renderRadioState } from './radioPresentation.js';
function el() {
const classes = new Set();
return {
textContent: '',
classList: {
toggle(name, on) {
on ? classes.add(name) : classes.delete(name);
},
contains: (name) => classes.has(name),
},
};
}
function render(audioError) {
globalThis.document = { getElementById: () => null, activeElement: null };
const host = {
destroyed: false,
_radioPanel: el(),
_radioPlaybackState: el(),
_syncContextRadioLauncherState() {},
actions: {
getLifecycle: () => null,
preservePanelStateDuringClear: () => false,
setPanelCollapsed() {},
scheduleLayout() {},
},
};
renderRadioState.call(host, {
enabled: true,
audioState: 'error',
audioError,
filteredCount: 1,
stationCount: 1,
volume: 1,
});
return host._radioPlaybackState.textContent;
}
const PLAYBACK_ERRORS = [
'Playback requires a direct click or tap.',
'Broadcaster stream could not be started.',
'Broadcaster stream is unavailable or blocked by the browser.',
];
for (const locale of ['es', 'ru']) {
test(`radio playback errors are localized in ${locale}`, () => {
setLocale(locale);
try {
for (const message of PLAYBACK_ERRORS) {
assert.notEqual(render(message), message, `${locale}: ${message}`);
}
// Control: the fallback (no audioError) is translated.
assert.notEqual(render(null), 'Broadcaster stream unavailable');
} finally {
setLocale('en');
}
});
}
test('radio playback errors stay English', () => {
setLocale('en');
for (const message of PLAYBACK_ERRORS) {
assert.equal(render(message), message);
}
assert.equal(render(null), 'Broadcaster stream unavailable');
});