|
2 | 2 |
|
3 | 3 | import type { ProviderSettings } from "@roo-code/types" |
4 | 4 |
|
| 5 | +import type { ApiHandlerCreateMessageMetadata } from "../../api" |
| 6 | + |
5 | 7 | import { singleCompletionHandler } from "../single-completion-handler" |
6 | 8 | import { buildApiHandler, SingleCompletionHandler } from "../../api" |
7 | 9 | import { supportPrompt } from "../../shared/support-prompt" |
@@ -45,6 +47,29 @@ describe("enhancePrompt", () => { |
45 | 47 | expect((handler as any).completePrompt).toHaveBeenCalledWith(`Test prompt`, undefined) |
46 | 48 | }) |
47 | 49 |
|
| 50 | + it("forwards metadata to completePrompt", async () => { |
| 51 | + const controller = new AbortController() |
| 52 | + const metadata: ApiHandlerCreateMessageMetadata = { |
| 53 | + taskId: "test-task-id", |
| 54 | + mode: "code" as any, |
| 55 | + abortSignal: controller.signal, |
| 56 | + } |
| 57 | + |
| 58 | + const result = await singleCompletionHandler(mockApiConfig, "Test prompt", metadata) |
| 59 | + |
| 60 | + expect(result).toBe("Enhanced prompt") |
| 61 | + const handler = buildApiHandler(mockApiConfig) |
| 62 | + expect((handler as any).completePrompt).toHaveBeenCalledWith("Test prompt", metadata) |
| 63 | + }) |
| 64 | + |
| 65 | + it("forwards undefined metadata when not provided", async () => { |
| 66 | + const result = await singleCompletionHandler(mockApiConfig, "Test prompt") |
| 67 | + |
| 68 | + expect(result).toBe("Enhanced prompt") |
| 69 | + const handler = buildApiHandler(mockApiConfig) |
| 70 | + expect((handler as any).completePrompt).toHaveBeenCalledWith("Test prompt", undefined) |
| 71 | + }) |
| 72 | + |
48 | 73 | it("enhances prompt using custom enhancement prompt when provided", async () => { |
49 | 74 | const customEnhancePrompt = "You are a custom prompt enhancer" |
50 | 75 | const customEnhancePromptWithTemplate = customEnhancePrompt + "\n\n${userInput}" |
|
0 commit comments