Skip to content

Commit 1ec8736

Browse files
committed
Add integration test
1 parent 7c68793 commit 1ec8736

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

pkg/integration/components/commit_description_panel_driver.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ func (self *CommitDescriptionPanelDriver) GoToBeginning() *CommitDescriptionPane
4141
return self
4242
}
4343

44+
func (self *CommitDescriptionPanelDriver) AddCoAuthor(author string) *CommitDescriptionPanelDriver {
45+
self.t.press(self.t.keys.CommitMessage.CommitMenu)
46+
self.t.ExpectPopup().Menu().Title(Equals("Commit Menu")).
47+
Select(Contains("Add co-author")).
48+
Confirm()
49+
self.t.ExpectPopup().Prompt().Title(Contains("Add co-author")).
50+
Type(author).
51+
Confirm()
52+
return self
53+
}
54+
4455
func (self *CommitDescriptionPanelDriver) Title(expected *TextMatcher) *CommitDescriptionPanelDriver {
4556
self.getViewDriver().Title(expected)
4657

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+
var AddCoAuthorWhileCommitting = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Add co-author while typing the commit message",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {
13+
},
14+
SetupRepo: func(shell *Shell) {
15+
shell.CreateFile("file", "file content")
16+
},
17+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
18+
t.Views().Files().
19+
IsFocused().
20+
PressPrimaryAction(). // stage file
21+
Press(keys.Files.CommitChanges)
22+
23+
t.ExpectPopup().CommitMessagePanel().
24+
Type("Subject").
25+
SwitchToDescription().
26+
Type("Here's my message.").
27+
AddCoAuthor("John Doe <[email protected]>").
28+
Content(Equals("Here's my message.\n\nCo-authored-by: John Doe <[email protected]>")).
29+
AddCoAuthor("Jane Smith <[email protected]>").
30+
// Second co-author doesn't add a blank line:
31+
Content(Equals("Here's my message.\n\nCo-authored-by: John Doe <[email protected]>\nCo-authored-by: Jane Smith <[email protected]>")).
32+
SwitchToSummary().
33+
Confirm()
34+
35+
t.Views().Commits().
36+
Lines(
37+
Contains("Subject"),
38+
).
39+
Focus().
40+
Tap(func() {
41+
t.Views().Main().ContainsLines(
42+
Equals(" Subject"),
43+
Equals(" "),
44+
Equals(" Here's my message."),
45+
Equals(" "),
46+
Equals(" Co-authored-by: John Doe <[email protected]>"),
47+
Equals(" Co-authored-by: Jane Smith <[email protected]>"),
48+
)
49+
})
50+
},
51+
})

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var tests = []*components.IntegrationTest{
6464
cherry_pick.CherryPickDuringRebase,
6565
cherry_pick.CherryPickRange,
6666
commit.AddCoAuthor,
67+
commit.AddCoAuthorWhileCommitting,
6768
commit.Amend,
6869
commit.AutoWrapMessage,
6970
commit.Commit,

0 commit comments

Comments
 (0)