jesseduffield.lazygit/pkg/integration/tests/bisect/from_other_branch.go
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

47 lines
1.6 KiB
Go

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: []string{},
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").
StartBisect("other~2", "other~5")
},
SetupConfig: func(cfg *config.AppConfig) {},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Information().Content(Contains("Bisecting"))
t.Views().Commits().
Focus().
TopLines(
MatchesRegexp(`<-- bad.*commit-08`),
MatchesRegexp(`<-- current.*commit-07`),
MatchesRegexp(`\?.*commit-06`),
MatchesRegexp(`<-- good.*commit-05`),
).
SelectNextItem().
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")).Confirm()
t.Views().Information().Content(DoesNotContain("Bisecting"))
}).
// back in master branch which just had the one commit
Lines(
Contains("only commit on master"),
)
},
})