test(doctor): cover repeat talk normalization guard

This commit is contained in:
masonxhuang 2026-04-04 20:26:07 +08:00
parent 88809e0651
commit a67bcaa11b
1 changed files with 50 additions and 0 deletions

View File

@ -2017,4 +2017,54 @@ describe("doctor config flow", () => {
expect(cfg.channels.googlechat.dm.allowFrom).toEqual(["*"]);
expect(cfg.channels.googlechat.allowFrom).toEqual(["*"]);
});
it("does not report repeat talk provider normalization on consecutive repair runs", async () => {
await withTempHome(async (home) => {
const configDir = path.join(home, ".openclaw");
await fs.mkdir(configDir, { recursive: true });
await fs.writeFile(
path.join(configDir, "openclaw.json"),
JSON.stringify(
{
talk: {
interruptOnSpeech: true,
silenceTimeoutMs: 1500,
provider: "elevenlabs",
providers: {
elevenlabs: {
apiKey: "secret-key",
voiceId: "voice-123",
modelId: "eleven_v3",
},
},
},
},
null,
2,
),
"utf-8",
);
const noteSpy = vi.spyOn(noteModule, "note").mockImplementation(() => {});
try {
await loadAndMaybeMigrateDoctorConfig({
options: { nonInteractive: true, repair: true },
confirm: async () => false,
});
noteSpy.mockClear();
await loadAndMaybeMigrateDoctorConfig({
options: { nonInteractive: true, repair: true },
confirm: async () => false,
});
const secondRunTalkNormalizationLines = noteSpy.mock.calls
.filter((call) => call[1] === "Doctor changes")
.map((call) => String(call[0]))
.filter((line) => line.includes("Normalized talk.provider/providers shape"));
expect(secondRunTalkNormalizationLines).toEqual([]);
} finally {
noteSpy.mockRestore();
}
});
});
});