diff --git a/pkg/integration/components/menu_driver.go b/pkg/integration/components/menu_driver.go index e0d6133e6..a71bada76 100644 --- a/pkg/integration/components/menu_driver.go +++ b/pkg/integration/components/menu_driver.go @@ -66,6 +66,15 @@ func (self *MenuDriver) Filter(text string) *MenuDriver { return self } +// pastes the text the way a terminal does it. Only for menus that filter as you +// type. +func (self *MenuDriver) Paste(text string) *MenuDriver { + self.getViewDriver().IsFocused() + self.t.paste(text) + + return self +} + func (self *MenuDriver) LineCount(matcher *IntMatcher) *MenuDriver { self.getViewDriver().LineCount(matcher) diff --git a/pkg/integration/tests/filter_and_search/paste_into_keybindings_menu.go b/pkg/integration/tests/filter_and_search/paste_into_keybindings_menu.go new file mode 100644 index 000000000..d87f1cb54 --- /dev/null +++ b/pkg/integration/tests/filter_and_search/paste_into_keybindings_menu.go @@ -0,0 +1,36 @@ +package filter_and_search + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var PasteIntoKeybindingsMenu = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Pasting text that ends with a newline into the keybindings menu filters the menu without running the selected item", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFile("myfile", "myfile") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + Lines( + Contains(`??`).Contains(`myfile`).IsSelected(), + ). + Press(keys.Universal.OptionMenu) + + t.ExpectPopup().Menu(). + Title(Equals("Keybindings")). + Paste("stage all\n") + + t.Views().Files(). + Lines( + /* EXPECTED: + Contains(`??`).Contains(`myfile`), + ACTUAL: */ + Contains(`A `).Contains(`myfile`), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index e5949856a..aeded3da4 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -337,6 +337,7 @@ var tests = []*components.IntegrationTest{ filter_and_search.NestedFilter, filter_and_search.NestedFilterTransient, filter_and_search.NewSearch, + filter_and_search.PasteIntoKeybindingsMenu, filter_and_search.RerenderTheSearchedMainView, filter_and_search.SearchALongDiff, filter_and_search.SearchStatusAfterARerender,