|
| 1 | +package custom_commands |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/jesseduffield/lazygit/pkg/config" |
| 5 | + . "github.com/jesseduffield/lazygit/pkg/integration/components" |
| 6 | +) |
| 7 | + |
| 8 | +var CustomCommandsSubmenuWithSpecialKeybindings = NewIntegrationTest(NewIntegrationTestArgs{ |
| 9 | + Description: "Using custom commands from a custom commands menu with keybindings that conflict with builtin ones", |
| 10 | + ExtraCmdArgs: []string{}, |
| 11 | + Skip: false, |
| 12 | + SetupRepo: func(shell *Shell) {}, |
| 13 | + SetupConfig: func(cfg *config.AppConfig) { |
| 14 | + cfg.GetUserConfig().CustomCommands = []config.CustomCommand{ |
| 15 | + { |
| 16 | + Key: "x", |
| 17 | + Description: "My Custom Commands", |
| 18 | + CommandMenu: []config.CustomCommand{ |
| 19 | + { |
| 20 | + Key: "j", |
| 21 | + Context: "global", |
| 22 | + Command: "echo j", |
| 23 | + Output: "popup", |
| 24 | + }, |
| 25 | + { |
| 26 | + Key: "H", |
| 27 | + Context: "global", |
| 28 | + Command: "echo H", |
| 29 | + Output: "popup", |
| 30 | + }, |
| 31 | + { |
| 32 | + Key: "y", |
| 33 | + Context: "global", |
| 34 | + Command: "echo y", |
| 35 | + Output: "popup", |
| 36 | + }, |
| 37 | + { |
| 38 | + Key: "<down>", |
| 39 | + Context: "global", |
| 40 | + Command: "echo down", |
| 41 | + Output: "popup", |
| 42 | + }, |
| 43 | + }, |
| 44 | + }, |
| 45 | + } |
| 46 | + cfg.GetUserConfig().Keybinding.Universal.ConfirmMenu = "y" |
| 47 | + }, |
| 48 | + Run: func(t *TestDriver, keys config.KeybindingConfig) { |
| 49 | + t.Views().Files(). |
| 50 | + Focus(). |
| 51 | + IsEmpty(). |
| 52 | + Press("x"). |
| 53 | + Tap(func() { |
| 54 | + t.ExpectPopup().Menu(). |
| 55 | + Title(Equals("My Custom Commands")). |
| 56 | + Lines( |
| 57 | + /* EXPECTED: |
| 58 | + Contains("j echo j"), |
| 59 | + Contains("H echo H"), |
| 60 | + Contains(" echo y"), |
| 61 | + Contains(" echo down"), |
| 62 | + ACTUAL: */ |
| 63 | + Contains("j echo j"), |
| 64 | + Contains("H echo H"), |
| 65 | + Contains(" echo y"), |
| 66 | + Contains("<down> echo down"), |
| 67 | + ) |
| 68 | + t.GlobalPress("j") |
| 69 | + /* EXPECTED: |
| 70 | + t.ExpectPopup().Alert().Title(Equals("echo j")).Content(Equals("j")).Confirm() |
| 71 | + ACTUAL: */ |
| 72 | + // The menu stays open; 'j' didn't trigger the command; instead, it selected the |
| 73 | + // next item, which we can confirm by pressing enter: |
| 74 | + t.GlobalPress(keys.Universal.ConfirmMenu) |
| 75 | + t.ExpectPopup().Alert().Title(Equals("echo H")).Content(Equals("H")).Confirm() |
| 76 | + }). |
| 77 | + Press("x"). |
| 78 | + Tap(func() { |
| 79 | + t.ExpectPopup().Menu(). |
| 80 | + Title(Equals("My Custom Commands")) |
| 81 | + t.GlobalPress("H") |
| 82 | + /* EXPECTED: |
| 83 | + t.ExpectPopup().Alert().Title(Equals("echo H")).Content(Equals("H")).Confirm() |
| 84 | + ACTUAL: */ |
| 85 | + // The menu stays open: |
| 86 | + t.ExpectPopup().Menu(). |
| 87 | + Title(Equals("My Custom Commands")) |
| 88 | + }) |
| 89 | + }, |
| 90 | +}) |
0 commit comments