返回 DeepSeek-Reasonix
heartbeat-locale-boundary.test.ts
根目录 / desktop / frontend / src / __tests__ / heartbeat-locale-boundary.test.ts
1 import assert from "node:assert/strict";
2 import { readFileSync } from "node:fs";
3 import { dirname, resolve } from "node:path";
4 import { fileURLToPath } from "node:url";
5 import { heartbeatFeatureKeys } from "../custom/features/heartbeat/heartbeat.i18n";
6
7 const testDir = dirname(fileURLToPath(import.meta.url));
8 const globalLocales = ["en.ts", "zh.ts", "zh-TW.ts"].map((name) =>
9 readFileSync(resolve(testDir, "../locales", name), "utf8"),
10 );
11
12 assert.ok(heartbeatFeatureKeys.length > 0, "Heartbeat owns feature-local translations");
13 for (const key of heartbeatFeatureKeys) {
14 for (const source of globalLocales) {
15 assert.ok(!source.includes(`"${key}"`), `${key} stays out of the global locale chunks`);
16 }
17 }
18
19 const panel = readFileSync(resolve(testDir, "../custom/features/heartbeat/HeartbeatPanel.tsx"), "utf8");
20 assert.match(panel, /const t = useHeartbeatT\(\)/, "the lazy Heartbeat page resolves its feature-local translations");
21
22 console.log(` PASS ${heartbeatFeatureKeys.length} Heartbeat translations stay feature-local`);
23
23 lines TYPESCRIPT