diff --git a/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go b/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go new file mode 100644 index 000000000..2c8b9302a --- /dev/null +++ b/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go @@ -0,0 +1,44 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var OfferResetWhenMergeBaseIsBad = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Offer to reset instead of showing the bisect menu when git stopped because the merge base is bad", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(2). + NewBranch("fixed"). + CreateNCommitsStartingAt(1, 3). + Checkout("master"). + CreateNCommitsStartingAt(2, 4). + // Git checks out the merge base commit-02 to test first. If it is + // bad, git can't find the first bad commit, and stops. + StartBisect("master", "fixed"). + RunCommandExpectError([]string{"git", "bisect", "bad"}) + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-05"), + Contains("CI commit-04"), + Contains("CI commit-02").Contains("<-- bad").IsSelected(), + Contains("CI commit-01"), + ). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + /* EXPECTED: + t.ExpectPopup().Confirmation().Title(Equals("Reset 'git bisect'")).Content(Equals("Are you sure you want to reset 'git bisect'?")).Cancel() + ACTUAL: */ + t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(Contains("Mark current commit")).Cancel() + }) + }, +}) diff --git a/pkg/integration/tests/bisect/show_result_again.go b/pkg/integration/tests/bisect/show_result_again.go new file mode 100644 index 000000000..ac2406732 --- /dev/null +++ b/pkg/integration/tests/bisect/show_result_again.go @@ -0,0 +1,41 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var ShowResultAgain = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Show the result of a finished bisect again instead of the bisect menu", + 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(). + SelectedLine(Contains("CI commit-08").Contains("<-- bad")). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + /* EXPECTED: + t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-08.*Do you want to reset")).Cancel() + ACTUAL: */ + t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(Contains("Mark current commit")).Cancel() + }) + + t.Views().Branches(). + Focus(). + Press(keys.Commits.ViewBisectOptions) + + t.ExpectToast(Equals("Disabled: Bisecting is in progress; use the commits panel")) + }, +}) diff --git a/pkg/integration/tests/bisect/show_result_when_found_right_away.go b/pkg/integration/tests/bisect/show_result_when_found_right_away.go new file mode 100644 index 000000000..98f4fd7a8 --- /dev/null +++ b/pkg/integration/tests/bisect/show_result_when_found_right_away.go @@ -0,0 +1,44 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var ShowResultWhenFoundRightAway = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Show the result instead of the bisect menu when git found the first bad commit without testing any", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(3). + // The good commit is the parent of the bad one, so git doesn't + // check out anything to test + StartBisect("HEAD", "HEAD~1") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-03").Contains("<-- bad").IsSelected(), + Contains("CI commit-02").Contains("<-- good"), + Contains("CI commit-01"), + ). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + /* EXPECTED: + t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-03.*Do you want to reset")).Cancel() + ACTUAL: */ + t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(MatchesRegexp(`b Mark commit [0-9a-f]+ as bad`)).Cancel() + }) + + t.Views().Branches(). + Focus(). + Press(keys.Commits.ViewBisectOptions) + + t.ExpectToast(Equals("Disabled: Bisecting is in progress; use the commits panel")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index b0aad9c53..4122c1188 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -39,10 +39,13 @@ var tests = []*components.IntegrationTest{ bisect.CheckOutBranchBeforeBisecting, bisect.ChooseTerms, bisect.FromOtherBranch, + bisect.OfferResetWhenMergeBaseIsBad, bisect.SelectCurrentCommit, bisect.SelectCurrentCommitInLongRange, bisect.SelectFirstBadCommit, bisect.SelectFirstBadCommitOnStartup, + bisect.ShowResultAgain, + bisect.ShowResultWhenFoundRightAway, bisect.Skip, bisect.StartFromBranches, bisect.StartFromSubCommitsAndReflog,