From 3725343dde5a7157f5ff0485d4708029e95cce87 Mon Sep 17 00:00:00 2001 From: user <17591696+sand4rt@users.noreply.github.com> Date: Sat, 18 Jul 2026 09:37:59 +0200 Subject: [PATCH] fix: broken features --- tests/test_integrations.lua | 172 +++++++++++++++++++++++++++++++++++- tests/test_wincmd.lua | 111 +++++++++++++++++++++++ 2 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 tests/test_wincmd.lua diff --git a/tests/test_integrations.lua b/tests/test_integrations.lua index c7103fd..6c9388d 100644 --- a/tests/test_integrations.lua +++ b/tests/test_integrations.lua @@ -36,6 +36,44 @@ T["left integration"]["opening closes zen side buffer, closing reopens it"] = fu }) end +T["left integration"]["opening a left integration preserves an existing top integration"] = function() + child.cmd("Git") + child.lua("vim.cmd('Fyler kind=split_left_most')") + + Helpers.expect.layout(child, { + type = "col", + children = { + { type = "leaf", filetype = "fugitive", buftype = "nowrite", width = 240, height = 25 }, + { + type = "row", + children = { + { type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 46, height = 24 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 24 }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 24 }, + }, + }, + }, + }) + + child.cmd("close") + child.lua("vim.cmd('Fyler kind=split_left_most')") + child.cmd("close") + + Helpers.expect.layout(child, { + type = "col", + children = { + { type = "leaf", filetype = "fugitive", buftype = "nowrite", width = 240, height = 25 }, + { + type = "row", + children = { + { type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 24 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 24 }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 24 }, + }, + }, + }, + }) +end T["left integration"]["opening an integration should close the existing integration on the same side"] = function() child.cmd("Fyler kind=split_left_most") @@ -61,6 +99,45 @@ T["left integration"]["opening an integration should close the existing integrat }) end +T["left integration"]["opening a left integration preserves an existing bottom integration"] = function() + child.cmd("Trouble diagnostics") + child.cmd("Fyler kind=split_left_most") + + Helpers.expect.layout(child, { + type = "col", + children = { + { + type = "row", + children = { + { type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 46, height = 39 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 39 }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 39 }, + }, + }, + { type = "leaf", filetype = "trouble", buftype = "nofile", width = 240, height = 10 }, + }, + }) + + child.cmd("close") + child.cmd("Fyler kind=split_left_most") + child.cmd("close") + + Helpers.expect.layout(child, { + type = "col", + children = { + { + type = "row", + children = { + { type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 39 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 39 }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 39 }, + }, + }, + { type = "leaf", filetype = "trouble", buftype = "nofile", width = 240, height = 10 }, + }, + }) +end + T["top integration"] = MiniTest.new_set({}) T["top integration"]["opening"] = function() @@ -257,9 +334,70 @@ T["right integration"]["opening an integration with table filetype"] = function( }) end +T["combined"] = MiniTest.new_set({}) + +T["combined"]["opening a side integration preserves existing top and bottom integrations"] = function() + child.cmd("Git") + child.cmd("Trouble diagnostics") + child.cmd("Fyler kind=split_left_most") + + Helpers.expect.layout(child, { + type = "col", + children = { + { type = "leaf", filetype = "fugitive", buftype = "nowrite", width = 240, height = 25 }, + { + type = "row", + children = { + { type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 46, height = 13 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 13 }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 13 }, + }, + }, + { type = "leaf", filetype = "trouble", buftype = "nofile", width = 240, height = 10 }, + }, + }) + + child.cmd("close") + child.cmd("Fyler kind=split_left_most") + child.cmd("close") + + Helpers.expect.layout(child, { + type = "col", + children = { + { type = "leaf", filetype = "fugitive", buftype = "nowrite", width = 240, height = 25 }, + { + type = "row", + children = { + { type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 13 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 13 }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 13 }, + }, + }, + { type = "leaf", filetype = "trouble", buftype = "nofile", width = 240, height = 10 }, + }, + }) + + child.cmd("Trouble close") + + Helpers.expect.layout(child, { + type = "col", + children = { + { type = "leaf", filetype = "fugitive", buftype = "nowrite", width = 240, height = 25 }, + { + type = "row", + children = { + { type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 24 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 24 }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 24 }, + }, + }, + }, + }) +end + local min_width_child = MiniTest.new_child_neovim() -T["min_width"] = MiniTest.new_set({ +T["min width"] = MiniTest.new_set({ hooks = { pre_case = function() min_width_child.restart({ "-u", "tests/scripts/init_with_zen_min_width.lua" }) @@ -268,7 +406,7 @@ T["min_width"] = MiniTest.new_set({ }, }) -T["min_width"]["integration with a larger min_width should override the wildcard default"] = function() +T["min width"]["integration with a larger min_width should override the wildcard default"] = function() min_width_child.lua([[vim.o.splitright = true; require("CopilotChat").open()]]) Helpers.expect.layout(min_width_child, { @@ -281,4 +419,34 @@ T["min_width"]["integration with a larger min_width should override the wildcard }) end +T["small window integration"] = MiniTest.new_set() + +T["small window integration"]["left integration should keep its natural width"] = function() + child.restart({ "-u", "tests/scripts/init_with_zen_small.lua" }) + child.cmd("Fyler kind=split_left_most") + + -- Fyler opens at 30% of 140 = 42 cols. Zen must not force it to 0. + Helpers.expect.layout(child, { + type = "row", + children = { + { type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 42, height = 50 }, + { type = "leaf", filetype = "", buftype = "", width = 97, height = 50 }, + }, + }) +end + +T["small window integration"]["right integration should keep its natural width"] = function() + child.restart({ "-u", "tests/scripts/init_with_zen_small.lua" }) + child.cmd("Neotest summary open") + + -- Neotest opens at vertical resize 50. Zen must not force it to 0. + Helpers.expect.layout(child, { + type = "row", + children = { + { type = "leaf", filetype = "", buftype = "", width = 89, height = 50 }, + { type = "leaf", filetype = "neotest-summary", buftype = "nofile", width = 50, height = 50 }, + }, + }) +end + return T diff --git a/tests/test_wincmd.lua b/tests/test_wincmd.lua new file mode 100644 index 0000000..fbca709 --- /dev/null +++ b/tests/test_wincmd.lua @@ -0,0 +1,111 @@ +local Helpers = dofile("tests/scripts/helpers.lua") +local child = MiniTest.new_child_neovim() + +local T = MiniTest.new_set({ + hooks = { + pre_case = function() + child.restart({ "-u", "tests/scripts/init_with_zen.lua" }) + end, + post_once = child.stop, + }, +}) + +T["moving a window to the side does not go past zen buffers"] = function() + child.cmd("wincmd H") + + Helpers.expect.layout(child, { + type = "row", + children = { + { type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 50 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 50 }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 }, + }, + }) + + child.cmd("wincmd L") + + Helpers.expect.layout(child, { + type = "row", + children = { + { type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 50 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 50 }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 }, + }, + }) +end + +T["moving a window to the side does not go past integrations"] = function() + child.cmd("Fyler kind=split_left_most") + child.cmd("Neotest summary open") + + child.cmd("wincmd H") + + Helpers.expect.layout(child, { + type = "row", + children = { + { type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 46, height = 50 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 50 }, + { type = "leaf", filetype = "neotest-summary", buftype = "nofile", width = 46, height = 50 }, + }, + }) + + child.cmd("wincmd L") + + Helpers.expect.layout(child, { + type = "row", + children = { + { type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 46, height = 50 }, + { type = "leaf", filetype = "", buftype = "", width = 146, height = 50 }, + { type = "leaf", filetype = "neotest-summary", buftype = "nofile", width = 46, height = 50 }, + }, + }) +end + +T["hsplit"] = MiniTest.new_set({}) + +T["hsplit"]["moving a window below keeps it between zen buffers"] = function() + child.cmd("edit test.lua") + child.cmd("split test.rs") + + child.cmd("wincmd J") + + Helpers.expect.layout(child, { + type = "row", + children = { + { type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 50 }, + { + type = "col", + children = { + { type = "leaf", filetype = "lua", buftype = "", width = 146, height = 24 }, + { type = "leaf", filetype = "rust", buftype = "", width = 146, height = 25 }, + }, + }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 }, + }, + }) +end + +T["hsplit"]["moving a window above keeps it between zen buffers"] = function() + child.cmd("edit test.lua") + child.cmd("split test.rs") + + child.cmd("wincmd j") + child.cmd("wincmd K") + + Helpers.expect.layout(child, { + type = "row", + children = { + { type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 50 }, + { + type = "col", + children = { + { type = "leaf", filetype = "rust", buftype = "", width = 146, height = 24 }, + { type = "leaf", filetype = "lua", buftype = "", width = 146, height = 25 }, + }, + }, + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 }, + }, + }) +end + +return T