Skip to content

Commit 196e5bf

Browse files
committed
fixup! Add "CopyToClipboard" command to ConfirmationController
1 parent c0ff8b8 commit 196e5bf

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

pkg/integration/components/popup.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ func (self *Popup) Alert() *AlertDriver {
3636
return &AlertDriver{t: self.t}
3737
}
3838

39+
func (self *AlertDriver) Tap(f func()) *AlertDriver {
40+
self.getViewDriver().Tap(f)
41+
return self
42+
}
43+
3944
func (self *Popup) inAlert() {
4045
// basically the same thing as a confirmation popup with the current implementation
4146
self.t.assertWithRetries(func() (bool, string) {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package misc
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var CopyConfirmationMessageToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Copy the text of a confirmation popup to the clipboard",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {
13+
config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > clipboard"
14+
},
15+
16+
SetupRepo: func(shell *Shell) {
17+
shell.EmptyCommit("commit")
18+
},
19+
20+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
21+
t.Views().Commits().
22+
Focus().
23+
Lines(
24+
Contains("commit").IsSelected(),
25+
).
26+
Press(keys.Universal.Remove)
27+
28+
t.ExpectPopup().Alert().
29+
Title(Equals("Drop commit")).
30+
Content(Equals("Are you sure you want to drop the selected commit(s)?")).
31+
Tap(func() {
32+
t.GlobalPress(keys.Universal.CopyToClipboard)
33+
t.ExpectToast(Equals("Message copied to clipboard"))
34+
}).
35+
Confirm()
36+
37+
t.FileSystem().FileContent("clipboard",
38+
Equals("Are you sure you want to drop the selected commit(s)?"))
39+
},
40+
})

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ var tests = []*components.IntegrationTest{
299299
interactive_rebase.SwapWithConflict,
300300
interactive_rebase.ViewFilesOfTodoEntries,
301301
misc.ConfirmOnQuit,
302+
misc.CopyConfirmationMessageToClipboard,
302303
misc.CopyToClipboard,
303304
misc.DisabledKeybindings,
304305
misc.InitialOpen,

0 commit comments

Comments
 (0)