Skip to content

Commit 1b667b4

Browse files
committed
test: new tests to ensure attach is called
1 parent aa00b0b commit 1b667b4

File tree

1 file changed

+58
-5
lines changed

1 file changed

+58
-5
lines changed

tests/test_client.lua

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,33 @@ T["client()"]["will not attach to buffer due to filetype exclusion"] = function(
206206
reference_screenshot(child.get_screenshot(), nil, { ignore_text = { 9, 10 }, ignore_attr = { 9, 10 } })
207207
end
208208

209-
T["client()"]["auto_trigger off - will not attach automatically"] = function()
209+
-- Reenable with new config
210+
-- T["client()"]["auto_trigger off - will not attach automatically"] = function()
211+
-- child.configure_copilot()
212+
-- child.cmd("e test.txt")
213+
-- child.type_keys("i", "<Esc>")
214+
-- child.cmd("Copilot status")
215+
--
216+
-- local messages = child.lua([[
217+
-- local messages = ""
218+
-- local function has_passed()
219+
-- messages = vim.api.nvim_exec("messages", { output = true }) or ""
220+
-- if messages:find(".*Online.*attached.*") then
221+
-- return true
222+
-- end
223+
-- end
224+
--
225+
-- vim.wait(1000, function()
226+
-- return has_passed()
227+
-- end, 50)
228+
--
229+
-- return messages
230+
-- ]])
231+
--
232+
-- u.expect_no_match(messages, ".*Online.*attached.*")
233+
-- end
234+
235+
T["client()"]["auto_trigger off - will attach automatically"] = function()
210236
child.configure_copilot()
211237
child.cmd("e test.txt")
212238
child.type_keys("i", "<Esc>")
@@ -228,12 +254,14 @@ T["client()"]["auto_trigger off - will not attach automatically"] = function()
228254
return messages
229255
]])
230256

231-
u.expect_no_match(messages, ".*Online.*attached.*")
257+
u.expect_match(messages, ".*Online.*attached.*")
232258
end
233259

234-
T["client()"]["auto_trigger off - will attach when requesting suggestion"] = function()
260+
T["client()"]["suggestion and panel off - will attach automatically"] = function()
261+
child.config.suggestion = "enabled = false,"
235262
child.configure_copilot()
236-
child.type_keys("i", "<M-l>", "<Esc>")
263+
child.cmd("e test.txt")
264+
child.type_keys("i", "<Esc>")
237265
child.cmd("Copilot status")
238266

239267
local messages = child.lua([[
@@ -245,7 +273,7 @@ T["client()"]["auto_trigger off - will attach when requesting suggestion"] = fun
245273
end
246274
end
247275
248-
vim.wait(5000, function()
276+
vim.wait(1000, function()
249277
return has_passed()
250278
end, 50)
251279
@@ -255,4 +283,29 @@ T["client()"]["auto_trigger off - will attach when requesting suggestion"] = fun
255283
u.expect_match(messages, ".*Online.*attached.*")
256284
end
257285

286+
-- re-enable with added configuration
287+
-- T["client()"]["auto_trigger off - will attach when requesting suggestion"] = function()
288+
-- child.configure_copilot()
289+
-- child.type_keys("i", "<M-l>", "<Esc>")
290+
-- child.cmd("Copilot status")
291+
--
292+
-- local messages = child.lua([[
293+
-- local messages = ""
294+
-- local function has_passed()
295+
-- messages = vim.api.nvim_exec("messages", { output = true }) or ""
296+
-- if messages:find(".*Online.*attached.*") then
297+
-- return true
298+
-- end
299+
-- end
300+
--
301+
-- vim.wait(5000, function()
302+
-- return has_passed()
303+
-- end, 50)
304+
--
305+
-- return messages
306+
-- ]])
307+
--
308+
-- u.expect_match(messages, ".*Online.*attached.*")
309+
-- end
310+
258311
return T

0 commit comments

Comments
 (0)