summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/filter_and_search/filter_menu.go
blob: 59c47fb716d1a83315aabd6cbc7b32e47d28ed30 (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
package filter_and_search

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

var FilterMenu = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Filtering the keybindings menu",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateFile("myfile", "myfile")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			IsFocused().
			Lines(
				Contains(`??`).Contains(`myfile`).IsSelected(),
			).
			Press(keys.Universal.OptionMenu).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Keybindings")).
					Filter("Ignore").
					Lines(
						// menu has filtered down to the one item that matches the filter
						Contains(`--- Local ---`),
						Contains(`Ignore`).IsSelected(),
					).
					Confirm()

				t.ExpectPopup().Menu().
					Title(Equals("Ignore or exclude file")).
					Select(Contains("Add to .gitignore")).
					Confirm()
			})

		t.Views().Files().
			IsFocused().
			Lines(
				// file has been ignored
				Contains(`.gitignore`).IsSelected(),
			).
			// Upon opening the menu again, the filter should have been reset
			Press(keys.Universal.OptionMenu).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Keybindings")).
					LineCount(GreaterThan(1))
			})
	},
})