From 0c59771e314d6faaad69676985cd2a11c157ee37 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 22 Mar 2024 11:02:52 +0100 Subject: refactor(tests): all screen tests should use highlights This is the first installment of a multi-PR series significantly refactoring how highlights are being specified. The end goal is to have a base set of 20 ish most common highlights, and then specific files only need to add more groups to that as needed. As a complicating factor, we also want to migrate to the new default color scheme eventually. But by sharing a base set, that future PR will hopefully be a lot smaller since a lot of tests will be migrated just simply by updating the base set in place. As a first step, fix the anti-pattern than Screen defaults to ignoring highlights. Highlights are integral part of the screen state, not something "extra" which we only test "sometimes". For now, we still allow opt-out via the intentionally ugly screen._default_attr_ids = nil The end goal is to get rid of all of these eventually (which will be easier as part of the color scheme migration) --- test/functional/plugin/health_spec.lua | 61 ++++++++++++++++---------- test/functional/plugin/lsp/inlay_hint_spec.lua | 4 +- 2 files changed, 39 insertions(+), 26 deletions(-) (limited to 'test/functional/plugin') diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 8564ec7c9b..9306180c40 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -166,11 +166,11 @@ describe('health.vim', function() screen:expect { grid = [[ ^ | - ──────────────────────────────────────────────────| - +WE 4 lines: foo: ·······························| - ──────────────────────────────────────────────────| - +-- 8 lines: test_plug.success1: require("test_pl| - ~ | + {14:──────────────────────────────────────────────────}| + {13:+WE 4 lines: foo: ·······························}| + {14:──────────────────────────────────────────────────}| + {13:+-- 8 lines: test_plug.success1: require("test_pl}| + {1:~ }| | ]], } @@ -218,6 +218,12 @@ describe(':checkhealth window', function() it('opens directly if no buffer created', function() local screen = Screen.new(50, 12) + screen:set_default_attr_ids { + [1] = { foreground = Screen.colors.Blue, bold = true }, + [14] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }, + [31] = { foreground = tonumber('0x6a0dad') }, + [32] = { foreground = Screen.colors.PaleGreen2 }, + } screen:attach({ ext_multigrid = true }) command('checkhealth success1') screen:expect { @@ -227,16 +233,16 @@ describe(':checkhealth window', function() [3:--------------------------------------------------]| ## grid 2 ^ | - ──────────────────────────────────────────────────| - ──────────────────────────── | - test_plug.success1: require("test_plug.success1. | - health").check() | + {14:──────────────────────────────────────────────────}| + {14:────────────────────────────} | + {31:test_plug.success1: require("test_plug.success1. }| + {31:health").check()} | | - report 1 | - - OK everything is fine | + {31:report 1} | + - {32:OK} everything is fine | | - report 2 | - - OK nothing to see here | + {31:report 2} | + - {32:OK} nothing to see here | ## grid 3 | ]], @@ -245,6 +251,12 @@ describe(':checkhealth window', function() local function test_health_vsplit(left, emptybuf, mods) local screen = Screen.new(50, 20) + screen:set_default_attr_ids { + [1] = { foreground = Screen.colors.Blue, bold = true }, + [14] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }, + [31] = { foreground = tonumber('0x6a0dad') }, + [32] = { foreground = Screen.colors.PaleGreen2 }, + } screen:attach({ ext_multigrid = true }) if not emptybuf then insert('hello') @@ -257,24 +269,24 @@ describe(':checkhealth window', function() [3:--------------------------------------------------]| ## grid 2 %s | - ~ |*18 + {1:~ }|*18 ## grid 3 | ## grid 4 ^ | - ─────────────────────────|*3 - ─── | - test_plug.success1: | - require("test_plug. | - success1.health").check()| + {14:─────────────────────────}|*3 + {14:───} | + {31:test_plug.success1: }| + {31:require("test_plug. }| + {31:success1.health").check()}| | - report 1 | - - OK everything is fine | + {31:report 1} | + - {32:OK} everything is fine | | - report 2 | - - OK nothing to see here | + {31:report 2} | + - {32:OK} nothing to see here | | - ~ |*4 + {1:~ }|*4 ]]):format( left and '[4:-------------------------]│[2:------------------------]|*19' or '[2:------------------------]│[4:-------------------------]|*19', @@ -304,6 +316,7 @@ describe(':checkhealth window', function() local function test_health_split(top, emptybuf, mods) local screen = Screen.new(50, 25) screen:attach({ ext_multigrid = true }) + screen._default_attr_ids = nil if not emptybuf then insert('hello') end diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua index 864394d7e0..b046a2c509 100644 --- a/test/functional/plugin/lsp/inlay_hint_spec.lua +++ b/test/functional/plugin/lsp/inlay_hint_spec.lua @@ -41,12 +41,12 @@ local grid_without_inlay_hints = [[ ]] local grid_with_inlay_hints = [[ - auto add(int a, int b)-> int { return a + b; } | + auto add(int a, int b){1:-> int} { return a + b; } | | int main() { | int x = 1; | int y = 2; | - return add(a: x,b: y); | + return add({1:a:} x,{1:b:} y); | } | ^} | | -- cgit