summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-02-25 21:00:29 +0100
committerStefan Haller <stefan@haller-berlin.de>2023-03-07 09:49:34 +0100
commit4ca012dbfbe0c6be33da36f442a4d7d10019fafd (patch)
tree254c973885b3cfe8d3727ac81feee9e5d804b5cb /pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go
parent6bd1c1d06807fced80ca0bdbc736c2da39ae3dcf (diff)
Add test for reverse-applying a patch that conflicts
The patch contains changes to two files; the first one conflicts, the second doesn't. Note how it only applies changes to the first file at this point in the branch; we'll fix this in the next commit. This test would fail on master for multiple reasons.
Diffstat (limited to 'pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go')
-rw-r--r--pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go91
1 files changed, 91 insertions, 0 deletions
diff --git a/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go b/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go
new file mode 100644
index 000000000..8c3e61a86
--- /dev/null
+++ b/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go
@@ -0,0 +1,91 @@
+package patch_building
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var ApplyInReverseWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Apply a custom patch in reverse, resulting in a conflict",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.CreateFileAndAdd("file1", "file1 content\n")
+ shell.CreateFileAndAdd("file2", "file2 content\n")
+ shell.Commit("first commit")
+ shell.UpdateFileAndAdd("file1", "file1 content\nmore file1 content\n")
+ shell.UpdateFileAndAdd("file2", "file2 content\nmore file2 content\n")
+ shell.Commit("second commit")
+ shell.UpdateFileAndAdd("file1", "file1 content\nmore file1 content\neven more file1\n")
+ shell.Commit("third commit")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("third commit").IsSelected(),
+ Contains("second commit"),
+ Contains("first commit"),
+ ).
+ NavigateToLine(Contains("second commit")).
+ PressEnter()
+
+ t.Views().CommitFiles().
+ IsFocused().
+ Lines(
+ Contains("M").Contains("file1").IsSelected(),
+ Contains("M").Contains("file2"),
+ ).
+ // Add both files to the patch; the first will conflict, the second won't
+ PressPrimaryAction().
+ SelectNextItem().
+ PressPrimaryAction()
+
+ t.Views().Information().Content(Contains("building patch"))
+
+ t.Views().PatchBuildingSecondary().Content(
+ Contains("+more file1 content").Contains("+more file2 content"))
+
+ t.Common().SelectPatchOption(Contains("apply patch in reverse"))
+
+ t.ExpectPopup().Alert().
+ Title(Equals("Error")).
+ Content(Contains("Applied patch to 'file1' with conflicts.").
+ DoesNotContain("Applied patch to 'file2' cleanly.")).
+ Confirm()
+
+ t.Views().Files().
+ Focus().
+ Lines(
+ Contains("UU").Contains("file1").IsSelected(),
+ ).
+ PressPrimaryAction()
+
+ t.Views().MergeConflicts().
+ IsFocused().
+ ContainsLines(
+ Contains("file1 content"),
+ Contains("<<<<<<< ours").IsSelected(),
+ Contains("more file1 content").IsSelected(),
+ Contains("even more file1").IsSelected(),
+ Contains("=======").IsSelected(),
+ Contains(">>>>>>> theirs"),
+ ).
+ SelectNextItem().
+ PressPrimaryAction()
+
+ t.Views().Files().
+ Focus().
+ Lines(
+ Contains("M").Contains("file1").IsSelected(),
+ )
+
+ t.Views().Main().
+ ContainsLines(
+ Contains(" file1 content"),
+ Contains("-more file1 content"),
+ Contains("-even more file1"),
+ )
+ },
+})