mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-19 21:28:28 +02:00
We want to show an error when the user tries to invoke an action that expects only a single item to be selected. We're using the GetDisabledReason field to enforce this (as well as DisabledReason on menu items). I've created a ListControllerTrait to store some shared convenience functions for this.
39 lines
986 B
Go
39 lines
986 B
Go
package ui
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
)
|
|
|
|
var EmptyMenu = NewIntegrationTest(NewIntegrationTestArgs{
|
|
Description: "Verify that we don't crash on an empty menu",
|
|
ExtraCmdArgs: []string{},
|
|
Skip: false,
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
SetupRepo: func(shell *Shell) {
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
t.Views().Files().
|
|
IsFocused().
|
|
Press(keys.Universal.OptionMenu)
|
|
|
|
t.Views().Menu().
|
|
IsFocused().
|
|
// a string that filters everything out
|
|
FilterOrSearch("ljasldkjaslkdjalskdjalsdjaslkd").
|
|
IsEmpty().
|
|
Press(keys.Universal.Select).
|
|
Tap(func() {
|
|
t.ExpectToast(Equals("Disabled: No item selected"))
|
|
}).
|
|
// escape the search
|
|
PressEscape().
|
|
// escape the view
|
|
PressEscape()
|
|
|
|
// back in the files view, selecting the non-existing menu item was a no-op
|
|
t.Views().Files().
|
|
IsFocused()
|
|
},
|
|
})
|