File size: 2,012 Bytes
d197cf3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | // Control UI i18n script tests cover locale extraction and validation.
import { describe, expect, it } from "vitest";
import {
findPlaceholderMismatches,
isProviderAuthError,
resolveTranslationModel,
} from "../../scripts/control-ui-i18n.ts";
describe("control-ui-i18n placeholder validation", () => {
it("reports missing and extra placeholders by key", () => {
const mismatches = findPlaceholderMismatches(
new Map([
["sessionsView.activeTooltip", "Updated in the last {count} minutes."],
["sessionsView.store", "Store: {path}"],
["sessionsView.limitTooltip", "Max sessions to load."],
]),
new Map([
["sessionsView.activeTooltip", "Actualizadas en los últimos N minutos."],
["sessionsView.store", "Almacén: {path}"],
["sessionsView.limitTooltip", "Máximo {extra} de sesiones."],
]),
"es",
);
expect(mismatches).toEqual([
{
key: "sessionsView.activeTooltip",
locale: "es",
sourcePlaceholders: ["count"],
translatedPlaceholders: [],
},
{
key: "sessionsView.limitTooltip",
locale: "es",
sourcePlaceholders: [],
translatedPlaceholders: ["extra"],
},
]);
});
});
describe("control-ui-i18n translation runtime resolution", () => {
it("uses the in-tree OpenClaw LLM model catalog", () => {
expect(resolveTranslationModel()).toMatchObject({
id: "gpt-6-astra",
provider: "openai",
});
});
});
describe("control-ui-i18n provider auth errors", () => {
it("recognizes OpenAI and Anthropic authentication failures", () => {
expect(isProviderAuthError(new Error("401 Incorrect API key provided"))).toBe(true);
expect(
isProviderAuthError(
new Error(
'401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}',
),
),
).toBe(true);
expect(isProviderAuthError(new Error("model timed out"))).toBe(false);
});
});
|