mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
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.
This commit is contained in:
@ -360,6 +360,12 @@ func (self *Shell) Clone(repoName string) *Shell {
|
|||||||
return self
|
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 {
|
func (self *Shell) SetBranchUpstream(branch string, upstream string) *Shell {
|
||||||
self.RunCommand([]string{"git", "branch", "--set-upstream-to=" + upstream, branch})
|
self.RunCommand([]string{"git", "branch", "--set-upstream-to=" + upstream, branch})
|
||||||
|
|
||||||
|
@ -315,6 +315,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
ui.Accordion,
|
ui.Accordion,
|
||||||
ui.DoublePopup,
|
ui.DoublePopup,
|
||||||
ui.EmptyMenu,
|
ui.EmptyMenu,
|
||||||
|
ui.KeybindingSuggestionsWhenSwitchingRepos,
|
||||||
ui.ModeSpecificKeybindingSuggestions,
|
ui.ModeSpecificKeybindingSuggestions,
|
||||||
ui.OpenLinkFailure,
|
ui.OpenLinkFailure,
|
||||||
ui.RangeSelect,
|
ui.RangeSelect,
|
||||||
|
@ -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>"))
|
||||||
|
},
|
||||||
|
})
|
Reference in New Issue
Block a user