1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/integration/tests/misc/copy_to_clipboard.go
Red S d7f84aed8a feat: add os.copyToClipboardCmd to allow for a custom command
Issue #1055

test: CopyPatchToClipboard (temporary commit for review)
2023-07-29 19:09:59 +10:00

45 lines
1.1 KiB
Go

package misc
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
// We're emulating the clipboard by writing to a file called clipboard
var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Copy a branch name to the clipboard using custom clipboard command template",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.UserConfig.OS.CopyToClipboardCmd = "echo {{text}} > clipboard"
},
SetupRepo: func(shell *Shell) {
shell.NewBranch("branch-a")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Focus().
Lines(
Contains("branch-a").IsSelected(),
).
Press(keys.Universal.CopyToClipboard)
t.Views().Files().
Focus()
t.GlobalPress(keys.Files.RefreshFiles)
// Expect to see the clipboard file with contents
t.Views().Files().
IsFocused().
Lines(
Contains("clipboard").IsSelected(),
)
t.Views().Main().Content(Contains("branch-a"))
},
})