Files
openclaw/src/config/talk-defaults.test.ts
Peter Steinberger b5265a07d7 refactor: replace 156k-line generated baselines with SHA-256 hash files
Config and Plugin SDK drift detection now compares SHA-256 hashes instead
of full JSON content. The .sha256 files (6 lines total) are tracked in git;
the full JSON baselines are gitignored and generated locally for inspection.

Same CI guarantee, zero repo churn on schema changes.
2026-04-04 16:49:21 +09:00

54 lines
2.1 KiB
TypeScript

import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
import {
buildConfigDocBaseline,
flattenConfigDocBaselineEntries,
normalizeConfigDocBaselineHelpPath,
} from "./doc-baseline.js";
import { FIELD_HELP } from "./schema.help.js";
import {
describeTalkSilenceTimeoutDefaults,
TALK_SILENCE_TIMEOUT_MS_BY_PLATFORM,
} from "./talk-defaults.js";
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
function readRepoFile(relativePath: string): string {
return fs.readFileSync(path.join(repoRoot, relativePath), "utf8");
}
describe("talk silence timeout defaults", () => {
it("keeps help text and docs aligned with the policy", async () => {
const defaultsDescription = describeTalkSilenceTimeoutDefaults();
const baseline = await buildConfigDocBaseline();
const talkEntry = flattenConfigDocBaselineEntries(baseline).find(
(entry) => entry.path === normalizeConfigDocBaselineHelpPath("talk.silenceTimeoutMs"),
);
expect(FIELD_HELP["talk.silenceTimeoutMs"]).toContain(defaultsDescription);
expect(talkEntry?.help).toContain(defaultsDescription);
expect(readRepoFile("docs/gateway/configuration-reference.md")).toContain(defaultsDescription);
expect(readRepoFile("docs/nodes/talk.md")).toContain(defaultsDescription);
});
it("matches the Apple and Android runtime constants", () => {
const macDefaults = readRepoFile("apps/macos/Sources/OpenClaw/TalkDefaults.swift");
const iosDefaults = readRepoFile("apps/ios/Sources/Voice/TalkDefaults.swift");
const androidDefaults = readRepoFile(
"apps/android/app/src/main/java/ai/openclaw/app/voice/TalkDefaults.kt",
);
expect(macDefaults).toContain(
`static let silenceTimeoutMs = ${TALK_SILENCE_TIMEOUT_MS_BY_PLATFORM.macos}`,
);
expect(iosDefaults).toContain(
`static let silenceTimeoutMs = ${TALK_SILENCE_TIMEOUT_MS_BY_PLATFORM.ios}`,
);
expect(androidDefaults).toContain(
`const val defaultSilenceTimeoutMs = ${TALK_SILENCE_TIMEOUT_MS_BY_PLATFORM.android}L`,
);
});
});