Files
gods-eye-view/src/voice/realtimeCostTierStatus.test.mjs
T
Sameh Khamis 1de4f635ca feat(voice): render the voice control from a presenter
createVoiceControl now returns a presenter instead of building the
control with innerHTML: the session, cost, input, card and panel owners
write its state by part and listen for interactions, and VoiceControl.vue
renders it in the command dock, between the location bar and the visual
presets as before. Focus moves wait for the render; the waveform's bars
publish apart from the control and only when they change; the minutes
field keeps a draft until its owner writes it. Owner tests use a real
presenter on their own store, and view tests render the control.
2026-10-31 19:22:03 -07:00

54 lines
1.6 KiB
JavaScript

// The status after a tier switch names the tier in the interface
// language, as the tier button does; the stored tier value stays English.
import test from 'node:test';
import assert from 'node:assert/strict';
import { setLocale, t } from '../i18n/index.js';
import { RealtimeCost } from './realtimeCost.js';
import { createTestVoiceUi } from '../testSupport/voiceUi.mjs';
function harness() {
const ui = createTestVoiceUi();
const statusCalls = [];
const cost = new RealtimeCost({
readUi: () => ui,
readStatus: () => 'listening',
operations: {
isActive: () => true,
isVoiceSessionSettled: () => false,
setStatus: (status, detail) => statusCalls.push(detail),
},
});
return { cost, ui, statusCalls };
}
const EXPECTED = {
en: {
mini: 'MINI applies next session',
standard: 'STANDARD applies next session',
},
ru: {
mini: 'МИНИ — со следующей сессии',
standard: 'СТАНДАРТ — со следующей сессии',
},
es: {
mini: 'MINI desde la próxima sesión',
standard: 'ESTÁNDAR desde la próxima sesión',
},
};
for (const locale of Object.keys(EXPECTED)) {
test(`${locale}: tier status names the tier in the interface language`, (ctx) => {
setLocale(locale);
ctx.after(() => setLocale('en'));
for (const tier of ['mini', 'standard']) {
const { cost, ui, statusCalls } = harness();
assert.equal(cost.setVoiceTier(tier), tier, 'stored tier stays English');
assert.equal(statusCalls.at(-1), EXPECTED[locale][tier]);
assert.equal(
ui.state.tier.text,
tier === 'mini' ? t('MINI') : t('STD'),
);
}
});
}