From 59f2ef04992974c487107f9f8bc657fc4b4e9361 Mon Sep 17 00:00:00 2001 From: Shakker Date: Mon, 11 May 2026 06:33:39 +0100 Subject: [PATCH] test: tighten hook approval assertions --- src/plugins/hooks.before-tool-call.test.ts | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/plugins/hooks.before-tool-call.test.ts b/src/plugins/hooks.before-tool-call.test.ts index ddc341c9056..67494f691f4 100644 --- a/src/plugins/hooks.before-tool-call.test.ts +++ b/src/plugins/hooks.before-tool-call.test.ts @@ -33,15 +33,13 @@ function expectRequireApprovalResult( block?: boolean; blockReason?: string; params?: Record; - requireApproval?: Record; + requireApproval?: PluginHookBeforeToolCallResult["requireApproval"]; }, ) { expect(result?.block).toBe(expected.block); expect(result?.blockReason).toBe(expected.blockReason); expect(result?.params).toEqual(expected.params); - expect(result?.requireApproval).toEqual( - expected.requireApproval ? expect.objectContaining(expected.requireApproval) : undefined, - ); + expect(result?.requireApproval).toEqual(expected.requireApproval); } describe("before_tool_call hook merger — requireApproval", () => { @@ -90,6 +88,9 @@ describe("before_tool_call hook merger — requireApproval", () => { }, ], expectedApproval: { + id: "a1", + title: "T", + description: "D", pluginId: "my-plugin", }, }, @@ -119,6 +120,7 @@ describe("before_tool_call hook merger — requireApproval", () => { ], expectedApproval: { title: "First", + description: "First plugin", pluginId: "plugin-a", }, }, @@ -137,6 +139,8 @@ describe("before_tool_call hook merger — requireApproval", () => { }, ], expectedApproval: { + title: "T", + description: "D", pluginId: "actual-plugin", }, }, @@ -201,7 +205,11 @@ describe("before_tool_call hook merger — requireApproval", () => { }, ], expected: { - requireApproval: { pluginId: "approver" }, + requireApproval: { + title: "Needs approval", + description: "Approval needed", + pluginId: "approver", + }, params: { source: "approver", safe: true }, }, }, @@ -232,7 +240,11 @@ describe("before_tool_call hook merger — requireApproval", () => { expected: { block: true, blockReason: "blocked", - requireApproval: { pluginId: "approver" }, + requireApproval: { + title: "Needs approval", + description: "Approval needed", + pluginId: "approver", + }, params: { source: "approver", safe: true }, }, },