Skip to content

Commit b91a0c1

Browse files
test(task): cover sayAndCreateMissingParamError missing-parameter notice
Exercises both relPath branches of the now-localized missing-tool-parameter error so the changed lines in Task.ts are covered (addresses the codecov patch-coverage gap on #343).
1 parent cf8b454 commit b91a0c1

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/core/task/__tests__/Task.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,33 @@ describe("Cline", () => {
396396
})
397397
})
398398

399+
describe("sayAndCreateMissingParamError", () => {
400+
it("surfaces a localized error notice and returns the missing-parameter tool error for both relPath branches", async () => {
401+
const cline = new Task({
402+
provider: mockProvider,
403+
apiConfiguration: mockApiConfig,
404+
task: "test task",
405+
startTask: false,
406+
})
407+
408+
const saySpy = vi.spyOn(cline, "say").mockResolvedValue(undefined)
409+
410+
// relPath provided -> the "...WithPath" message branch.
411+
const withPath = await cline.sayAndCreateMissingParamError("read_file", "path", "src/foo.ts")
412+
// relPath omitted -> the plain message branch.
413+
const withoutPath = await cline.sayAndCreateMissingParamError("execute_command", "command")
414+
415+
// Both branches emit an "error" say with localized text.
416+
expect(saySpy).toHaveBeenCalledTimes(2)
417+
expect(saySpy).toHaveBeenNthCalledWith(1, "error", expect.any(String))
418+
expect(saySpy).toHaveBeenNthCalledWith(2, "error", expect.any(String))
419+
420+
// The returned tool error names the missing parameter.
421+
expect(withPath).toContain("path")
422+
expect(withoutPath).toContain("command")
423+
})
424+
})
425+
399426
describe("getEnvironmentDetails", () => {
400427
describe("API conversation handling", () => {
401428
beforeEach(() => {

0 commit comments

Comments
 (0)