From 44166f7cfe593adc4985e4b2ab80edfe4366ddbc Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 19 Apr 2026 03:55:35 +0100 Subject: [PATCH] test: share live model switch params --- src/agents/live-model-switch.test.ts | 67 +++++++++------------------- 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/src/agents/live-model-switch.test.ts b/src/agents/live-model-switch.test.ts index 42ef677235e..48d40775730 100644 --- a/src/agents/live-model-switch.test.ts +++ b/src/agents/live-model-switch.test.ts @@ -58,6 +58,23 @@ async function loadModule() { return mod; } +type ShouldSwitchParams = Parameters< + typeof import("./live-model-switch.js").shouldSwitchToLiveModel +>[0]; + +function makeShouldSwitchParams(overrides: Partial = {}): ShouldSwitchParams { + return { + cfg: { session: { store: "/tmp/custom-store.json" } }, + sessionKey: "main", + agentId: "reply", + defaultProvider: "anthropic", + defaultModel: "claude-opus-4-6", + currentProvider: "anthropic", + currentModel: "claude-opus-4-6", + ...overrides, + }; +} + describe("live model switch", () => { beforeAll(async () => { mod = await import("./live-model-switch.js"); @@ -391,15 +408,7 @@ describe("live model switch", () => { const { shouldSwitchToLiveModel } = await loadModule(); - const result = shouldSwitchToLiveModel({ - cfg: { session: { store: "/tmp/custom-store.json" } }, - sessionKey: "main", - agentId: "reply", - defaultProvider: "anthropic", - defaultModel: "claude-opus-4-6", - currentProvider: "anthropic", - currentModel: "claude-opus-4-6", - }); + const result = shouldSwitchToLiveModel(makeShouldSwitchParams()); expect(result).toEqual({ provider: "openai", @@ -419,15 +428,7 @@ describe("live model switch", () => { const { shouldSwitchToLiveModel } = await loadModule(); - const result = shouldSwitchToLiveModel({ - cfg: { session: { store: "/tmp/custom-store.json" } }, - sessionKey: "main", - agentId: "reply", - defaultProvider: "anthropic", - defaultModel: "claude-opus-4-6", - currentProvider: "anthropic", - currentModel: "claude-opus-4-6", - }); + const result = shouldSwitchToLiveModel(makeShouldSwitchParams()); expect(result).toBeUndefined(); }); @@ -443,15 +444,7 @@ describe("live model switch", () => { const { shouldSwitchToLiveModel } = await loadModule(); - const result = shouldSwitchToLiveModel({ - cfg: { session: { store: "/tmp/custom-store.json" } }, - sessionKey: "main", - agentId: "reply", - defaultProvider: "anthropic", - defaultModel: "claude-opus-4-6", - currentProvider: "anthropic", - currentModel: "claude-opus-4-6", - }); + const result = shouldSwitchToLiveModel(makeShouldSwitchParams()); expect(result).toBeUndefined(); }); @@ -472,15 +465,7 @@ describe("live model switch", () => { const { shouldSwitchToLiveModel } = await loadModule(); - const result = shouldSwitchToLiveModel({ - cfg: { session: { store: "/tmp/custom-store.json" } }, - sessionKey: "main", - agentId: "reply", - defaultProvider: "anthropic", - defaultModel: "claude-opus-4-6", - currentProvider: "anthropic", - currentModel: "claude-opus-4-6", - }); + const result = shouldSwitchToLiveModel(makeShouldSwitchParams()); expect(result).toBeUndefined(); // Give the fire-and-forget clearLiveModelSwitchPending a tick to resolve @@ -492,15 +477,7 @@ describe("live model switch", () => { it("returns undefined when sessionKey is missing", async () => { const { shouldSwitchToLiveModel } = await loadModule(); - const result = shouldSwitchToLiveModel({ - cfg: { session: { store: "/tmp/custom-store.json" } }, - sessionKey: undefined, - agentId: "reply", - defaultProvider: "anthropic", - defaultModel: "claude-opus-4-6", - currentProvider: "anthropic", - currentModel: "claude-opus-4-6", - }); + const result = shouldSwitchToLiveModel(makeShouldSwitchParams({ sessionKey: undefined })); expect(result).toBeUndefined(); });