summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/bisect/skip.go
blob: ff4c5c1b261d4f414e84eed4311a34b3fc77b894 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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.UserConfig.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"))
	},
})