From 016d46526cf71042c0e538d0b8b42b99ef2b1a2a Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 29 Nov 2024 16:49:18 +0100 Subject: [PATCH] Add test for editing several commits right after a merge commit This is very similar to edit_range_select_outside_rebase.go, except that it selects commits right after, and including, a merge commit. This test already works correctly. The reason we add it is that we are going to have two different implementations of the `e` command depending on whether the last selected commit is a merge commit, and we want to make sure they both work with a range selection. --- ...nge_select_down_to_merge_outside_rebase.go | 43 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 44 insertions(+) create mode 100644 pkg/integration/tests/interactive_rebase/edit_range_select_down_to_merge_outside_rebase.go diff --git a/pkg/integration/tests/interactive_rebase/edit_range_select_down_to_merge_outside_rebase.go b/pkg/integration/tests/interactive_rebase/edit_range_select_down_to_merge_outside_rebase.go new file mode 100644 index 000000000..364b04518 --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/edit_range_select_down_to_merge_outside_rebase.go @@ -0,0 +1,43 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" + "github.com/jesseduffield/lazygit/pkg/integration/tests/shared" +) + +var EditRangeSelectDownToMergeOutsideRebase = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Select a range of commits (the last one being a merge commit) to edit outside of a rebase", + ExtraCmdArgs: []string{}, + Skip: false, + GitVersion: AtLeast("2.22.0"), // first version that supports the --rebase-merges option + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shared.CreateMergeCommit(shell) + shell.CreateNCommits(2) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + TopLines( + Contains("CI ◯ commit 02").IsSelected(), + Contains("CI ◯ commit 01"), + Contains("Merge branch 'second-change-branch' into first-change-branch"), + ). + Press(keys.Universal.RangeSelectDown). + Press(keys.Universal.RangeSelectDown). + Press(keys.Universal.Edit). + Lines( + Contains("edit CI commit 02").IsSelected(), + Contains("edit CI commit 01").IsSelected(), + Contains(" CI ⏣─╮ <-- YOU ARE HERE --- Merge branch 'second-change-branch' into first-change-branch").IsSelected(), + Contains(" CI │ ◯ * second-change-branch unrelated change"), + Contains(" CI │ ◯ second change"), + Contains(" CI ◯ │ first change"), + Contains(" CI ◯─╯ * original"), + Contains(" CI ◯ three"), + Contains(" CI ◯ two"), + Contains(" CI ◯ one"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 65b6c6a6d..ce7220873 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -214,6 +214,7 @@ var tests = []*components.IntegrationTest{ interactive_rebase.EditFirstCommit, interactive_rebase.EditLastCommitOfStackedBranch, interactive_rebase.EditNonTodoCommitDuringRebase, + interactive_rebase.EditRangeSelectDownToMergeOutsideRebase, interactive_rebase.EditRangeSelectOutsideRebase, interactive_rebase.EditTheConflCommit, interactive_rebase.FixupFirstCommit,