summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/conflicts/undo_choose_hunk.go
blob: c03f79cf68af9eae2de1b82e56cc50c858035b7c (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
package conflicts

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

var UndoChooseHunk = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Chooses a hunk when resolving a merge conflict and then undoes the choice",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shared.CreateMergeConflictFileMultiple(shell)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			IsFocused().
			Lines(
				Contains("UU file").IsSelected(),
			).
			PressEnter()

		t.Views().MergeConflicts().
			IsFocused().
			Content(Contains("<<<<<<< HEAD\nFirst Change")).
			// explicitly asserting on the selection because sometimes the content renders
			// before the selection is ready for user input
			SelectedLines(
				Contains("<<<<<<< HEAD"),
				Contains("First Change"),
				Contains("======="),
			).
			PressPrimaryAction().
			// choosing the first hunk
			Content(DoesNotContain("<<<<<<< HEAD\nFirst Change")).
			Press(keys.Universal.Undo).
			Content(Contains("<<<<<<< HEAD\nFirst Change"))
	},
})