From 03e1d37492cb0ec4d684a461275d826d4200b3ab Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 20 Aug 2026 19:10:51 +0200 Subject: [PATCH] Keep patch-move conflict coverage on the focused diff Conflict and dirty-worktree handling happen after a custom patch is built, but their tests must no longer rely on either explorer to build it. Select whole and partial patches in the commit diff while preserving the rebase-conflict and stash-restoration assertions. Co-Authored-By: GitHub Copilot --- ...from_added_file_to_index_with_conflict.go} | 18 ++++++------- .../move_patch_to_index_with_conflict.go} | 17 +++++++++---- ...move_patch_to_index_with_modified_file.go} | 25 +++++++++++-------- pkg/integration/tests/test_list.go | 6 ++--- 4 files changed, 39 insertions(+), 27 deletions(-) rename pkg/integration/tests/{patch_building/move_to_index_from_added_file_with_conflict.go => main_view/move_patch_from_added_file_to_index_with_conflict.go} (82%) rename pkg/integration/tests/{patch_building/move_to_index_with_conflict.go => main_view/move_patch_to_index_with_conflict.go} (83%) rename pkg/integration/tests/{patch_building/move_to_index_with_modified_file.go => main_view/move_patch_to_index_with_modified_file.go} (67%) diff --git a/pkg/integration/tests/patch_building/move_to_index_from_added_file_with_conflict.go b/pkg/integration/tests/main_view/move_patch_from_added_file_to_index_with_conflict.go similarity index 82% rename from pkg/integration/tests/patch_building/move_to_index_from_added_file_with_conflict.go rename to pkg/integration/tests/main_view/move_patch_from_added_file_to_index_with_conflict.go index 177e76e04..10bc6e999 100644 --- a/pkg/integration/tests/patch_building/move_to_index_from_added_file_with_conflict.go +++ b/pkg/integration/tests/main_view/move_patch_from_added_file_to_index_with_conflict.go @@ -1,15 +1,17 @@ -package patch_building +package main_view import ( "github.com/jesseduffield/lazygit/pkg/config" . "github.com/jesseduffield/lazygit/pkg/integration/components" ) -var MoveToIndexFromAddedFileWithConflict = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Move a patch from a file that was added in a commit to the index, causing a conflict", +var MovePatchFromAddedFileToIndexWithConflict = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Move part of an added file from a commit to the index, causing a conflict", ExtraCmdArgs: []string{}, Skip: false, - SetupConfig: func(config *config.AppConfig) {}, + SetupConfig: func(config *config.AppConfig) { + config.GetUserConfig().Gui.UseHunkModeInStagingView = false + }, SetupRepo: func(shell *Shell) { shell.EmptyCommit("first commit") @@ -34,17 +36,15 @@ var MoveToIndexFromAddedFileWithConflict = NewIntegrationTest(NewIntegrationTest Lines( Contains("file1").IsSelected(), ). - PressEnter() + Press(keys.Universal.FocusMainView) - t.Views().PatchBuilding(). + t.Views().Main(). IsFocused(). - SelectNextItem(). + NavigateToLine(Contains("+2nd line")). PressPrimaryAction() t.Views().Information().Content(Contains("Building patch")) - t.Common().SelectPatchOption(Contains("Move patch out into index")) - t.Common().AcknowledgeConflicts() t.Views().Files(). diff --git a/pkg/integration/tests/patch_building/move_to_index_with_conflict.go b/pkg/integration/tests/main_view/move_patch_to_index_with_conflict.go similarity index 83% rename from pkg/integration/tests/patch_building/move_to_index_with_conflict.go rename to pkg/integration/tests/main_view/move_patch_to_index_with_conflict.go index bdf0765d9..28a720adc 100644 --- a/pkg/integration/tests/patch_building/move_to_index_with_conflict.go +++ b/pkg/integration/tests/main_view/move_patch_to_index_with_conflict.go @@ -1,15 +1,17 @@ -package patch_building +package main_view import ( "github.com/jesseduffield/lazygit/pkg/config" . "github.com/jesseduffield/lazygit/pkg/integration/components" ) -var MoveToIndexWithConflict = NewIntegrationTest(NewIntegrationTestArgs{ +var MovePatchToIndexWithConflict = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Move a patch from a commit to the index, causing a conflict", ExtraCmdArgs: []string{}, Skip: false, - SetupConfig: func(config *config.AppConfig) {}, + SetupConfig: func(config *config.AppConfig) { + config.GetUserConfig().Gui.UseHunkModeInStagingView = false + }, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("file1", "file1 content") shell.Commit("first commit") @@ -36,12 +38,17 @@ var MoveToIndexWithConflict = NewIntegrationTest(NewIntegrationTestArgs{ Lines( Contains("file1").IsSelected(), ). + Press(keys.Universal.FocusMainView) + + t.Views().Main(). + IsFocused(). + SelectedLines(Contains("-file1 content")). + Press(keys.Universal.ToggleRangeSelect). + Press(keys.Universal.NextItem). PressPrimaryAction() t.Views().Information().Content(Contains("Building patch")) - t.Common().SelectPatchOption(Contains("Move patch out into index")) - t.Common().AcknowledgeConflicts() t.Views().Files(). diff --git a/pkg/integration/tests/patch_building/move_to_index_with_modified_file.go b/pkg/integration/tests/main_view/move_patch_to_index_with_modified_file.go similarity index 67% rename from pkg/integration/tests/patch_building/move_to_index_with_modified_file.go rename to pkg/integration/tests/main_view/move_patch_to_index_with_modified_file.go index 93aba6d41..d5bc51aab 100644 --- a/pkg/integration/tests/patch_building/move_to_index_with_modified_file.go +++ b/pkg/integration/tests/main_view/move_patch_to_index_with_modified_file.go @@ -1,15 +1,17 @@ -package patch_building +package main_view import ( "github.com/jesseduffield/lazygit/pkg/config" . "github.com/jesseduffield/lazygit/pkg/integration/components" ) -var MoveToIndexWithModifiedFile = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Move a patch from a commit to the index, with a modified file in the working tree that conflicts with the patch", +var MovePatchToIndexWithModifiedFile = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Move a patch from a commit to the index with a conflicting working-tree change", ExtraCmdArgs: []string{}, Skip: false, - SetupConfig: func(config *config.AppConfig) {}, + SetupConfig: func(config *config.AppConfig) { + config.GetUserConfig().Gui.UseHunkModeInStagingView = false + }, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("file1", "1\n2\n3\n4\n") shell.Commit("first commit") @@ -31,10 +33,16 @@ var MoveToIndexWithModifiedFile = NewIntegrationTest(NewIntegrationTestArgs{ Lines( Equals("M file1"), ). + Press(keys.Universal.FocusMainView) + + t.Views().Main(). + IsFocused(). + SelectedLines(Contains("-1")). + Press(keys.Universal.ToggleRangeSelect). + Press(keys.Universal.NextItem). PressPrimaryAction() t.Views().Information().Content(Contains("Building patch")) - t.Views().Secondary().Content(Contains("-1\n+11")) t.Common().SelectPatchOption(Contains("Move patch out into index")) @@ -49,11 +57,8 @@ var MoveToIndexWithModifiedFile = NewIntegrationTest(NewIntegrationTestArgs{ Equals("MM file1"), ) - t.Views().Main(). - Content(Contains("-11\n+111\n")) - t.Views().Secondary(). - Content(Contains("-1\n+11\n")) - + t.Views().Main().Content(Contains("-11\n+111\n")) + t.Views().Secondary().Content(Contains("-1\n+11\n")) t.Views().Stash().IsEmpty() }, }) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index ee221a18a..11e2a7abd 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -413,8 +413,11 @@ var tests = []*components.IntegrationTest{ main_view.MoveOnWhenThePatchMarksRewrapTheDiff, main_view.MovePartOfAdjacentAddedLinesToIndex, main_view.MovePartialPatchToIndex, + main_view.MovePatchFromAddedFileToIndexWithConflict, main_view.MovePatchToIndex, + main_view.MovePatchToIndexWithConflict, main_view.MovePatchToIndexWithCustomDiffConfig, + main_view.MovePatchToIndexWithModifiedFile, main_view.NavigateByHunkAndFile, main_view.NoSelectionOverABinaryDiff, main_view.NoSelectionOverACommitLog, @@ -481,9 +484,6 @@ var tests = []*components.IntegrationTest{ patch_building.EditLineInPatchBuildingPanel, patch_building.MoveToEarlierCommit, patch_building.MoveToEarlierCommitFromAddedFile, - patch_building.MoveToIndexFromAddedFileWithConflict, - patch_building.MoveToIndexWithConflict, - patch_building.MoveToIndexWithModifiedFile, patch_building.MoveToLaterCommit, patch_building.MoveToLaterCommitPartialHunk, patch_building.MoveToNewCommit,