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

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

var UnsetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Unset upstream of selected branch, both when it exists and when it doesn't",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("one").
			NewBranch("branch_to_remove").
			Checkout("master").
			CloneIntoRemote("origin").
			SetBranchUpstream("master", "origin/master").
			SetBranchUpstream("branch_to_remove", "origin/branch_to_remove").
			// to get the "(upstream gone)" branch status
			RunCommand([]string{"git", "push", "origin", "--delete", "branch_to_remove"})
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Press(keys.Universal.NextScreenMode). // we need to enlargen the window to see the upstream
			SelectedLines(
				Contains("master").Contains("origin master"),
			).
			Press(keys.Branches.SetUpstream).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Upstream options")).
					Select(Contains("Unset upstream of selected branch")).
					Confirm()
			}).
			SelectedLines(
				Contains("master").DoesNotContain("origin master"),
			)

		t.Views().Branches().
			Focus().
			SelectNextItem().
			SelectedLines(
				Contains("branch_to_remove").Contains("origin branch_to_remove").Contains("upstream gone"),
			).
			Press(keys.Branches.SetUpstream).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Upstream options")).
					Select(Contains("Unset upstream of selected branch")).
					Confirm()
			}).
			SelectedLines(
				Contains("branch_to_remove").DoesNotContain("origin branch_to_remove").DoesNotContain("upstream gone"),
			)
	},
})