diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 5ac4bdcba..434eba2b6 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -526,6 +526,8 @@ var tests = []*components.IntegrationTest{ ui.ReloadSidePanels, ui.ReorderSidePanels, ui.SubCommitsScrollPositionIsReset, + ui.SuggestionsSelectionFollowsTheFocus, + ui.SwitchRepoMovesTheSelection, ui.SwitchTabFromMenu, ui.SwitchTabWithPanelJumpKeys, undo.UndoCheckoutAndDrop, diff --git a/pkg/integration/tests/ui/suggestions_selection_follows_the_focus.go b/pkg/integration/tests/ui/suggestions_selection_follows_the_focus.go new file mode 100644 index 000000000..793c58bf8 --- /dev/null +++ b/pkg/integration/tests/ui/suggestions_selection_follows_the_focus.go @@ -0,0 +1,42 @@ +package ui + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SuggestionsSelectionFollowsTheFocus = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "The suggestions list only shows a selection while it, rather than the prompt, has the focus", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + EmptyCommit("one"). + NewBranch("branch-to-checkout") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Branches(). + Focus(). + Press(keys.Branches.CheckoutBranchByName) + + t.ExpectPopup().Prompt(). + Title(Equals("Branch name:")). + Type("branch-to"). + SuggestionTopLines(Contains("branch-to-checkout")) + + t.Views().Suggestions().SelectionIsHidden() + + t.Views().Prompt().Press(keys.Universal.TogglePanel) + t.Views().Suggestions(). + IsFocused(). + SelectionIsActive(). + Press(keys.Universal.TogglePanel) + + t.Views().Prompt().IsFocused() + t.Views().Suggestions().SelectionIsHidden() + + t.Views().Prompt().Press(keys.Universal.Return) + t.Views().Branches().IsFocused() + }, +}) diff --git a/pkg/integration/tests/ui/switch_repo_moves_the_selection.go b/pkg/integration/tests/ui/switch_repo_moves_the_selection.go new file mode 100644 index 000000000..eb7c4b2df --- /dev/null +++ b/pkg/integration/tests/ui/switch_repo_moves_the_selection.go @@ -0,0 +1,48 @@ +package ui + +import ( + "path/filepath" + + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SwitchRepoMovesTheSelection = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "The selection follows the focus of the repo being switched to, rather than the one being left", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) { + otherRepo, _ := filepath.Abs("../other") + config.GetAppState().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().Branches(). + Focus(). + SelectionIsActive() + + // The other repo has its own focus, which is the files panel it starts in + switchToRepo("other") + t.Views().Files().IsFocused() + t.Views().Branches().SelectionIsHidden() + + // And coming back, this repo still has the focus we left it with + switchToRepo("repo") + t.Views().Branches(). + IsFocused(). + SelectionIsActive() + t.Views().Files().SelectionIsHidden() + }, +})