Skip to content

Commit 9b2a0c4

Browse files
committed
Add test for copying a commit author to the clipboard
The test shows that we are including single quotes in strange places.
1 parent a04ad24 commit 9b2a0c4

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package commit
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
// We're emulating the clipboard by writing to a file called clipboard
9+
10+
var CopyAuthorToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
11+
Description: "Copy a commit author name to the clipboard",
12+
ExtraCmdArgs: []string{},
13+
Skip: false,
14+
SetupConfig: func(config *config.AppConfig) {
15+
// Include delimiters around the text so that we can assert on the entire content
16+
config.GetUserConfig().OS.CopyToClipboardCmd = "echo /{{text}}/ > clipboard"
17+
},
18+
19+
SetupRepo: func(shell *Shell) {
20+
shell.SetAuthor("John Doe", "[email protected]")
21+
shell.EmptyCommit("commit")
22+
},
23+
24+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
25+
t.Views().Commits().
26+
Focus().
27+
Lines(
28+
Contains("commit").IsSelected(),
29+
).
30+
Press(keys.Commits.CopyCommitAttributeToClipboard)
31+
32+
t.ExpectPopup().Menu().
33+
Title(Equals("Copy to clipboard")).
34+
Select(Contains("Commit author")).
35+
Confirm()
36+
37+
t.ExpectToast(Equals("Commit author copied to clipboard"))
38+
39+
t.Views().Files().
40+
Focus().
41+
Press(keys.Files.RefreshFiles).
42+
Lines(
43+
Contains("clipboard").IsSelected(),
44+
)
45+
46+
/* EXPECTED:
47+
t.Views().Main().Content(Contains("/John Doe <[email protected]>/"))
48+
ACTUAL: */
49+
t.Views().Main().Content(Contains("/'John Doe <[email protected]'>/"))
50+
},
51+
})

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ var tests = []*components.IntegrationTest{
8787
commit.CommitWithGlobalPrefix,
8888
commit.CommitWithNonMatchingBranchName,
8989
commit.CommitWithPrefix,
90+
commit.CopyAuthorToClipboard,
9091
commit.CreateAmendCommit,
9192
commit.CreateFixupCommitInBranchStack,
9293
commit.CreateTag,

0 commit comments

Comments
 (0)