summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-06-13 09:57:02 +0200
committerStefan Haller <stefan@haller-berlin.de>2024-06-23 12:28:42 +0200
commita7c97400c69f641683f38fb7cf11eb8b18e11882 (patch)
tree8e42d01120d3d8e4169ee841d96cc70bbde52830 /pkg
parent5e9fe2be80a067e91a5bc010a37bfeddc09cacdc (diff)
Add a test demonstrating the bug
After switching to another repo and then back to the original one, all keybinding suggestions in the status bar are shown twice.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/integration/components/shell.go6
-rw-r--r--pkg/integration/tests/test_list.go1
-rw-r--r--pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go45
3 files changed, 52 insertions, 0 deletions
diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go
index a8caff77d..01a9caf3a 100644
--- a/pkg/integration/components/shell.go
+++ b/pkg/integration/components/shell.go
@@ -360,6 +360,12 @@ func (self *Shell) Clone(repoName string) *Shell {
return self
}
+func (self *Shell) CloneNonBare(repoName string) *Shell {
+ self.RunCommand([]string{"git", "clone", ".", "../" + repoName})
+
+ return self
+}
+
func (self *Shell) SetBranchUpstream(branch string, upstream string) *Shell {
self.RunCommand([]string{"git", "branch", "--set-upstream-to=" + upstream, branch})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index 5fbbfb4e2..cc7fc6ca1 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -315,6 +315,7 @@ var tests = []*components.IntegrationTest{
ui.Accordion,
ui.DoublePopup,
ui.EmptyMenu,
+ ui.KeybindingSuggestionsWhenSwitchingRepos,
ui.ModeSpecificKeybindingSuggestions,
ui.OpenLinkFailure,
ui.RangeSelect,
diff --git a/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go b/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go
new file mode 100644
index 000000000..2bf4e53c9
--- /dev/null
+++ b/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go
@@ -0,0 +1,45 @@
+package ui
+
+import (
+ "path/filepath"
+
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var KeybindingSuggestionsWhenSwitchingRepos = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Show correct keybinding suggestions after switching between repos",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {
+ otherRepo, _ := filepath.Abs("../other")
+ config.AppState.RecentRepos = []string{otherRepo}
+ },
+ SetupRepo: func(shell *Shell) {
+ shell.CloneNonBare("other")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ switchToRepo := func(repo string) {
+ t.GlobalPress(keys.Universal.OpenRecentRepos)
+ t.ExpectPopup().Menu().Title(Equals("Recent repositories")).
+ Lines(
+ Contains(repo).IsSelected(),
+ Contains("Cancel"),
+ ).Confirm()
+ t.Views().Status().Content(Contains(repo + " → master"))
+ }
+
+ t.Views().Files().Focus()
+ t.Views().Options().Content(
+ Equals("Commit: c | Stash: s | Reset: D | Keybindings: ? | Cancel: <esc>"))
+
+ switchToRepo("other")
+ switchToRepo("repo")
+
+ t.Views().Options().Content(
+ /* EXPECTED:
+ Equals("Commit: c | Stash: s | Reset: D | Keybindings: ? | Cancel: <esc>"))
+ ACTUAL (all keybindings appear twice): */
+ Equals("Commit: c | Stash: s | Reset: D | Commit: c | Stash: s | Reset: D | Keybindings: ? | Cancel: <esc> | Keybindings: ? | Cancel: <esc>"))
+ },
+})