From 1998d0724f18283f410ca57bebe67fefa4aaebfa Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 10 Mar 2023 18:56:07 +0100 Subject: [PATCH] Add a test for stopping at an "edit" command that conflicts This test is almost identical to swap_in_rebase_with_conflict.go, except that it sets the commit that will conflict to "edit". This test is interesting because there's special code needed to determine whether an "edit" command conflicted or not, i.e. whether to show the "confl" entry. In this case we do. We have lots of other tests already that have "edit" commands that don't conflict, so that's covered already. --- .../swap_in_rebase_with_conflict_and_edit.go | 52 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 53 insertions(+) create mode 100644 pkg/integration/tests/interactive_rebase/swap_in_rebase_with_conflict_and_edit.go diff --git a/pkg/integration/tests/interactive_rebase/swap_in_rebase_with_conflict_and_edit.go b/pkg/integration/tests/interactive_rebase/swap_in_rebase_with_conflict_and_edit.go new file mode 100644 index 000000000..494c79552 --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/swap_in_rebase_with_conflict_and_edit.go @@ -0,0 +1,52 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SwapInRebaseWithConflictAndEdit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Via an edit-triggered rebase, swap two commits, causing a conflict, then edit the commit that will conflict.", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("myfile", "one") + shell.Commit("commit one") + shell.UpdateFileAndAdd("myfile", "two") + shell.Commit("commit two") + shell.UpdateFileAndAdd("myfile", "three") + shell.Commit("commit three") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("commit three").IsSelected(), + Contains("commit two"), + Contains("commit one"), + ). + NavigateToLine(Contains("commit one")). + Press(keys.Universal.Edit). + Lines( + Contains("commit three"), + Contains("commit two"), + Contains("<-- YOU ARE HERE --- commit one").IsSelected(), + ). + NavigateToLine(Contains("commit two")). + Press(keys.Commits.MoveUpCommit). + Lines( + Contains("commit two").IsSelected(), + Contains("commit three"), + Contains("<-- YOU ARE HERE --- commit one"), + ). + NavigateToLine(Contains("commit three")). + Press(keys.Universal.Edit). + SelectPreviousItem(). + Tap(func() { + t.Common().ContinueRebase() + }) + + handleConflictsFromSwap(t) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 02d4f8432..c1549df83 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -121,6 +121,7 @@ var tests = []*components.IntegrationTest{ interactive_rebase.SquashDownSecondCommit, interactive_rebase.SquashFixupsAboveFirstCommit, interactive_rebase.SwapInRebaseWithConflict, + interactive_rebase.SwapInRebaseWithConflictAndEdit, interactive_rebase.SwapWithConflict, misc.ConfirmOnQuit, misc.InitialOpen,