diff --git a/pkg/integration/tests/custom_commands/custom_commands_submenu_with_special_keybindings.go b/pkg/integration/tests/custom_commands/custom_commands_submenu_with_special_keybindings.go new file mode 100644 index 000000000..cc23b297d --- /dev/null +++ b/pkg/integration/tests/custom_commands/custom_commands_submenu_with_special_keybindings.go @@ -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: "", + 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(" 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")) + }) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 14072d866..9c5d57ec9 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -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,