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

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

var RebaseCopiedBranch = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Make a copy of a branch, rebase it, check that the original branch is unaffected",
	ExtraCmdArgs: []string{},
	Skip:         false,
	GitVersion:   AtLeast("2.38.0"),
	SetupConfig: func(config *config.AppConfig) {
		config.AppState.GitLogShowGraph = "never"
	},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("master 1").
			EmptyCommit("master 2").
			NewBranchFrom("branch1", "master^").
			EmptyCommit("branch 1").
			EmptyCommit("branch 2").
			NewBranch("branch2")

		shell.SetConfig("rebase.updateRefs", "true")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Lines(
			Contains("CI * branch 2"),
			Contains("CI branch 1"),
			Contains("CI master 1"),
		)

		t.Views().Branches().
			Focus().
			Lines(
				Contains("branch2").IsSelected(),
				Contains("branch1"),
				Contains("master"),
			).
			NavigateToLine(Contains("master")).
			Press(keys.Branches.RebaseBranch).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Rebase 'branch2' onto 'master'")).
					Select(Contains("Simple rebase")).
					Confirm()
			})

		t.Views().Commits().Lines(
			Contains("CI branch 2"),
			Contains("CI branch 1"),
			Contains("CI master 2"),
			Contains("CI master 1"),
		)

		t.Views().Branches().
			Focus().
			NavigateToLine(Contains("branch1")).
			PressPrimaryAction()

		t.Views().Commits().Lines(
			Contains("CI branch 2"),
			Contains("CI branch 1"),
			Contains("CI master 1"),
		)
	},
})