summaryrefslogtreecommitdiffstats
path: root/pkg/integration
diff options
context:
space:
mode:
authorLuka Markušić <luka.markusic@microblink.com>2023-03-10 10:31:30 +0100
committerJesse Duffield <jessedduffield@gmail.com>2023-04-13 21:20:46 +1000
commit2b4ac986a247b3ef90a877c412d7e1974d88c8e2 (patch)
treeb49d5a018725542981b62bcf9c997c2cf333d3a4 /pkg/integration
parentcaedf574845513d96f30252535941b6de9351308 (diff)
Don't add custom command to history if it starts with space
Add tests for custom command with leading space
Diffstat (limited to 'pkg/integration')
-rw-r--r--pkg/integration/tests/custom_commands/basic_at_runtime.go35
-rw-r--r--pkg/integration/tests/custom_commands/basic_at_runtime_history.go38
-rw-r--r--pkg/integration/tests/custom_commands/basic_from_config.go (renamed from pkg/integration/tests/custom_commands/basic.go)2
-rw-r--r--pkg/integration/tests/test_list.go4
4 files changed, 77 insertions, 2 deletions
diff --git a/pkg/integration/tests/custom_commands/basic_at_runtime.go b/pkg/integration/tests/custom_commands/basic_at_runtime.go
new file mode 100644
index 000000000..96b9b9174
--- /dev/null
+++ b/pkg/integration/tests/custom_commands/basic_at_runtime.go
@@ -0,0 +1,35 @@
+package custom_commands
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var BasicCmdAtRuntime = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Using a custom command provided at runtime to create a new file",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("blah")
+ },
+ SetupConfig: func(cfg *config.AppConfig) {},
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Files().
+ IsEmpty().
+ IsFocused().
+ Press(keys.Universal.ExecuteCustomCommand)
+
+ t.ExpectPopup().Prompt().
+ Title(Equals("Custom Command:")).
+ Type("touch file.txt").
+ Confirm()
+
+ t.GlobalPress(keys.Files.RefreshFiles)
+
+ t.Views().Files().
+ IsFocused().
+ Lines(
+ Contains("file.txt"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/custom_commands/basic_at_runtime_history.go b/pkg/integration/tests/custom_commands/basic_at_runtime_history.go
new file mode 100644
index 000000000..40cf5b328
--- /dev/null
+++ b/pkg/integration/tests/custom_commands/basic_at_runtime_history.go
@@ -0,0 +1,38 @@
+package custom_commands
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var OmitFromHistory = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Omitting a runtime custom command from history if it begins with space",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("blah")
+ },
+ SetupConfig: func(cfg *config.AppConfig) {},
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.GlobalPress(keys.Universal.ExecuteCustomCommand)
+ t.ExpectPopup().Prompt().
+ Title(Equals("Custom Command:")).
+ Type("echo aubergine").
+ Confirm()
+
+ t.GlobalPress(keys.Universal.ExecuteCustomCommand)
+ t.ExpectPopup().Prompt().
+ Title(Equals("Custom Command:")).
+ SuggestionLines(Contains("aubergine")).
+ SuggestionLines(DoesNotContain("tangerine")).
+ Type(" echo tangerine").
+ Confirm()
+
+ t.GlobalPress(keys.Universal.ExecuteCustomCommand)
+ t.ExpectPopup().Prompt().
+ Title(Equals("Custom Command:")).
+ SuggestionLines(Contains("aubergine")).
+ SuggestionLines(DoesNotContain("tangerine")).
+ Cancel()
+ },
+})
diff --git a/pkg/integration/tests/custom_commands/basic.go b/pkg/integration/tests/custom_commands/basic_from_config.go
index ce500b9a6..0f15183d9 100644
--- a/pkg/integration/tests/custom_commands/basic.go
+++ b/pkg/integration/tests/custom_commands/basic_from_config.go
@@ -5,7 +5,7 @@ import (
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
-var Basic = NewIntegrationTest(NewIntegrationTestArgs{
+var BasicCmdFromConfig = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Using a custom command to create a new file",
ExtraCmdArgs: "",
Skip: false,
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index fae655cbc..b44246abf 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -64,7 +64,9 @@ var tests = []*components.IntegrationTest{
conflicts.ResolveExternally,
conflicts.ResolveMultipleFiles,
conflicts.UndoChooseHunk,
- custom_commands.Basic,
+ custom_commands.BasicCmdFromConfig,
+ custom_commands.BasicCmdAtRuntime,
+ custom_commands.OmitFromHistory,
custom_commands.FormPrompts,
custom_commands.MenuFromCommand,
custom_commands.MenuFromCommandsOutput,