|
1 | | -import { parseRuntimeString } from "./chatCommands"; |
| 1 | +import { describe, expect, test, mock } from "bun:test"; |
| 2 | +import type { SendMessageOptions } from "@/common/types/ipc"; |
| 3 | + |
| 4 | +// Mock dependency to avoid localStorage usage |
| 5 | +mock.module("@/browser/utils/messages/compactionModelPreference", () => ({ |
| 6 | + resolveCompactionModel: (model: string | undefined) => model, |
| 7 | +})); |
| 8 | + |
| 9 | +const { parseRuntimeString, prepareCompactionMessage } = await import("./chatCommands"); |
2 | 10 |
|
3 | 11 | describe("parseRuntimeString", () => { |
4 | 12 | const workspaceName = "test-workspace"; |
@@ -84,3 +92,30 @@ describe("parseRuntimeString", () => { |
84 | 92 | ); |
85 | 93 | }); |
86 | 94 | }); |
| 95 | + |
| 96 | +describe("prepareCompactionMessage", () => { |
| 97 | + const createBaseOptions = (): SendMessageOptions => ({ |
| 98 | + model: "anthropic:claude-3-5-sonnet", |
| 99 | + thinkingLevel: "medium", |
| 100 | + toolPolicy: [], |
| 101 | + mode: "exec", |
| 102 | + }); |
| 103 | + |
| 104 | + test("embeds resumeModel from base send options", () => { |
| 105 | + const sendMessageOptions = createBaseOptions(); |
| 106 | + const { metadata } = prepareCompactionMessage({ |
| 107 | + workspaceId: "ws-1", |
| 108 | + maxOutputTokens: 4096, |
| 109 | + continueMessage: "Keep building", |
| 110 | + model: "anthropic:claude-3-5-haiku", |
| 111 | + sendMessageOptions, |
| 112 | + }); |
| 113 | + |
| 114 | + expect(metadata.type).toBe("compaction-request"); |
| 115 | + if (metadata.type !== "compaction-request") { |
| 116 | + throw new Error("Expected compaction metadata"); |
| 117 | + } |
| 118 | + |
| 119 | + expect(metadata.parsed.resumeModel).toBe(sendMessageOptions.model); |
| 120 | + }); |
| 121 | +}); |
0 commit comments