mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 23:50:43 +00:00
test: tighten auth profile assertions
This commit is contained in:
@@ -117,9 +117,10 @@ describe("resolveApiKeyForProfile cross-agent refresh coordination (#26322)", ()
|
||||
expect(callCount).toBe(1);
|
||||
expect(results).toHaveLength(agentCount);
|
||||
for (const result of results) {
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.apiKey).toBe("cross-agent-refreshed-access");
|
||||
expect(result?.provider).toBe(provider);
|
||||
expect(result).toMatchObject({
|
||||
apiKey: "cross-agent-refreshed-access",
|
||||
provider,
|
||||
});
|
||||
}
|
||||
}, 10_000);
|
||||
});
|
||||
|
||||
@@ -186,9 +186,10 @@ describe("resolveApiKeyForProfile fallback to main agent", () => {
|
||||
// fresh main credentials are used read-through without copying the refresh token.
|
||||
const result = await resolveFromSecondaryAgent(profileId);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.apiKey).toBe("fresh-access-token");
|
||||
expect(result?.provider).toBe("anthropic");
|
||||
expect(result).toMatchObject({
|
||||
apiKey: "fresh-access-token",
|
||||
provider: "anthropic",
|
||||
});
|
||||
|
||||
// The secondary store keeps its local credential; inherited OAuth is read-through.
|
||||
const secondaryStore = JSON.parse(
|
||||
|
||||
@@ -224,7 +224,7 @@ describe("models-config", () => {
|
||||
provider: { baseUrl: "https://api.copilot.example", models: [] },
|
||||
});
|
||||
|
||||
expectCopilotProviderFromPlan(plan).toEqual({
|
||||
expect(expectCopilotProviderFromPlan(plan)).toEqual({
|
||||
baseUrl: "https://api.copilot.example",
|
||||
models: [],
|
||||
});
|
||||
@@ -235,7 +235,7 @@ describe("models-config", () => {
|
||||
provider: { baseUrl: "https://api.individual.githubcopilot.com", models: [] },
|
||||
});
|
||||
|
||||
expectCopilotProviderFromPlan(plan)?.toEqual({
|
||||
expect(expectCopilotProviderFromPlan(plan)).toEqual({
|
||||
baseUrl: "https://api.individual.githubcopilot.com",
|
||||
models: [],
|
||||
});
|
||||
@@ -272,7 +272,6 @@ function expectCopilotProviderFromPlan(
|
||||
? (JSON.parse(plan.contents) as { providers?: Record<string, unknown> })
|
||||
: {};
|
||||
const provider = parsed.providers?.["github-copilot"];
|
||||
expect(typeof provider).toBe("object");
|
||||
expect(provider).not.toBeNull();
|
||||
return expect(provider);
|
||||
expect(provider).toEqual(expect.any(Object));
|
||||
return provider;
|
||||
}
|
||||
|
||||
@@ -511,7 +511,7 @@ describe("compaction-safeguard runtime registry", () => {
|
||||
it("clears entry when value is null", () => {
|
||||
const sm = {};
|
||||
setCompactionSafeguardRuntime(sm, { maxHistoryShare: 0.7 });
|
||||
expect(getCompactionSafeguardRuntime(sm)).not.toBeNull();
|
||||
expect(getCompactionSafeguardRuntime(sm)).toEqual({ maxHistoryShare: 0.7 });
|
||||
setCompactionSafeguardRuntime(sm, null);
|
||||
expect(getCompactionSafeguardRuntime(sm)).toBeNull();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user