summaryrefslogtreecommitdiffstats
path: root/pkg/integration
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-03-08 17:50:51 +0100
committerStefan Haller <stefan@haller-berlin.de>2023-06-22 18:57:43 +0200
commit3d76c734aab1c92510b491fae25f94c1a8f5c0d5 (patch)
treece652a29b670373c7f6e04e7a405fd3f38e58a7a /pkg/integration
parentcddf056f4d88e23ba7c2aa2263b9a2b1608ff651 (diff)
Add test for amending a commit, causing a conflict
Diffstat (limited to 'pkg/integration')
-rw-r--r--pkg/integration/tests/interactive_rebase/amend_commit_with_conflict.go74
-rw-r--r--pkg/integration/tests/test_list.go1
2 files changed, 75 insertions, 0 deletions
diff --git a/pkg/integration/tests/interactive_rebase/amend_commit_with_conflict.go b/pkg/integration/tests/interactive_rebase/amend_commit_with_conflict.go
new file mode 100644
index 000000000..0483487f3
--- /dev/null
+++ b/pkg/integration/tests/interactive_rebase/amend_commit_with_conflict.go
@@ -0,0 +1,74 @@
+package interactive_rebase
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var AmendCommitWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Amends a staged file to a commit, causing a conflict there.",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.CreateFileAndAdd("file", "1\n").Commit("one")
+ shell.UpdateFileAndAdd("file", "1\n2\n").Commit("two")
+ shell.UpdateFileAndAdd("file", "1\n2\n3\n").Commit("three")
+ shell.UpdateFileAndAdd("file", "1\n2\n4\n")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("three"),
+ Contains("two"),
+ Contains("one"),
+ ).
+ NavigateToLine(Contains("two")).
+ Press(keys.Commits.AmendToCommit).
+ Tap(func() {
+ t.ExpectPopup().Confirmation().
+ Title(Equals("Amend commit")).
+ Content(Contains("Are you sure you want to amend this commit with your staged files?")).
+ Confirm()
+ t.Common().AcknowledgeConflicts()
+ }).
+ Lines(
+ Contains("pick").Contains("three"),
+ // Would be nice to see "fixup! two" here, because that's what git is trying to apply right now
+ Contains("<-- YOU ARE HERE --- two"),
+ Contains("one"),
+ )
+
+ t.Views().Files().
+ IsFocused().
+ Lines(
+ Contains("UU file"),
+ ).
+ PressEnter()
+
+ t.Views().MergeConflicts().
+ IsFocused().
+ TopLines(
+ Contains("1"),
+ Contains("2"),
+ Contains("<<<<<<< HEAD"),
+ Contains("======="),
+ Contains("4"),
+ Contains(">>>>>>>"),
+ ).
+ SelectNextItem().
+ PressPrimaryAction() // pick "4"
+
+ t.Common().ContinueOnConflictsResolved()
+
+ t.Common().AcknowledgeConflicts()
+
+ t.Views().Commits().
+ Lines(
+ // Would be nice to see "three" here, because that's what git is trying to apply right now
+ Contains("<-- YOU ARE HERE --- two"),
+ Contains("one"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index 5e45d7e55..2c047b38f 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -95,6 +95,7 @@ var tests = []*components.IntegrationTest{
filter_by_path.SelectFile,
filter_by_path.TypeFile,
interactive_rebase.AdvancedInteractiveRebase,
+ interactive_rebase.AmendCommitWithConflict,
interactive_rebase.AmendFirstCommit,
interactive_rebase.AmendFixupCommit,
interactive_rebase.AmendHeadCommitDuringRebase,