Skip to content

Commit b05abc4

Browse files
Test failure
1 parent 254fd47 commit b05abc4

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

tests/test_review_feature.lua

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,53 @@ T["review_window_escape_rejects"] = function()
183183
eq(result.approved, false)
184184
end
185185

186+
T["failed_tool_execution_skips_review_window"] = function()
187+
-- Simulate tool execution failure with review requested
188+
_G.child.lua_func(function()
189+
_G.test_result = { review_shown = false, callback_called = false, error_received = nil }
190+
191+
-- Mock a tool execution that fails
192+
local params = {
193+
server_name = "test_server",
194+
tool_name = "failing_tool",
195+
tool_input = {},
196+
}
197+
198+
-- Simulate the flow with review_requested = true but tool execution fails
199+
local parsed = _G.shared.parse_params(params, "use_mcp_tool")
200+
parsed.review_requested = true
201+
202+
-- Create a mock callback that tracks if it's called with an error
203+
local function mock_callback(result, error)
204+
_G.test_result.callback_called = true
205+
_G.test_result.error_received = error ~= nil
206+
207+
-- Check if review window was created
208+
local wins = vim.api.nvim_list_wins()
209+
for _, win in ipairs(wins) do
210+
local config = vim.api.nvim_win_get_config(win)
211+
if config.title and type(config.title) == "table" then
212+
local title_str = config.title[1][1]
213+
if title_str:match("Review") then
214+
_G.test_result.review_shown = true
215+
break
216+
end
217+
end
218+
end
219+
end
220+
221+
-- Simulate error being passed to callback (review should NOT be shown)
222+
mock_callback(nil, "Tool execution failed: connection timeout")
223+
224+
vim.wait(100)
225+
end)
226+
227+
local result = _G.child.lua_get("_G.test_result")
228+
eq(result.callback_called, true)
229+
eq(result.error_received, true)
230+
eq(result.review_shown, false) -- Review window should NOT appear on error
231+
end
232+
186233
T["review_window_displays_images_count"] = function()
187234
_G.child.lua([[
188235
local result_data = {

0 commit comments

Comments
 (0)