Files
Stefan Haller d181615c31 Make integration tests using commits more robust
Some tests assert that a specific commit subject does or doesn't occur
in the main view; interactive_rebase/outside_rebase_range_select.go is
an example for this, it asserts `t.Views().Main().Content(
DoesNotContain("commit 06"))`. The problem with this kind of assertion
and our test commit naming scheme is that the diff view begins with a
"commit <hash>" line, and when that hash happens to start with "06" the
assertion matched it and failed spuriously. This was usually masked by
our MaxAttempts=2 that we currently use for integration tests (it's
quite unlikely that the commit gets a hash beginning with "06" twice in
a row). However, we want to get to a state where we can set MaxAttempts
to 1, so make this more robust by changing our naming scheme.
2026-07-09 11:56:27 +02:00

91 lines
3.3 KiB
Go

package bisect
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Skip = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Start a git bisect and skip a few commits (selected or current)",
ExtraCmdArgs: []string{},
Skip: false,
SetupRepo: func(shell *Shell) {
shell.
CreateNCommits(10)
},
SetupConfig: func(cfg *config.AppConfig) {
cfg.GetUserConfig().Git.Log.ShowGraph = "never"
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
SelectedLine(Contains("commit-10")).
Press(keys.Commits.ViewBisectOptions).
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as bad`)).Confirm()
}).
NavigateToLine(Contains("commit-01")).
Press(keys.Commits.ViewBisectOptions).
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as good`)).Confirm()
t.Views().Information().Content(Contains("Bisecting"))
}).
Lines(
Contains("CI commit-10").Contains("<-- bad"),
Contains("CI commit-09").DoesNotContain("<--"),
Contains("CI commit-08").DoesNotContain("<--"),
Contains("CI commit-07").DoesNotContain("<--"),
Contains("CI commit-06").DoesNotContain("<--"),
Contains("CI commit-05").Contains("<-- current").IsSelected(),
Contains("CI commit-04").DoesNotContain("<--"),
Contains("CI commit-03").DoesNotContain("<--"),
Contains("CI commit-02").DoesNotContain("<--"),
Contains("CI commit-01").Contains("<-- good"),
).
Press(keys.Commits.ViewBisectOptions).
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Bisect")).
// Does not show a "Skip selected commit" entry:
Lines(
Contains("b Mark current commit").Contains("as bad"),
Contains("g Mark current commit").Contains("as good"),
Contains("s Skip current commit"),
Contains("r Reset bisect"),
Contains("Cancel"),
).
Select(Contains("Skip current commit")).Confirm()
}).
// Skipping the current commit selects the new current commit:
Lines(
Contains("CI commit-10").Contains("<-- bad"),
Contains("CI commit-09").DoesNotContain("<--"),
Contains("CI commit-08").DoesNotContain("<--"),
Contains("CI commit-07").DoesNotContain("<--"),
Contains("CI commit-06").Contains("<-- current").IsSelected(),
Contains("CI commit-05").Contains("<-- skipped"),
Contains("CI commit-04").DoesNotContain("<--"),
Contains("CI commit-03").DoesNotContain("<--"),
Contains("CI commit-02").DoesNotContain("<--"),
Contains("CI commit-01").Contains("<-- good"),
).
NavigateToLine(Contains("commit-07")).
Press(keys.Commits.ViewBisectOptions).
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Bisect")).
// Does show a "Skip selected commit" entry:
Lines(
Contains("b Mark current commit").Contains("as bad"),
Contains("g Mark current commit").Contains("as good"),
Contains("s Skip current commit"),
Contains("S Skip selected commit"),
Contains("r Reset bisect"),
Contains("Cancel"),
).
Select(Contains("Skip selected commit")).Confirm()
}).
// Skipping a selected, non-current commit keeps the selection
// there:
SelectedLine(Contains("CI commit-07").Contains("<-- skipped"))
},
})