aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/health_spec.lua
diff options
context:
space:
mode:
authorPablo Arias <pabloariasal@gmail.com>2023-12-25 01:30:56 +0100
committerGitHub <noreply@github.com>2023-12-25 08:30:56 +0800
commit2ff2785c396e66c285fecf5b151d8f8863f9d4e6 (patch)
treea5328e075c2ccf9c1013fcdb07b722a13ab14ede /test/functional/plugin/health_spec.lua
parent675522af18f59918a64e6dbe5f0ba3b1d3b4eb65 (diff)
downloadrneovim-2ff2785c396e66c285fecf5b151d8f8863f9d4e6.tar.gz
rneovim-2ff2785c396e66c285fecf5b151d8f8863f9d4e6.tar.bz2
rneovim-2ff2785c396e66c285fecf5b151d8f8863f9d4e6.zip
feat(health): checkhealth buffer can show in a split window (#26714)
:checkhealth now respects :vertical and :horizontal. For example: :vertical checkhealth foo bar will open the healthcheck buffer in a vertical split.
Diffstat (limited to 'test/functional/plugin/health_spec.lua')
-rw-r--r--test/functional/plugin/health_spec.lua190
1 files changed, 190 insertions, 0 deletions
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
index 50b1d03f36..7f23c3e7db 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -6,6 +6,9 @@ local curbuf_contents = helpers.curbuf_contents
local command = helpers.command
local eq, neq, matches = helpers.eq, helpers.neq, helpers.matches
local getcompletion = helpers.funcs.getcompletion
+local feed = helpers.feed
+local source = helpers.source
+local exec_lua = helpers.exec_lua
describe(':checkhealth', function()
it("detects invalid $VIMRUNTIME", function()
@@ -200,3 +203,190 @@ describe(':checkhealth provider', function()
eq(nil, string.match(curbuf_contents(), 'WRONG!!!'))
end)
end)
+
+describe(':checkhealth window', function()
+ before_each(function()
+ clear{args={'-u', 'NORC'}}
+ -- Provides healthcheck functions
+ command("set runtimepath+=test/functional/fixtures")
+ command("set nofoldenable nowrap laststatus=0")
+ end)
+
+ it("opens directly if no buffer created", function()
+ local screen = Screen.new(50, 12)
+ screen:attach({ext_multigrid=true})
+ command("checkhealth success1")
+ screen:expect{grid=[[
+ ## grid 1
+ [2:--------------------------------------------------]|*11
+ [3:--------------------------------------------------]|
+ ## grid 2
+ ^ |
+ ──────────────────────────────────────────────────|
+ ──────────────────────────── |
+ test_plug.success1: require("test_plug.success1. |
+ health").check() |
+ |
+ report 1 |
+ - OK everything is fine |
+ |
+ report 2 |
+ - OK nothing to see here |
+ ## grid 3
+ |
+ ]]}
+ end)
+
+ it("opens in vsplit window when no buffer created", function()
+ local screen = Screen.new(50, 20)
+ screen:attach({ext_multigrid=true})
+ command("vertical checkhealth success1")
+ screen:expect{grid=[[
+ ## grid 1
+ [4:-------------------------]│[2:------------------------]|*19
+ [3:--------------------------------------------------]|
+ ## grid 2
+ |
+ ~ |*18
+ ## grid 3
+ |
+ ## grid 4
+ ^ |
+ ─────────────────────────|*3
+ ─── |
+ test_plug.success1: |
+ require("test_plug. |
+ success1.health").check()|
+ |
+ report 1 |
+ - OK everything is fine |
+ |
+ report 2 |
+ - OK nothing to see here |
+ |
+ ~ |*4
+ ]]}
+ end)
+
+ it("opens in split window when no buffer created", function()
+ local screen = Screen.new(50, 25)
+ screen:attach({ext_multigrid=true})
+ command("horizontal checkhealth success1")
+ screen:expect{grid=[[
+ ## grid 1
+ [4:--------------------------------------------------]|*12
+ health:// |
+ [2:--------------------------------------------------]|*11
+ [3:--------------------------------------------------]|
+ ## grid 2
+ |
+ ~ |*10
+ ## grid 3
+ |
+ ## grid 4
+ ^ |
+ ──────────────────────────────────────────────────|
+ ──────────────────────────── |
+ test_plug.success1: require("test_plug.success1. |
+ health").check() |
+ |
+ report 1 |
+ - OK everything is fine |
+ |
+ report 2 |
+ - OK nothing to see here |
+ |
+ ]]}
+ end)
+
+ it("opens in split window", function()
+ local screen = Screen.new(50, 25)
+ screen:attach({ext_multigrid=true})
+ feed('ihello')
+ feed('<esc>')
+ command("horizontal checkhealth success1")
+ screen:expect{grid=[[
+ ## grid 1
+ [4:--------------------------------------------------]|*12
+ health:// |
+ [2:--------------------------------------------------]|*11
+ [3:--------------------------------------------------]|
+ ## grid 2
+ hello |
+ ~ |*10
+ ## grid 3
+ |
+ ## grid 4
+ ^ |
+ ──────────────────────────────────────────────────|
+ ──────────────────────────── |
+ test_plug.success1: require("test_plug.success1. |
+ health").check() |
+ |
+ report 1 |
+ - OK everything is fine |
+ |
+ report 2 |
+ - OK nothing to see here |
+ |
+ ]]}
+ end)
+
+ it("opens in vsplit window", function()
+ local screen = Screen.new(50, 25)
+ screen:attach({ext_multigrid=true})
+ feed('ihello')
+ feed('<esc>')
+ command("vertical checkhealth success1")
+ screen:expect{grid=[[
+ ## grid 1
+ [4:-------------------------]│[2:------------------------]|*24
+ [3:--------------------------------------------------]|
+ ## grid 2
+ hello |
+ ~ |*23
+ ## grid 3
+ |
+ ## grid 4
+ ^ |
+ ─────────────────────────|*3
+ ─── |
+ test_plug.success1: |
+ require("test_plug. |
+ success1.health").check()|
+ |
+ report 1 |
+ - OK everything is fine |
+ |
+ report 2 |
+ - OK nothing to see here |
+ |
+ ~ |*9
+ ]]}
+ end)
+
+ it("opens in tab", function()
+ -- create an empty buffer called "my_buff"
+ exec_lua 'vim.api.nvim_create_buf(false, true)'
+ command('file my_buff')
+ command("checkhealth success1")
+ -- define a function that collects all buffers in each tab
+ -- returns a dictionary like {tab1 = ["buf1", "buf2"], tab2 = ["buf3"]}
+ source([[
+ function CollectBuffersPerTab()
+ let buffs = {}
+ for i in range(tabpagenr('$'))
+ let key = 'tab' . (i + 1)
+ let value = []
+ for j in tabpagebuflist(i + 1)
+ call add(value, bufname(j))
+ endfor
+ let buffs[key] = value
+ endfor
+ return buffs
+ endfunction
+ ]])
+ local buffers_per_tab = exec_lua("return vim.fn.CollectBuffersPerTab()")
+ eq(buffers_per_tab, {tab1 = { "my_buff" }, tab2 = {"health://"}})
+ end)
+end)