diff options
Diffstat (limited to 'pkg/integration/tests')
-rw-r--r-- | pkg/integration/tests/custom_commands/history.go | 60 | ||||
-rw-r--r-- | pkg/integration/tests/test_list.go | 1 |
2 files changed, 61 insertions, 0 deletions
diff --git a/pkg/integration/tests/custom_commands/history.go b/pkg/integration/tests/custom_commands/history.go new file mode 100644 index 000000000..834892564 --- /dev/null +++ b/pkg/integration/tests/custom_commands/history.go @@ -0,0 +1,60 @@ +package custom_commands + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var History = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Test that the custom commands history is saved correctly", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) {}, + 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 1"). + Confirm() + + t.GlobalPress(keys.Universal.ExecuteCustomCommand) + t.ExpectPopup().Prompt(). + Title(Equals("Custom command:")). + SuggestionLines(Contains("1")). + Type("echo 2"). + Confirm() + + t.GlobalPress(keys.Universal.ExecuteCustomCommand) + t.ExpectPopup().Prompt(). + Title(Equals("Custom command:")). + SuggestionLines( + // "echo 2" was typed last, so it should come first + Contains("2"), + Contains("1"), + ). + Type("echo 3"). + Confirm() + + t.GlobalPress(keys.Universal.ExecuteCustomCommand) + t.ExpectPopup().Prompt(). + Title(Equals("Custom command:")). + SuggestionLines( + Contains("3"), + Contains("2"), + Contains("1"), + ). + Type("echo 1"). + Confirm() + + // Executing a command again should move it to the front: + t.GlobalPress(keys.Universal.ExecuteCustomCommand) + t.ExpectPopup().Prompt(). + Title(Equals("Custom command:")). + SuggestionLines( + Contains("1"), + Contains("3"), + Contains("2"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index a5e17c470..3abc41853 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -98,6 +98,7 @@ var tests = []*components.IntegrationTest{ custom_commands.CheckForConflicts, custom_commands.ComplexCmdAtRuntime, custom_commands.FormPrompts, + custom_commands.History, custom_commands.MenuFromCommand, custom_commands.MenuFromCommandsOutput, custom_commands.MultiplePrompts, |