Add a test demonstrating that the conflicts popup disappears

If moving a custom patch into a new commit before the original one
results in a conflict, lazygit shows the "Conflicts!" popup, but then
immediately focuses the commits view. This closes the popup, and the
user is left in a rebase that is stopped at a conflict without being
told about it.

The test uses a pre-commit hook that changes a file of the new commit;
this makes picking the original commit conflict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-11-03 19:25:48 +01:00
co-authored by Claude Opus 5.5
parent 7bf398db1d
commit 9383172a6c
2 changed files with 70 additions and 0 deletions
@@ -0,0 +1,69 @@
package main_view
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var MovePatchToNewCommitBeforeWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Move a patch into a new commit before the original commit, where a commit hook changes the new commit so that replaying the original commit conflicts",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file1", "1st line\n")
shell.Commit("first commit")
shell.UpdateFileAndAdd("file1", "1st line\n2nd line\n")
shell.CreateFileAndAdd("file2", "file2 content\n")
shell.Commit("commit to move from")
shell.CreateFile(".git/hooks/pre-commit", "#!/bin/sh\necho 'hook line' >> file1\ngit add file1\n")
shell.MakeExecutable(".git/hooks/pre-commit")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("commit to move from").IsSelected(),
Contains("first commit"),
).
PressEnter()
t.Views().CommitFiles().
IsFocused().
Lines(
Equals("▼ /").IsSelected(),
Contains("file1"),
Contains("file2"),
).
NavigateToLine(Contains("file2")).
PressPrimaryAction()
t.Views().Information().Content(Contains("Building patch"))
t.Common().SelectPatchOption(Contains("Move patch into new commit before the original commit"))
t.ExpectPopup().CommitMessagePanel().
InitialText(Equals("")).
Type("new commit").Confirm()
/* EXPECTED:
t.Common().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
Lines(
Contains("UU").Contains("file1"),
)
ACTUAL: */
t.Views().Commits().
IsFocused().
Lines(
Contains("─── Pending rebase todos"),
Contains("pick").Contains("<-- CONFLICT --- commit to move from"),
Contains("─── Commits"),
Contains("new commit"),
Contains("first commit"),
)
},
})
+1
View File
@@ -471,6 +471,7 @@ var tests = []*components.IntegrationTest{
main_view.MovePatchToLaterCommit,
main_view.MovePatchToNewCommit,
main_view.MovePatchToNewCommitBefore,
main_view.MovePatchToNewCommitBeforeWithConflict,
main_view.MovePatchToNewCommitInStackedBranch,
main_view.NavigateByHunkAndFile,
main_view.NoDiffStatLinksUnderAnExternalDiff,