1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2026-01-26 01:41:35 +03:00

Add a test that demonstrates problems with custom menu keybindings

The test shows two problems: a <down> keybinding is not removed from a menu item
(the 'y' binding is removed though, which is correct), and keybindings such as
'j' and 'H' don't work. We will fix both of these separately in the following
commits.
This commit is contained in:
Stefan Haller
2025-12-21 12:36:24 +01:00
parent b7a24c8298
commit e19544a42b
2 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
package custom_commands
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var CustomCommandsSubmenuWithSpecialKeybindings = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Using custom commands from a custom commands menu with keybindings that conflict with builtin ones",
ExtraCmdArgs: []string{},
Skip: false,
SetupRepo: func(shell *Shell) {},
SetupConfig: func(cfg *config.AppConfig) {
cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
{
Key: "x",
Description: "My Custom Commands",
CommandMenu: []config.CustomCommand{
{
Key: "j",
Context: "global",
Command: "echo j",
Output: "popup",
},
{
Key: "H",
Context: "global",
Command: "echo H",
Output: "popup",
},
{
Key: "y",
Context: "global",
Command: "echo y",
Output: "popup",
},
{
Key: "<down>",
Context: "global",
Command: "echo down",
Output: "popup",
},
},
},
}
cfg.GetUserConfig().Keybinding.Universal.ConfirmMenu = "y"
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
Focus().
IsEmpty().
Press("x").
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("My Custom Commands")).
Lines(
/* EXPECTED:
Contains("j echo j"),
Contains("H echo H"),
Contains(" echo y"),
Contains(" echo down"),
ACTUAL: */
Contains("j echo j"),
Contains("H echo H"),
Contains(" echo y"),
Contains("<down> echo down"),
)
t.GlobalPress("j")
/* EXPECTED:
t.ExpectPopup().Alert().Title(Equals("echo j")).Content(Equals("j")).Confirm()
ACTUAL: */
// The menu stays open; 'j' didn't trigger the command; instead, it selected the
// next item, which we can confirm by pressing enter:
t.GlobalPress(keys.Universal.ConfirmMenu)
t.ExpectPopup().Alert().Title(Equals("echo H")).Content(Equals("H")).Confirm()
}).
Press("x").
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("My Custom Commands"))
t.GlobalPress("H")
/* EXPECTED:
t.ExpectPopup().Alert().Title(Equals("echo H")).Content(Equals("H")).Confirm()
ACTUAL: */
// The menu stays open:
t.ExpectPopup().Menu().
Title(Equals("My Custom Commands"))
})
},
})

View File

@@ -170,6 +170,7 @@ var tests = []*components.IntegrationTest{
custom_commands.BasicCommand,
custom_commands.CheckForConflicts,
custom_commands.CustomCommandsSubmenu,
custom_commands.CustomCommandsSubmenuWithSpecialKeybindings,
custom_commands.FormPrompts,
custom_commands.GlobalContext,
custom_commands.MenuFromCommand,