test: tighten auth profile assertions · openclaw/openclaw@a571fcf
steipete
·
2026-05-08
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -117,9 +117,10 @@ describe("resolveApiKeyForProfile cross-agent refresh coordination (#26322)", ()
|
117 | 117 | expect(callCount).toBe(1); |
118 | 118 | expect(results).toHaveLength(agentCount); |
119 | 119 | for (const result of results) { |
120 | | -expect(result).not.toBeNull(); |
121 | | -expect(result?.apiKey).toBe("cross-agent-refreshed-access"); |
122 | | -expect(result?.provider).toBe(provider); |
| 120 | +expect(result).toMatchObject({ |
| 121 | +apiKey: "cross-agent-refreshed-access", |
| 122 | + provider, |
| 123 | +}); |
123 | 124 | } |
124 | 125 | }, 10_000); |
125 | 126 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -186,9 +186,10 @@ describe("resolveApiKeyForProfile fallback to main agent", () => {
|
186 | 186 | // fresh main credentials are used read-through without copying the refresh token. |
187 | 187 | const result = await resolveFromSecondaryAgent(profileId); |
188 | 188 | |
189 | | -expect(result).not.toBeNull(); |
190 | | -expect(result?.apiKey).toBe("fresh-access-token"); |
191 | | -expect(result?.provider).toBe("anthropic"); |
| 189 | +expect(result).toMatchObject({ |
| 190 | +apiKey: "fresh-access-token", |
| 191 | +provider: "anthropic", |
| 192 | +}); |
192 | 193 | |
193 | 194 | // The secondary store keeps its local credential; inherited OAuth is read-through. |
194 | 195 | const secondaryStore = JSON.parse( |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -224,7 +224,7 @@ describe("models-config", () => {
|
224 | 224 | provider: { baseUrl: "https://api.copilot.example", models: [] }, |
225 | 225 | }); |
226 | 226 | |
227 | | -expectCopilotProviderFromPlan(plan).toEqual({ |
| 227 | +expect(expectCopilotProviderFromPlan(plan)).toEqual({ |
228 | 228 | baseUrl: "https://api.copilot.example", |
229 | 229 | models: [], |
230 | 230 | }); |
@@ -235,7 +235,7 @@ describe("models-config", () => {
|
235 | 235 | provider: { baseUrl: "https://api.individual.githubcopilot.com", models: [] }, |
236 | 236 | }); |
237 | 237 | |
238 | | -expectCopilotProviderFromPlan(plan)?.toEqual({ |
| 238 | +expect(expectCopilotProviderFromPlan(plan)).toEqual({ |
239 | 239 | baseUrl: "https://api.individual.githubcopilot.com", |
240 | 240 | models: [], |
241 | 241 | }); |
@@ -272,7 +272,6 @@ function expectCopilotProviderFromPlan(
|
272 | 272 | ? (JSON.parse(plan.contents) as { providers?: Record<string, unknown> }) |
273 | 273 | : {}; |
274 | 274 | const provider = parsed.providers?.["github-copilot"]; |
275 | | -expect(typeof provider).toBe("object"); |
276 | | -expect(provider).not.toBeNull(); |
277 | | -return expect(provider); |
| 275 | +expect(provider).toEqual(expect.any(Object)); |
| 276 | +return provider; |
278 | 277 | } |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -511,7 +511,7 @@ describe("compaction-safeguard runtime registry", () => {
|
511 | 511 | it("clears entry when value is null", () => { |
512 | 512 | const sm = {}; |
513 | 513 | setCompactionSafeguardRuntime(sm, { maxHistoryShare: 0.7 }); |
514 | | -expect(getCompactionSafeguardRuntime(sm)).not.toBeNull(); |
| 514 | +expect(getCompactionSafeguardRuntime(sm)).toEqual({ maxHistoryShare: 0.7 }); |
515 | 515 | setCompactionSafeguardRuntime(sm, null); |
516 | 516 | expect(getCompactionSafeguardRuntime(sm)).toBeNull(); |
517 | 517 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。