forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_panel.lua
More file actions
66 lines (59 loc) · 1.74 KB
/
test_panel.lua
File metadata and controls
66 lines (59 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local eq = MiniTest.expect.equality
local child = MiniTest.new_child_neovim()
local env = require("tests.env")
local T = MiniTest.new_set({
hooks = {
pre_once = function()
if vim.fn.filereadable("./tests/logs/test_suggestion.log") == 1 then
vim.fn.delete("./tests/logs/test_suggestion.log")
end
end,
pre_case = function()
child.restart({ "-u", "tests/scripts/minimal_init.lua" })
child.bo.readonly = false
child.lua("M = require('copilot')")
child.lua("cmd = require('copilot.command')")
child.lua("p = require('copilot.panel')")
-- child.lua([[require("osv").launch({ port = 8086 })]])
child.fn.setenv("GITHUB_COPILOT_TOKEN", env.COPILOT_TOKEN)
end,
post_once = child.stop,
},
})
T["panel()"] = MiniTest.new_set()
-- This test can fail if the LSP is taking more time than usual and re-running it passes
T["panel()"]["panel suggestions works"] = function()
child.o.lines, child.o.columns = 30, 100
child.lua([[M.setup({
panel = {
auto_refresh = true,
},
suggestion = {
auto_trigger = true,
},
logger = {
file_log_level = vim.log.levels.TRACE,
file = "./tests/logs/test_suggestion.log",
},
filetypes = {
["*"] = true,
},
})]])
-- look for a synchronous way to wait for engine to be up
vim.loop.sleep(500)
child.type_keys("i123", "<Esc>", "o456", "<Esc>", "o7")
child.lua("p.toggle()")
local i = 0
local lines = ""
while i < 50 do
vim.loop.sleep(200)
child.lua("vim.wait(0)")
lines = child.api.nvim_buf_get_lines(2, 4, 5, false)
if lines[1] == "789" then
break
end
i = i + 1
end
eq(lines[1], "789")
end
return T