1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

migrate revert merge test

This commit is contained in:
Jesse Duffield
2023-02-19 14:47:07 +11:00
parent 88c76868ba
commit b5e325b0a4
43 changed files with 68 additions and 98 deletions

View File

@@ -36,6 +36,18 @@ func (self *MenuDriver) Select(option *matcher) *MenuDriver {
return self
}
func (self *MenuDriver) Lines(matchers ...*matcher) *MenuDriver {
self.getViewDriver().Lines(matchers...)
return self
}
func (self *MenuDriver) TopLines(matchers ...*matcher) *MenuDriver {
self.getViewDriver().TopLines(matchers...)
return self
}
func (self *MenuDriver) checkNecessaryChecksCompleted() {
if !self.hasCheckedTitle {
self.t.Fail("You must check the title of a menu popup by calling Title() before calling Confirm()/Cancel().")

View File

@@ -116,6 +116,10 @@ func (self *Shell) Merge(name string) *Shell {
return self.RunCommand("git merge --commit --no-ff " + name)
}
func (self *Shell) ContinueMerge() *Shell {
return self.RunCommand("git -c core.editor=true merge --continue")
}
func (self *Shell) GitAdd(path string) *Shell {
return self.RunCommand(fmt.Sprintf("git add \"%s\"", path))
}

View File

@@ -0,0 +1,43 @@
package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
"github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
)
var RevertMerge = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Reverts a merge commit and chooses to revert to the parent commit",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shared.CreateMergeCommit(shell)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().Focus().
TopLines(
Contains("Merge branch 'second-change-branch' into first-change-branch").IsSelected(),
).
Press(keys.Commits.RevertCommit)
t.ExpectPopup().Menu().
Title(Equals("Select parent commit for merge")).
Lines(
Contains("first change"),
Contains("second-change-branch unrelated change"),
Contains("cancel"),
).
Select(Contains("first change")).
Confirm()
t.Views().Commits().IsFocused().
TopLines(
Contains("Revert \"Merge branch 'second-change-branch' into first-change-branch\""),
Contains("Merge branch 'second-change-branch' into first-change-branch").IsSelected(),
).
SelectPreviousItem()
t.Views().Main().Content(Contains("-Second Change").Contains("+First Change"))
},
})

View File

@@ -47,3 +47,11 @@ var MergeConflictsSetup = func(shell *Shell) {
EmptyCommit("second-change-branch unrelated change").
Checkout("first-change-branch")
}
var CreateMergeCommit = func(shell *Shell) {
MergeConflictsSetup(shell)
shell.RunShellCommandExpectError("git merge --no-edit second-change-branch")
shell.UpdateFileAndAdd("file", SecondChangeFileContent)
shell.ContinueMerge()
}

View File

@@ -40,6 +40,7 @@ var tests = []*components.IntegrationTest{
commit.DiscardOldFileChange,
commit.NewBranch,
commit.Revert,
commit.RevertMerge,
commit.StageRangeOfLines,
commit.Staged,
commit.StagedWithoutHooks,