Skip to content

Commit d2529af

Browse files
committed
test(utils): add metadata forwarding test for singleCompletionHandler
- Add test verifying metadata (including abortSignal) is forwarded to completePrompt - Add explicit test for undefined metadata case - Fixes Codecov coverage gap on single-completion-handler.ts line 28
1 parent 9b97337 commit d2529af

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/utils/__tests__/enhance-prompt.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import type { ProviderSettings } from "@roo-code/types"
44

5+
import type { ApiHandlerCreateMessageMetadata } from "../../api"
6+
57
import { singleCompletionHandler } from "../single-completion-handler"
68
import { buildApiHandler, SingleCompletionHandler } from "../../api"
79
import { supportPrompt } from "../../shared/support-prompt"
@@ -45,6 +47,29 @@ describe("enhancePrompt", () => {
4547
expect((handler as any).completePrompt).toHaveBeenCalledWith(`Test prompt`, undefined)
4648
})
4749

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+
4873
it("enhances prompt using custom enhancement prompt when provided", async () => {
4974
const customEnhancePrompt = "You are a custom prompt enhancer"
5075
const customEnhancePromptWithTemplate = customEnhancePrompt + "\n\n${userInput}"

0 commit comments

Comments
 (0)