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 <copilot@github.com>
This commit is contained in:
Stefan Haller
2026-09-27 18:26:56 +02:00
co-authored by GitHub Copilot
parent 9059d3e3b7
commit 6d46731e05
4 changed files with 39 additions and 27 deletions
@@ -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().
@@ -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().
@@ -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()
},
})
+3 -3
View File
@@ -411,8 +411,11 @@ var tests = []*components.IntegrationTest{
main_view.MoveMultiFileRangeToIndex,
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,
@@ -478,9 +481,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,