Files
OmniRoute/tests/unit/modality-bridge-video-i18n.test.ts
Diego Rodrigues de Sa e Souza 5379493bed feat: add Video Bridge frame sampling (#10483)
Implements the secure, opt-in Video Bridge for issue #9760, including bounded FFmpeg frame extraction, capability-aware routing, telemetry, settings UI, localization, documentation, and regression coverage.
2026-08-15 14:23:29 -03:00

73 lines
2.8 KiB
TypeScript

import assert from "node:assert/strict";
import { readdirSync, readFileSync } from "node:fs";
import path from "node:path";
import test from "node:test";
const messagesDirectory = path.resolve("src/i18n/messages");
const requiredKeys = [
"modalityBridgeVideoTitle",
"modalityBridgeVideoDesc",
"modalityBridgeVideoRuntimeReady",
"modalityBridgeVideoRuntimeUnavailable",
"modalityBridgeVideoRuntimeInstall",
"modalityBridgeVideoEnabled",
"modalityBridgeVideoEnabledDesc",
"modalityBridgeVideoModel",
"modalityBridgeVideoModelInherited",
"modalityBridgeVideoFrameCount",
"modalityBridgeVideoMaxVideos",
] as const;
test("all 43 UI locale catalogs contain non-placeholder Video Bridge settings", () => {
const catalogs = readdirSync(messagesDirectory)
.filter((file) => file.endsWith(".json"))
.sort();
assert.equal(catalogs.length, 43);
const english = JSON.parse(readFileSync(path.join(messagesDirectory, "en.json"), "utf8")) as {
settings: Record<string, string>;
};
for (const file of catalogs) {
const catalog = JSON.parse(readFileSync(path.join(messagesDirectory, file), "utf8")) as {
settings?: Record<string, unknown>;
};
for (const key of requiredKeys) {
const value = catalog.settings?.[key];
assert.equal(typeof value, "string", `${file}: settings.${key} missing`);
assert.ok(String(value).trim().length > 0, `${file}: settings.${key} empty`);
assert.equal(String(value).startsWith("__MISSING__:"), false, `${file}: ${key} placeholder`);
if (file !== "en.json" && key !== "modalityBridgeVideoTitle") {
assert.notEqual(
value,
english.settings[key],
`${file}: settings.${key} copied from English instead of translated`
);
}
}
}
});
test("localized Modality Bridge copy describes the shipped Video Bridge without stale backlog text", () => {
const ptBr = JSON.parse(readFileSync(path.join(messagesDirectory, "pt-BR.json"), "utf8")) as {
settings: Record<string, string>;
};
assert.equal(
ptBr.settings.modalityBridgeIntro,
"Converta conteúdo multimodal em texto antes que ele chegue a modelos apenas de texto. As pontes de visão, áudio e vídeo estão disponíveis e podem ser configuradas."
);
assert.equal(
ptBr.settings.modalityBridgeVideoDesc,
"Faça uma amostragem dos quadros do vídeo, descreva-os com um modelo de visão e continue com o modelo de texto escolhido."
);
for (const file of readdirSync(messagesDirectory).filter((entry) => entry.endsWith(".json"))) {
const catalog = JSON.parse(readFileSync(path.join(messagesDirectory, file), "utf8")) as {
settings: Record<string, unknown>;
};
assert.equal(
Object.hasOwn(catalog.settings, "modalityBridgeVideoComingSoon"),
false,
`${file}: stale Video Bridge backlog key`
);
}
});