mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-08 22:36:49 +02:00
Integration tests for copy tags to clipboard
Adds integration test in order to confirm if tags are being properly sent to the clipboard
This commit is contained in:
51
pkg/integration/tests/commit/copy_tag_to_clipboard.go
Normal file
51
pkg/integration/tests/commit/copy_tag_to_clipboard.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package commit
|
||||
|
||||
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 CopyTagToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Copy a commit tag to the clipboard",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
// Include delimiters around the text so that we can assert on the entire content
|
||||
config.GetUserConfig().OS.CopyToClipboardCmd = "echo _{{text}}_ > clipboard"
|
||||
},
|
||||
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.SetAuthor("John Doe", "john@doe.com")
|
||||
shell.EmptyCommit("commit")
|
||||
shell.CreateLightweightTag("tag1", "HEAD")
|
||||
shell.CreateLightweightTag("tag2", "HEAD")
|
||||
},
|
||||
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("commit").IsSelected(),
|
||||
).
|
||||
Press(keys.Commits.CopyCommitAttributeToClipboard)
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Copy to clipboard")).
|
||||
Select(Contains("Commit tags")).
|
||||
Confirm()
|
||||
|
||||
t.ExpectToast(Equals("Commit tags copied to clipboard"))
|
||||
|
||||
t.Views().Files().
|
||||
Focus().
|
||||
Press(keys.Files.RefreshFiles).
|
||||
Lines(
|
||||
Contains("clipboard").IsSelected(),
|
||||
)
|
||||
|
||||
t.Views().Main().Content(Contains("+_tag2"))
|
||||
t.Views().Main().Content(Contains("+tag1_"))
|
||||
},
|
||||
})
|
39
pkg/integration/tests/tag/copy_to_clipboard.go
Normal file
39
pkg/integration/tests/tag/copy_to_clipboard.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package tag
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Copy the tag to the clipboard",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
// Include delimiters around the text so that we can assert on the entire content
|
||||
config.GetUserConfig().OS.CopyToClipboardCmd = "echo _{{text}}_ > clipboard"
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("one")
|
||||
shell.CreateLightweightTag("tag1", "HEAD")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Tags().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("tag").IsSelected(),
|
||||
).
|
||||
Press(keys.Universal.CopyToClipboard)
|
||||
|
||||
t.ExpectToast(Equals("'tag1' copied to clipboard"))
|
||||
|
||||
t.Views().Files().
|
||||
Focus().
|
||||
Press(keys.Files.RefreshFiles).
|
||||
Lines(
|
||||
Contains("clipboard").IsSelected(),
|
||||
)
|
||||
|
||||
t.Views().Main().Content(Contains("_tag1_"))
|
||||
},
|
||||
})
|
@@ -93,6 +93,7 @@ var tests = []*components.IntegrationTest{
|
||||
commit.CommitWithNonMatchingBranchName,
|
||||
commit.CommitWithPrefix,
|
||||
commit.CopyAuthorToClipboard,
|
||||
commit.CopyTagToClipboard,
|
||||
commit.CreateAmendCommit,
|
||||
commit.CreateFixupCommitInBranchStack,
|
||||
commit.CreateTag,
|
||||
@@ -351,6 +352,7 @@ var tests = []*components.IntegrationTest{
|
||||
sync.RenameBranchAndPull,
|
||||
tag.Checkout,
|
||||
tag.CheckoutWhenBranchWithSameNameExists,
|
||||
tag.CopyToClipboard,
|
||||
tag.CreateWhileCommitting,
|
||||
tag.CrudAnnotated,
|
||||
tag.CrudLightweight,
|
||||
|
Reference in New Issue
Block a user