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

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

var Reset = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Hard reset to another branch",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.NewBranch("current-branch")
		shell.EmptyCommit("root commit")

		shell.NewBranch("other-branch")
		shell.EmptyCommit("other-branch commit")

		shell.Checkout("current-branch")
		shell.EmptyCommit("current-branch commit")
	},
	Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
		assert.View("commits").Lines(
			Contains("current-branch commit"),
			Contains("root commit"),
		)

		input.SwitchToBranchesWindow()

		assert.CurrentView().Name("localBranches").Lines(
			Contains("current-branch"),
			Contains("other-branch"),
		)
		input.NextItem()

		input.Press(keys.Commits.ViewResetOptions)

		input.Menu(Contains("reset to other-branch"), Contains("hard reset"))

		// ensure that we've returned from the menu before continuing
		assert.CurrentView().Name("localBranches")

		// assert that we now have the expected commits in the commit panel
		input.SwitchToCommitsWindow()
		assert.CurrentView().Name("commits").Lines(
			Contains("other-branch commit"),
			Contains("root commit"),
		)
	},
})