summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/bisect/from_other_branch.go
blob: 8759e28f3957016817f074ef03217636c4d8b1cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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: "",
	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").
			RunCommand("git bisect start other~2 other~5")
	},
	SetupConfig: func(cfg *config.AppConfig) {},
	Run: func(
		shell *Shell,
		t *TestDriver,
		keys config.KeybindingConfig,
	) {
		t.Views().Information().Content(Contains("bisecting"))

		t.Model().AtLeastOneCommit()

		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.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()

				t.ExpectAlert().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"),
			)
	},
})