1
0
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:
Bruno Jesus
2025-01-28 00:34:57 +00:00
parent ef0d319686
commit 632695f71c
3 changed files with 92 additions and 0 deletions

View 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_"))
},
})

View 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_"))
},
})

View File

@@ -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,