mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-07 22:02:56 +03:00
Add a unit test case for global context
This commit is contained in:
61
pkg/integration/tests/custom_commands/global_context.go
Normal file
61
pkg/integration/tests/custom_commands/global_context.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package custom_commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var GlobalContext = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Ensure global context works",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.EmptyCommit("my change")
|
||||||
|
},
|
||||||
|
SetupConfig: func(cfg *config.AppConfig) {
|
||||||
|
cfg.UserConfig.CustomCommands = []config.CustomCommand{
|
||||||
|
{
|
||||||
|
Key: "X",
|
||||||
|
Context: "global",
|
||||||
|
Command: "touch myfile",
|
||||||
|
ShowOutput: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
// commits
|
||||||
|
t.Views().Commits().
|
||||||
|
Focus().
|
||||||
|
Press("X")
|
||||||
|
|
||||||
|
t.Views().Files().
|
||||||
|
Focus().
|
||||||
|
Lines(Contains("myfile"))
|
||||||
|
|
||||||
|
t.Shell().DeleteFile("myfile")
|
||||||
|
t.GlobalPress(keys.Files.RefreshFiles)
|
||||||
|
|
||||||
|
// branches
|
||||||
|
t.Views().Branches().
|
||||||
|
Focus().
|
||||||
|
Press("X")
|
||||||
|
|
||||||
|
t.Views().Files().
|
||||||
|
Focus().
|
||||||
|
Lines(Contains("myfile"))
|
||||||
|
|
||||||
|
t.Shell().DeleteFile("myfile")
|
||||||
|
t.GlobalPress(keys.Files.RefreshFiles)
|
||||||
|
|
||||||
|
// files
|
||||||
|
t.Views().Files().
|
||||||
|
Focus().
|
||||||
|
Press("X")
|
||||||
|
|
||||||
|
t.Views().Files().
|
||||||
|
Focus().
|
||||||
|
Lines(Contains("myfile"))
|
||||||
|
|
||||||
|
t.Shell().DeleteFile("myfile")
|
||||||
|
},
|
||||||
|
})
|
@@ -122,6 +122,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
custom_commands.DeleteFromHistory,
|
custom_commands.DeleteFromHistory,
|
||||||
custom_commands.EditHistory,
|
custom_commands.EditHistory,
|
||||||
custom_commands.FormPrompts,
|
custom_commands.FormPrompts,
|
||||||
|
custom_commands.GlobalContext,
|
||||||
custom_commands.History,
|
custom_commands.History,
|
||||||
custom_commands.MenuFromCommand,
|
custom_commands.MenuFromCommand,
|
||||||
custom_commands.MenuFromCommandsOutput,
|
custom_commands.MenuFromCommandsOutput,
|
||||||
|
Reference in New Issue
Block a user