summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/branch/rebase_from_marked_base.go
blob: c2ee307e3e774c1316f92d052199c6afab257054 (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
package branch

import (
	"github.com/jesseduffield/lazygit/pkg/config"
	. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var RebaseFromMarkedBase = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Rebase onto another branch from a marked base commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.
			NewBranch("base-branch").
			EmptyCommit("one").
			EmptyCommit("two").
			EmptyCommit("three").
			NewBranch("active-branch").
			EmptyCommit("active one").
			EmptyCommit("active two").
			EmptyCommit("active three").
			Checkout("base-branch").
			NewBranch("target-branch").
			EmptyCommit("target one").
			EmptyCommit("target two").
			Checkout("active-branch")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains("active three"),
				Contains("active two"),
				Contains("active one"),
				Contains("three"),
				Contains("two"),
				Contains("one"),
			).
			NavigateToLine(Contains("active one")).
			Press(keys.Commits.MarkCommitAsBaseForRebase).
			Lines(
				Contains("active three").Contains("✓"),
				Contains("active two").Contains("✓"),
				Contains("↑↑↑ Will rebase from here ↑↑↑ active one"),
				Contains("three").DoesNotContain("✓"),
				Contains("two").DoesNotContain("✓"),
				Contains("one").DoesNotContain("✓"),
			)

		t.Views().Information().Content(Contains("Marked a base commit for rebase"))

		t.Views().Branches().
			Focus().
			Lines(
				Contains("active-branch"),
				Contains("target-branch"),
				Contains("base-branch"),
			).
			SelectNextItem().
			Press(keys.Branches.RebaseBranch)

		t.ExpectPopup().Menu().
			Title(Equals("Rebase 'active-branch' from marked base onto 'target-branch'")).
			Select(Contains("Simple rebase")).
			Confirm()

		t.Views().Commits().Lines(
			Contains("active three").DoesNotContain("✓"),
			Contains("active two").DoesNotContain("✓"),
			Contains("target two").DoesNotContain("✓"),
			Contains("target one").DoesNotContain("✓"),
			Contains("three").DoesNotContain("✓"),
			Contains("two").DoesNotContain("✓"),
			Contains("one").DoesNotContain("✓"),
		)
	},
})