@@ -139,25 +139,31 @@ describe("maybeRepairLegacyOAuthProfileIds", () => {
|
139 | 139 | makePrompter(true), |
140 | 140 | ); |
141 | 141 | |
142 | | -expect(repairMocks.repairOAuthProfileIdMismatch).toHaveBeenCalledWith({ |
143 | | -cfg: expect.objectContaining({ |
144 | | -auth: expect.objectContaining({ |
145 | | -profiles: expect.objectContaining({ |
146 | | -"anthropic:default": { provider: "anthropic", mode: "oauth" }, |
147 | | -}), |
148 | | -}), |
149 | | -}), |
150 | | -store: authProfileStoreMock.store, |
| 142 | +expect(repairMocks.repairOAuthProfileIdMismatch).toHaveBeenCalledOnce(); |
| 143 | +const repairCall = repairMocks.repairOAuthProfileIdMismatch.mock.calls[0]?.[0] as |
| 144 | +| { |
| 145 | +cfg?: OpenClawConfig; |
| 146 | +store?: AuthProfileStore; |
| 147 | +provider?: unknown; |
| 148 | +legacyProfileId?: unknown; |
| 149 | +} |
| 150 | +| undefined; |
| 151 | +if (!repairCall) { |
| 152 | +throw new Error("expected OAuth profile repair call"); |
| 153 | +} |
| 154 | +expect(repairCall.cfg?.auth?.profiles?.["anthropic:default"]).toEqual({ |
151 | 155 | provider: "anthropic", |
152 | | -legacyProfileId: "anthropic:default", |
| 156 | +mode: "oauth", |
153 | 157 | }); |
| 158 | +expect(repairCall.store).toBe(authProfileStoreMock.store); |
| 159 | +expect(repairCall.provider).toBe("anthropic"); |
| 160 | +expect(repairCall.legacyProfileId).toBe("anthropic:default"); |
154 | 161 | const auth = requireAuthConfig(next); |
155 | 162 | expect(auth.profiles?.["anthropic:default"]).toBeUndefined(); |
156 | | -expect(auth.profiles?.["anthropic:user@example.com"]).toMatchObject({ |
157 | | -provider: "anthropic", |
158 | | -mode: "oauth", |
159 | | -email: "user@example.com", |
160 | | -}); |
| 163 | +const repairedProfile = auth.profiles?.["anthropic:user@example.com"]; |
| 164 | +expect(repairedProfile?.provider).toBe("anthropic"); |
| 165 | +expect(repairedProfile?.mode).toBe("oauth"); |
| 166 | +expect(repairedProfile?.email).toBe("user@example.com"); |
161 | 167 | expect(auth.order?.anthropic).toEqual(["anthropic:user@example.com"]); |
162 | 168 | }); |
163 | 169 | |
|