summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/custom_commands
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-05-29 14:24:49 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-05-29 14:24:49 +1000
commit16fa22a36ef24e433e49426052e4156cb49064e0 (patch)
tree86935a929fc63ab02eea4e587e8b2eef185c6729 /pkg/integration/tests/custom_commands
parent8e6967c70273f838e4e200a61bdb631015d46bdc (diff)
Add suggestionsPreset to custom commands system
Diffstat (limited to 'pkg/integration/tests/custom_commands')
-rw-r--r--pkg/integration/tests/custom_commands/suggestions_preset.go64
1 files changed, 64 insertions, 0 deletions
diff --git a/pkg/integration/tests/custom_commands/suggestions_preset.go b/pkg/integration/tests/custom_commands/suggestions_preset.go
new file mode 100644
index 000000000..894e3b1fe
--- /dev/null
+++ b/pkg/integration/tests/custom_commands/suggestions_preset.go
@@ -0,0 +1,64 @@
+package custom_commands
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var SuggestionsPreset = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Using a custom command that uses a suggestions preset in a prompt step",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupRepo: func(shell *Shell) {
+ shell.NewBranch("branch-one")
+ shell.EmptyCommit("blah")
+ shell.NewBranch("branch-two")
+ shell.EmptyCommit("blah")
+ shell.NewBranch("branch-three")
+ shell.EmptyCommit("blah")
+ shell.NewBranch("branch-four")
+ shell.EmptyCommit("blah")
+ },
+ SetupConfig: func(cfg *config.AppConfig) {
+ cfg.UserConfig.CustomCommands = []config.CustomCommand{
+ {
+ Key: "a",
+ Context: "localBranches",
+ Command: `git checkout {{.Form.Branch}}`,
+ Prompts: []config.CustomCommandPrompt{
+ {
+ Key: "Branch",
+ Type: "input",
+ Title: "Enter a branch name",
+ SuggestionsPreset: "branches",
+ },
+ },
+ },
+ }
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Branches().
+ Focus().
+ Lines(
+ Contains("branch-four").IsSelected(),
+ Contains("branch-three"),
+ Contains("branch-two"),
+ Contains("branch-one"),
+ ).
+ Press("a")
+
+ t.ExpectPopup().Prompt().
+ Title(Equals("Enter a branch name")).
+ Type("three").
+ SuggestionLines(Contains("branch-three")).
+ ConfirmFirstSuggestion()
+
+ t.Views().Branches().
+ Lines(
+ Contains("branch-three").IsSelected(),
+ Contains("branch-four"),
+ Contains("branch-two"),
+ Contains("branch-one"),
+ )
+ },
+})