From fc15d14bdbaa3d2982653b33990501da740cb0da Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sun, 22 Feb 2026 12:13:43 -0500 Subject: [PATCH] fix(test): resolve busted migration test isolation issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Two issues introduced during the plenary-to-busted migration (6be0148). First, altbuf_spec waited for two BufEnter events but oil:// → file resolution only fires one async BufEnter (the synchronous one from vim.cmd.edit fires before wait_for_autocmd is registered). Second, reset_editor kept the first window which could be a preview window with stale oil_preview/oil_source_win state, causing close_preview_window_if_not_in_oil to close the wrong window in subsequent tests. Solution: Wait for a single BufEnter in the altbuf test. Replace the window-keeping logic in reset_editor with vim.cmd.new() + vim.cmd.only() to guarantee a fresh window with no inherited state. This also fixes the preview_spec.lua:30 timeout which had the same root cause. 114/114 tests pass. --- spec/altbuf_spec.lua | 1 - spec/test_util.lua | 8 ++------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/spec/altbuf_spec.lua b/spec/altbuf_spec.lua index b64bfc0..cd2cf4b 100644 --- a/spec/altbuf_spec.lua +++ b/spec/altbuf_spec.lua @@ -22,7 +22,6 @@ describe('Alternate buffer', function() local readme = fs.join(vim.fn.getcwd(), 'README.md') vim.cmd.edit({ args = { 'oil://' .. fs.os_to_posix_path(readme) } }) test_util.wait_for_autocmd('BufEnter') - test_util.wait_for_autocmd('BufEnter') assert.equals(readme, vim.api.nvim_buf_get_name(0)) assert.equals('foo', vim.fn.expand('#')) end) diff --git a/spec/test_util.lua b/spec/test_util.lua index b77f6f1..57f81b1 100644 --- a/spec/test_util.lua +++ b/spec/test_util.lua @@ -12,12 +12,8 @@ M.reset_editor = function() prompt_save_on_select_new_entry = false, }) vim.cmd.tabonly({ mods = { silent = true } }) - for i, winid in ipairs(vim.api.nvim_tabpage_list_wins(0)) do - if i > 1 then - vim.api.nvim_win_close(winid, true) - end - end - vim.api.nvim_win_set_buf(0, vim.api.nvim_create_buf(false, true)) + vim.cmd.new() + vim.cmd.only() for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do vim.api.nvim_buf_delete(bufnr, { force = true }) end