Skip to content

Commit 018c935

Browse files
committed
test: cover task_await bulk scope check binding
Change-Id: I7486265efb796be3831f5e97692dfba2f0fb163e Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent eb84002 commit 018c935

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/node/services/tools/task_await.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,38 @@ describe("task_await tool", () => {
3737
});
3838
});
3939

40+
it("supports filterDescendantAgentTaskIds without losing this binding", async () => {
41+
using tempDir = new TestTempDir("test-task-await-tool-this-binding");
42+
const baseConfig = createTestToolConfig(tempDir.path, { workspaceId: "parent-workspace" });
43+
44+
const waitForAgentReport = mock(() => Promise.resolve({ reportMarkdown: "ok" }));
45+
const isDescendantAgentTask = mock(() => true);
46+
47+
const taskService = {
48+
filterDescendantAgentTaskIds: function (ancestorWorkspaceId: string, taskIds: string[]) {
49+
expect(this).toBe(taskService);
50+
expect(ancestorWorkspaceId).toBe("parent-workspace");
51+
expect(taskIds).toEqual(["t1"]);
52+
return taskIds;
53+
},
54+
listActiveDescendantAgentTaskIds: mock(() => []),
55+
isDescendantAgentTask,
56+
waitForAgentReport,
57+
} as unknown as TaskService;
58+
59+
const tool = createTaskAwaitTool({ ...baseConfig, taskService });
60+
61+
const result: unknown = await Promise.resolve(
62+
tool.execute!({ task_ids: ["t1"] }, mockToolCallOptions)
63+
);
64+
65+
expect(result).toEqual({
66+
results: [{ status: "completed", taskId: "t1", reportMarkdown: "ok", title: undefined }],
67+
});
68+
expect(isDescendantAgentTask).toHaveBeenCalledTimes(0);
69+
expect(waitForAgentReport).toHaveBeenCalledTimes(1);
70+
});
71+
4072
it("marks invalid_scope without calling waitForAgentReport", async () => {
4173
using tempDir = new TestTempDir("test-task-await-tool-invalid-scope");
4274
const baseConfig = createTestToolConfig(tempDir.path, { workspaceId: "parent-workspace" });

0 commit comments

Comments
 (0)