summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/stash/apply_patch.go
blob: 4c7a19841570e57fa72d0b79c63598c79c4e4e05 (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
package stash

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

var ApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Restore part of a stash entry via applying a custom patch",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("initial commit")
		shell.CreateFile("myfile", "content")
		shell.CreateFile("myfile2", "content")
		shell.GitAddAll()
		shell.Stash("stash one")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().IsEmpty()

		t.Views().Stash().
			Focus().
			Lines(
				Contains("stash one").IsSelected(),
			).
			PressEnter().
			Tap(func() {
				t.Views().CommitFiles().
					IsFocused().
					Lines(
						Contains("myfile").IsSelected(),
						Contains("myfile2"),
					).
					PressPrimaryAction()

				t.Views().Information().Content(Contains("building patch"))

				t.Views().
					CommitFiles().
					Press(keys.Universal.CreatePatchOptionsMenu)

				t.ExpectPopup().Menu().
					Title(Equals("Patch Options")).
					Select(MatchesRegexp(`apply patch$`)).Confirm()
			})

		t.Views().Files().Lines(
			Contains("myfile"),
		)
	},
})