mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
migrate merge conflict tests
This commit is contained in:
38
pkg/integration/tests/conflicts/filter.go
Normal file
38
pkg/integration/tests/conflicts/filter.go
Normal file
@ -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"),
|
||||
)
|
||||
},
|
||||
})
|
33
pkg/integration/tests/conflicts/resolve_externally.go
Normal file
33
pkg/integration/tests/conflicts/resolve_externally.go
Normal file
@ -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()
|
||||
},
|
||||
})
|
54
pkg/integration/tests/conflicts/resolve_multiple_files.go
Normal file
54
pkg/integration/tests/conflicts/resolve_multiple_files.go
Normal file
@ -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()
|
||||
},
|
||||
})
|
@ -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()
|
||||
}
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user