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