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

add another bisect integration test

This commit is contained in:
Jesse Duffield
2022-08-22 19:52:05 +10:00
parent 010f430d1f
commit 8cdfc6758f
134 changed files with 119 additions and 127 deletions

View File

@@ -44,6 +44,10 @@ func (s *Shell) NewBranch(name string) *Shell {
return s.RunCommand("git checkout -b " + name)
}
func (s *Shell) Checkout(name string) *Shell {
return s.RunCommand("git checkout " + name)
}
func (s *Shell) GitAdd(path string) *Shell {
return s.RunCommand(fmt.Sprintf("git add \"%s\"", path))
}

View File

@@ -0,0 +1,69 @@
package bisect
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Opening lazygit when bisect has been started from another branch. There's an issue where we don't reselect the current branch if we mark the current branch as bad so this test side-steps that problem",
ExtraCmdArgs: "",
Skip: false,
SetupRepo: func(shell *Shell) {
shell.
EmptyCommit("only commit on master"). // this'll ensure we have a master branch
NewBranch("other").
CreateNCommits(10).
Checkout("master").
RunCommand("git bisect start other~2 other~5")
},
SetupConfig: func(cfg *config.AppConfig) {},
Run: func(
shell *Shell,
input *Input,
assert *Assert,
keys config.KeybindingConfig,
) {
viewBisectOptions := func() {
input.PressKeys(keys.Commits.ViewBisectOptions)
assert.InMenu()
}
markCommitAsGood := func() {
viewBisectOptions()
assert.MatchSelectedLine(Contains("bad"))
input.NextItem()
assert.MatchSelectedLine(Contains("good"))
input.Confirm()
}
assert.MatchViewContent("information", Contains("bisecting"))
assert.AtLeastOneCommit()
input.SwitchToCommitsWindow()
assert.MatchSelectedLine(Contains("<-- bad"))
assert.MatchSelectedLine(Contains("commit 08"))
input.NextItem()
assert.MatchSelectedLine(Contains("<-- current"))
assert.MatchSelectedLine(Contains("commit 07"))
markCommitAsGood()
assert.InAlert()
assert.MatchCurrentViewContent(Contains("Bisect complete!"))
assert.MatchCurrentViewContent(Contains("commit 08"))
assert.MatchCurrentViewContent(Contains("Do you want to reset"))
input.Confirm()
assert.MatchViewContent("information", NotContains("bisecting"))
// back in master branch which just had the one commit
assert.CurrentViewName("commits")
assert.CommitCount(1)
assert.MatchSelectedLine(Contains("only commit on master"))
},
})

View File

@@ -29,6 +29,7 @@ var tests = []*components.IntegrationTest{
custom_commands.MultiplePrompts,
custom_commands.MenuFromCommand,
bisect.Basic,
bisect.FromOtherBranch,
}
func GetTests() []*components.IntegrationTest {