test: tighten auth profile assertions

This commit is contained in:
Peter Steinberger
2026-05-08 15:57:58 +01:00
parent b46c26b4b0
commit a571fcf041
4 changed files with 13 additions and 12 deletions

View File

@@ -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);
});

View File

@@ -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(

View File

@@ -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;
}

View File

@@ -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();
});