summaryrefslogtreecommitdiffstats
path: root/pkg/integration
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-02-25 22:09:14 +1100
committerJesse Duffield <jessedduffield@gmail.com>2023-02-26 11:22:24 +1100
commitff3c5d331ecaaa5a9f372deda8877a92331dde7f (patch)
tree6aa51c4c070ddf01d1b37f34c1e0cb6928f10ccf /pkg/integration
parent33f9f81c8c83f33ef75ef5cd9dee7b842af07e64 (diff)
migrate merge conflict tests
Diffstat (limited to 'pkg/integration')
-rw-r--r--pkg/integration/tests/conflicts/filter.go38
-rw-r--r--pkg/integration/tests/conflicts/resolve_externally.go33
-rw-r--r--pkg/integration/tests/conflicts/resolve_multiple_files.go54
-rw-r--r--pkg/integration/tests/shared/conflicts.go40
-rw-r--r--pkg/integration/tests/tests_gen.go3
5 files changed, 156 insertions, 12 deletions
diff --git a/pkg/integration/tests/conflicts/filter.go b/pkg/integration/tests/conflicts/filter.go
new file mode 100644
index 000000000..b5f4b4c81
--- /dev/null
+++ b/pkg/integration/tests/conflicts/filter.go
@@ -0,0 +1,38 @@
+package conflicts
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+ "github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
+)
+
+var Filter = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Ensures that when there are merge conflicts, the files panel only shows conflicted files",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shared.CreateMergeConflictFiles(shell)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Files().
+ IsFocused().
+ Lines(
+ Contains("UU").Contains("file1").IsSelected(),
+ Contains("UU").Contains("file2"),
+ ).
+ Press(keys.Files.OpenStatusFilter).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Equals("Filtering")).
+ Select(Contains("Reset filter")).
+ Confirm()
+ }).
+ Lines(
+ Contains("UU").Contains("file1").IsSelected(),
+ Contains("UU").Contains("file2"),
+ // now we see the non-merge conflict file
+ Contains("A ").Contains("file3"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/conflicts/resolve_externally.go b/pkg/integration/tests/conflicts/resolve_externally.go
new file mode 100644
index 000000000..385e9ce4a
--- /dev/null
+++ b/pkg/integration/tests/conflicts/resolve_externally.go
@@ -0,0 +1,33 @@
+package conflicts
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+ "github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
+)
+
+var ResolveExternally = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Ensures that when merge conflicts are resolved outside of lazygit, lazygit prompts you to continue",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shared.CreateMergeConflictFile(shell)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Files().
+ IsFocused().
+ Lines(
+ Contains("UU file").IsSelected(),
+ ).
+ Tap(func() {
+ t.Shell().UpdateFile("file", "resolved content")
+ }).
+ Press(keys.Universal.Refresh)
+
+ t.Actions().ContinueOnConflictsResolved()
+
+ t.Views().Files().
+ IsEmpty()
+ },
+})
diff --git a/pkg/integration/tests/conflicts/resolve_multiple_files.go b/pkg/integration/tests/conflicts/resolve_multiple_files.go
new file mode 100644
index 000000000..2be35148e
--- /dev/null
+++ b/pkg/integration/tests/conflicts/resolve_multiple_files.go
@@ -0,0 +1,54 @@
+package conflicts
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+ "github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
+)
+
+var ResolveMultipleFiles = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Ensures that upon resolving conflicts for one file, the next file is selected",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shared.CreateMergeConflictFiles(shell)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Files().
+ IsFocused().
+ Lines(
+ Contains("UU").Contains("file1").IsSelected(),
+ Contains("UU").Contains("file2"),
+ ).
+ PressEnter()
+
+ t.Views().MergeConflicts().
+ IsFocused().
+ SelectedLines(
+ Contains("<<<<<<< HEAD"),
+ Contains("First Change"),
+ Contains("======="),
+ ).
+ PressPrimaryAction()
+
+ t.Views().Files().
+ IsFocused().
+ Lines(
+ Contains("UU").Contains("file2").IsSelected(),
+ ).
+ PressEnter()
+
+ // coincidentally these files have the same conflict
+ t.Views().MergeConflicts().
+ IsFocused().
+ SelectedLines(
+ Contains("<<<<<<< HEAD"),
+ Contains("First Change"),
+ Contains("======="),
+ ).
+ PressPrimaryAction()
+
+ t.Actions().ContinueOnConflictsResolved()
+ },
+})
diff --git a/pkg/integration/tests/shared/conflicts.go b/pkg/integration/tests/shared/conflicts.go
index 39a37cc37..76800a878 100644
--- a/pkg/integration/tests/shared/conflicts.go
+++ b/pkg/integration/tests/shared/conflicts.go
@@ -60,6 +60,33 @@ var CreateMergeCommit = func(shell *Shell) {
shell.ContinueMerge()
}
+// creates a merge conflict where there are two files with conflicts and a separate file without conflicts
+var CreateMergeConflictFiles = func(shell *Shell) {
+ shell.
+ NewBranch("original-branch").
+ EmptyCommit("one").
+ EmptyCommit("two").
+ EmptyCommit("three").
+ CreateFileAndAdd("file1", OriginalFileContent).
+ CreateFileAndAdd("file2", OriginalFileContent).
+ Commit("original").
+ NewBranch("first-change-branch").
+ UpdateFileAndAdd("file1", FirstChangeFileContent).
+ UpdateFileAndAdd("file2", FirstChangeFileContent).
+ Commit("first change").
+ Checkout("original-branch").
+ NewBranch("second-change-branch").
+ UpdateFileAndAdd("file1", SecondChangeFileContent).
+ UpdateFileAndAdd("file2", SecondChangeFileContent).
+ // this file is not changed in the second branch
+ CreateFileAndAdd("file3", "content").
+ Commit("second change").
+ EmptyCommit("second-change-branch unrelated change").
+ Checkout("first-change-branch")
+
+ shell.RunShellCommandExpectError("git merge --no-edit second-change-branch")
+}
+
// These 'multiple' variants are just like the short ones but with longer file contents and with multiple conflicts within the file.
var OriginalFileContentMultiple = `
@@ -110,8 +137,7 @@ Other
Other Second Change
`
-// prepares us for a rebase/merge that has conflicts
-var MergeConflictsSetupMultiple = func(shell *Shell) {
+var CreateMergeConflictFileMultiple = func(shell *Shell) {
shell.
NewBranch("original-branch").
EmptyCommit("one").
@@ -128,16 +154,6 @@ var MergeConflictsSetupMultiple = func(shell *Shell) {
Commit("second change").
EmptyCommit("second-change-branch unrelated change").
Checkout("first-change-branch")
-}
-
-var CreateMergeConflictFileMultiple = func(shell *Shell) {
- MergeConflictsSetupMultiple(shell)
shell.RunShellCommandExpectError("git merge --no-edit second-change-branch")
}
-
-var CreateMergeCommitMultiple = func(shell *Shell) {
- CreateMergeConflictFileMultiple(shell)
- shell.UpdateFileAndAdd("file", SecondChangeFileContentMultiple)
- shell.ContinueMerge()
-}
diff --git a/pkg/integration/tests/tests_gen.go b/pkg/integration/tests/tests_gen.go
index 16cf7d92a..dd1dfd70f 100644
--- a/pkg/integration/tests/tests_gen.go
+++ b/pkg/integration/tests/tests_gen.go
@@ -59,6 +59,9 @@ var tests = []*components.IntegrationTest{
commit.StagedWithoutHooks,
commit.Unstaged,
config.RemoteNamedStar,
+ conflicts.Filter,
+ conflicts.ResolveExternally,
+ conflicts.ResolveMultipleFiles,
conflicts.UndoChooseHunk,
custom_commands.Basic,
custom_commands.FormPrompts,