From 1a8c643734eef5ffa8566531f8a56514936eaaac Mon Sep 17 00:00:00 2001 From: Shakker Date: Fri, 8 May 2026 20:49:11 +0100 Subject: [PATCH] test: tighten auth repair assertions --- .../doctor-auth.deprecated-cli-profiles.test.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/commands/doctor-auth.deprecated-cli-profiles.test.ts b/src/commands/doctor-auth.deprecated-cli-profiles.test.ts index 7d680ab3183..840a19e0ce9 100644 --- a/src/commands/doctor-auth.deprecated-cli-profiles.test.ts +++ b/src/commands/doctor-auth.deprecated-cli-profiles.test.ts @@ -50,6 +50,14 @@ function makePrompter(confirmValue: boolean): DoctorPrompter { }; } +function requireAuthConfig(config: OpenClawConfig): NonNullable { + expect(config.auth).toBeDefined(); + if (!config.auth) { + throw new Error("expected repaired auth config"); + } + return config.auth; +} + beforeEach(() => { resolvePluginProvidersMock.mockReset(); resolvePluginProvidersMock.mockReturnValue([]); @@ -144,13 +152,14 @@ describe("maybeRepairLegacyOAuthProfileIds", () => { provider: "anthropic", legacyProfileId: "anthropic:default", }); - expect(next.auth?.profiles?.["anthropic:default"]).toBeUndefined(); - expect(next.auth?.profiles?.["anthropic:user@example.com"]).toMatchObject({ + const auth = requireAuthConfig(next); + expect(auth.profiles?.["anthropic:default"]).toBeUndefined(); + expect(auth.profiles?.["anthropic:user@example.com"]).toMatchObject({ provider: "anthropic", mode: "oauth", email: "user@example.com", }); - expect(next.auth?.order?.anthropic).toEqual(["anthropic:user@example.com"]); + expect(auth.order?.anthropic).toEqual(["anthropic:user@example.com"]); }); it("strips provider-controlled terminal escapes from repair prompts", async () => {