Add a test for pasting text into the keybindings menu

The keybindings menu filters as you type. If you paste text that ends
with a newline into it, the text filters the menu, and the newline then
runs the selected item as if you had pressed Enter. The same happens in
the other menus that filter as you type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-11-12 10:22:50 +01:00
co-authored by Claude Opus 5.5
parent f3bc6fc85e
commit f6ceabdebe
3 changed files with 46 additions and 0 deletions
@@ -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)
@@ -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`),
)
},
})
+1
View File
@@ -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,