From 5ad2c61c9a30decb7e9f580a602dcdc823937066 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 4 Apr 2026 00:06:45 +0900 Subject: [PATCH] test(config): cover gateway bind legacy doctor flow --- src/commands/doctor-config-flow.test.ts | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/commands/doctor-config-flow.test.ts b/src/commands/doctor-config-flow.test.ts index 19184256fb3..0c334c4f0f9 100644 --- a/src/commands/doctor-config-flow.test.ts +++ b/src/commands/doctor-config-flow.test.ts @@ -1309,6 +1309,57 @@ describe("doctor config flow", () => { } }); + it("repairs legacy gateway.bind host aliases on repair", async () => { + const result = await runDoctorConfigWithInput({ + repair: true, + config: { + gateway: { + bind: "0.0.0.0", + }, + }, + run: loadAndMaybeMigrateDoctorConfig, + }); + + const cfg = result.cfg as { + gateway?: { + bind?: string; + }; + }; + expect(cfg.gateway?.bind).toBe("lan"); + }); + + it("warns clearly about legacy gateway.bind host aliases and points to doctor --fix", async () => { + const noteSpy = vi.spyOn(noteModule, "note").mockImplementation(() => {}); + try { + await runDoctorConfigWithInput({ + config: { + gateway: { + bind: "localhost", + }, + }, + run: loadAndMaybeMigrateDoctorConfig, + }); + + expect( + noteSpy.mock.calls.some( + ([message, title]) => + title === "Legacy config keys detected" && + String(message).includes("gateway.bind:") && + String(message).includes("gateway.bind host aliases"), + ), + ).toBe(true); + expect( + noteSpy.mock.calls.some( + ([message, title]) => + title === "Doctor" && + String(message).includes('Run "openclaw doctor --fix" to migrate legacy config keys.'), + ), + ).toBe(true); + } finally { + noteSpy.mockRestore(); + } + }); + it("warns clearly about legacy talk config and points to doctor --fix", async () => { const noteSpy = vi.spyOn(noteModule, "note").mockImplementation(() => {}); try {