diff --git a/pkg/integration/tests/bisect/select_first_bad_commit.go b/pkg/integration/tests/bisect/select_first_bad_commit.go new file mode 100644 index 000000000..1e76cba29 --- /dev/null +++ b/pkg/integration/tests/bisect/select_first_bad_commit.go @@ -0,0 +1,42 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SelectFirstBadCommit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Select the first bad commit when marking the last commit to test finishes the bisect", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(10). + StartBisect("HEAD~2", "HEAD~5") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + TopLines( + Contains("CI commit-10"), + Contains("CI commit-09"), + Contains("CI commit-08").Contains("<-- bad"), + Contains("CI commit-07").Contains("<-- current").IsSelected(), + Contains("CI commit-06"), + Contains("CI commit-05").Contains("<-- good"), + ). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as good`)).Confirm() + + t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-08.*Do you want to reset")).Cancel() + }). + /* EXPECTED: + SelectedLine(Contains("CI commit-08").Contains("<-- bad")) + ACTUAL: */ + SelectedLine(Contains("CI commit-07")) + }, +}) diff --git a/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go b/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go new file mode 100644 index 000000000..00d6f4919 --- /dev/null +++ b/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go @@ -0,0 +1,31 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SelectFirstBadCommitOnStartup = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Select the first bad commit when starting with a finished bisect", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(10). + StartBisect("HEAD~2", "HEAD~5"). + // Mark commit-07, the commit that git checked out to test. This + // finishes the bisect, because commit-08 is bad. + RunCommand([]string{"git", "bisect", "good"}) + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + /* EXPECTED: + SelectedLine(Contains("CI commit-08").Contains("<-- bad")) + ACTUAL: */ + SelectedLine(Contains("CI commit-07")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 987713b3c..b0aad9c53 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -41,6 +41,8 @@ var tests = []*components.IntegrationTest{ bisect.FromOtherBranch, bisect.SelectCurrentCommit, bisect.SelectCurrentCommitInLongRange, + bisect.SelectFirstBadCommit, + bisect.SelectFirstBadCommitOnStartup, bisect.Skip, bisect.StartFromBranches, bisect.StartFromSubCommitsAndReflog,