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

67 lines
2.5 KiB
JavaScript

// Every status line of the ChatGPT OAuth flow in Provider Settings goes
// through t(), and the i18n check treats say() as a place UI text lands.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import {
extractMessages,
readCatalog,
shippedLocales,
unmarkedScript,
} from '../scripts/i18n.mjs';
// Status-line texts of the ChatGPT OAuth flow in Provider Settings
// (src/keySetup.js, handler of [data-cloud-voice-auth-toggle]).
const OAUTH_STATUS_TEXTS = [
'Cloud voice will use OPENAI_API_KEY on the next session.',
'Checking local ChatGPT OAuth sign-in…',
'ChatGPT OAuth selected for cloud voice. Your API key stays saved and available.',
'ChatGPT sign-in expired. Opening sign-in again…',
'Opening ChatGPT sign-in in your browser…',
'Finish ChatGPT sign-in in the browser. Waiting for it to complete…',
'ChatGPT sign-in timed out. Click {button} to try again.',
'OAuth check failed: {detail}',
'Could not check ChatGPT sign-in.',
'Could not check ChatGPT sign-in. Try again.',
'Could not start ChatGPT sign-in on this machine.',
'ChatGPT sign-in complete. OAuth will be used for the next cloud voice session.',
];
test('OAuth status-line texts are extractable messages with es/ru entries', () => {
const messages = extractMessages();
const missing = OAUTH_STATUS_TEXTS.filter((text) => !messages.has(text));
assert.deepEqual(missing, [], 'texts not wrapped in t() in src/keySetup.js');
for (const locale of shippedLocales()) {
const catalog = readCatalog(locale);
const untranslated = OAUTH_STATUS_TEXTS.filter((text) => !catalog[text]);
assert.deepEqual(untranslated, [], `${locale}.json lacks entries`);
}
});
test('the i18n check sees an unmarked literal passed to say()', () => {
const sample =
"const say = (x) => { el.textContent = x; };\nsay('Checking local ChatGPT OAuth sign-in…');\n";
const found = unmarkedScript('sample.js', sample);
assert.ok(
found.some((f) => f.text.includes('Checking local ChatGPT OAuth')),
'say(...) is not among JS_SINKS in scripts/i18n.mjs',
);
});
test('src/keySetup.js has no unmarked say() literals', () => {
const source = readFileSync(
new URL('./keySetup.js', import.meta.url),
'utf8',
);
const literal = /\bsay\(\s*['"`]/g;
const hits = [...source.matchAll(literal)].map(
(m) => source.slice(0, m.index).split('\n').length,
);
assert.deepEqual(
hits,
[],
`say() called with a bare literal at lines ${hits.join(', ')}`,
);
});