11local env = require (" tests.env" )
2- local M = {}
2+ local M = {
3+ mock_lsp_server = false ,
4+ }
35
46if not _G .attach_debugger then
57 _G .attach_debugger = false
@@ -59,6 +61,7 @@ function M.new_child_neovim(test_name)
5961
6062 --- @param mock_lsp_server ? boolean
6163 function child .run_pre_case (mock_lsp_server )
64+ M .mock_lsp_server = mock_lsp_server or false
6265 child .reset_config ()
6366 child .restart ({ " -u" , " tests/scripts/minimal_init.lua" })
6467
@@ -124,15 +127,35 @@ function M.new_child_neovim(test_name)
124127 end
125128
126129 function child .wait_for_suggestion ()
127- child .lua ([[
130+ if M .mock_lsp_server then
131+ child .lua ([[
132+ vim.wait(500, function()
133+ return M.suggested
134+ end, 10)
135+ ]] )
136+ else
137+ child .lua ([[
128138 vim.wait(5000, function()
129139 return M.suggested
130140 end, 10)
131141 ]] )
142+ end
132143 end
133144
134145 function child .wait_for_panel_suggestion ()
135- child .lua ([[
146+ if M .mock_lsp_server then
147+ child .lua ([[
148+ local function suggestion_is_visible()
149+ lines = vim.api.nvim_buf_get_lines(2, 4, 5, false)
150+ return lines[1] and (lines[1] == "789" or lines[1] == "789\r")
151+ end
152+
153+ vim.wait(500, function()
154+ return suggestion_is_visible()
155+ end, 50)
156+ ]] )
157+ else
158+ child .lua ([[
136159 local function suggestion_is_visible()
137160 lines = vim.api.nvim_buf_get_lines(2, 4, 5, false)
138161 return lines[1] and (lines[1] == "789" or lines[1] == "789\r")
@@ -142,6 +165,7 @@ function M.new_child_neovim(test_name)
142165 return suggestion_is_visible()
143166 end, 50)
144167 ]] )
168+ end
145169 end
146170
147171 return child
0 commit comments