diff --git a/pkg/integration/tests/branch/squash_merge_with_staged_changes.go b/pkg/integration/tests/branch/squash_merge_with_staged_changes.go new file mode 100644 index 000000000..4778101b0 --- /dev/null +++ b/pkg/integration/tests/branch/squash_merge_with_staged_changes.go @@ -0,0 +1,64 @@ +package branch + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SquashMergeWithStagedChanges = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Try to squash merge a branch while there are staged changes", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.NewBranch("original-branch"). + EmptyCommit("one"). + NewBranch("feature-branch"). + CreateFileAndAdd("feature-file", "content"). + Commit("feature"). + Checkout("original-branch"). + CreateFileAndAdd("staged-file", "content") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Branches(). + Focus(). + Lines( + Contains("original-branch").IsSelected(), + Contains("feature-branch"), + ). + SelectNextItem(). + Press(keys.Branches.MergeIntoCurrentBranch) + + t.ExpectPopup().Menu(). + Title(Equals("Merge")). + Select(Contains("Squash merge and commit")). + Confirm() + + /* EXPECTED: + t.ExpectToast(Equals("Disabled: Cannot squash merge while there are staged changes")) + + t.ExpectPopup().Menu(). + Title(Equals("Merge")). + Select(Contains("Squash merge and leave uncommitted")). + Confirm() + + t.ExpectToast(Equals("Disabled: Cannot squash merge while there are staged changes")) + ACTUAL: */ + t.Views().Commits(). + Focus(). + Lines( + Contains("Squash merge feature-branch into original-branch"), + Contains("one"), + ). + NavigateToLine(Contains("Squash merge feature-branch into original-branch")). + PressEnter() + + t.Views().CommitFiles(). + IsFocused(). + Lines( + Equals("▼ /"), + Contains("feature-file"), + Contains("staged-file"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index f2369036f..a20ab7f6b 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -110,6 +110,7 @@ var tests = []*components.IntegrationTest{ branch.SortRemoteBranches, branch.SortRemoteBranchesInStackOrder, branch.SquashMerge, + branch.SquashMergeWithStagedChanges, branch.Suggestions, branch.UnsetUpstream, cherry_pick.CherryPick,