1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/integration/tests/bisect/basic.go

60 lines
1.8 KiB
Go
Raw Normal View History

2022-08-22 11:34:02 +02:00
package bisect
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Basic = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Start a git bisect to find a bad commit",
ExtraCmdArgs: "",
Skip: false,
SetupRepo: func(shell *Shell) {
shell.
CreateNCommits(10)
},
SetupConfig: func(cfg *config.AppConfig) {},
2022-12-27 12:47:37 +02:00
Run: func(t *TestDriver, keys config.KeybindingConfig) {
2022-08-22 11:34:02 +02:00
markCommitAsBad := func() {
2022-12-27 12:35:36 +02:00
t.Views().Commits().
Press(keys.Commits.ViewBisectOptions)
2022-08-22 11:34:02 +02:00
2022-12-28 02:00:22 +02:00
t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as bad`)).Confirm()
2022-08-22 11:34:02 +02:00
}
markCommitAsGood := func() {
2022-12-27 12:35:36 +02:00
t.Views().Commits().
Press(keys.Commits.ViewBisectOptions)
2022-08-22 11:34:02 +02:00
2022-12-28 02:00:22 +02:00
t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
}
2022-08-22 11:34:02 +02:00
2022-12-27 12:35:36 +02:00
t.Views().Commits().
Focus().
SelectedLine(Contains("commit 10")).
2022-12-27 12:25:11 +02:00
NavigateToListItem(Contains("commit 09")).
Tap(func() {
markCommitAsBad()
2022-08-22 11:34:02 +02:00
2022-12-27 12:35:36 +02:00
t.Views().Information().Content(Contains("bisecting"))
2022-12-27 12:25:11 +02:00
}).
SelectedLine(Contains("<-- bad")).
2022-12-27 12:25:11 +02:00
NavigateToListItem(Contains("commit 02")).
Tap(markCommitAsGood).
// lazygit will land us in the commit between our good and bad commits.
SelectedLine(Contains("commit 05").Contains("<-- current")).
Tap(markCommitAsBad).
SelectedLine(Contains("commit 04").Contains("<-- current")).
Tap(func() {
markCommitAsGood()
// commit 5 is the culprit because we marked 4 as good and 5 as bad.
2022-12-28 02:00:22 +02:00
t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 05.*Do you want to reset")).Confirm()
2022-12-27 12:25:11 +02:00
}).
IsFocused().
Content(Contains("commit 04"))
2022-08-22 11:34:02 +02:00
2022-12-27 12:35:36 +02:00
t.Views().Information().Content(DoesNotContain("bisecting"))
2022-08-22 11:34:02 +02:00
},
})