diff --git a/pkg/integration/components/commit_description_panel_driver.go b/pkg/integration/components/commit_description_panel_driver.go index 0c4b2cfbb08..f00f3417080 100644 --- a/pkg/integration/components/commit_description_panel_driver.go +++ b/pkg/integration/components/commit_description_panel_driver.go @@ -31,6 +31,17 @@ func (self *CommitDescriptionPanelDriver) AddNewline() *CommitDescriptionPanelDr return self } +func (self *CommitDescriptionPanelDriver) AddCoAuthor(author string) *CommitDescriptionPanelDriver { + self.t.press(self.t.keys.CommitMessage.CommitMenu) + self.t.ExpectPopup().Menu().Title(Equals("Commit Menu")). + Select(Contains("Add co-author")). + Confirm() + self.t.ExpectPopup().Prompt().Title(Contains("Add co-author")). + Type(author). + Confirm() + return self +} + func (self *CommitDescriptionPanelDriver) Title(expected *TextMatcher) *CommitDescriptionPanelDriver { self.getViewDriver().Title(expected) diff --git a/pkg/integration/tests/commit/add_co_author_while_committing.go b/pkg/integration/tests/commit/add_co_author_while_committing.go new file mode 100644 index 00000000000..d817f00f079 --- /dev/null +++ b/pkg/integration/tests/commit/add_co_author_while_committing.go @@ -0,0 +1,51 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var AddCoAuthorWhileCommitting = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Add co-author while typing the commit message", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) { + }, + SetupRepo: func(shell *Shell) { + shell.CreateFile("file", "file content") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + PressPrimaryAction(). // stage file + Press(keys.Files.CommitChanges) + + t.ExpectPopup().CommitMessagePanel(). + Type("Subject"). + SwitchToDescription(). + Type("Here's my message."). + AddCoAuthor("John Doe "). + Content(Equals("Here's my message.\n\nCo-authored-by: John Doe ")). + AddCoAuthor("Jane Smith "). + // Second co-author doesn't add a blank line: + Content(Equals("Here's my message.\n\nCo-authored-by: John Doe \nCo-authored-by: Jane Smith ")). + SwitchToSummary(). + Confirm() + + t.Views().Commits(). + Lines( + Contains("Subject"), + ). + Focus(). + Tap(func() { + t.Views().Main().ContainsLines( + Equals(" Subject"), + Equals(" "), + Equals(" Here's my message."), + Equals(" "), + Equals(" Co-authored-by: John Doe "), + Equals(" Co-authored-by: Jane Smith "), + ) + }) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index e26a0731f2b..6dbb4af5661 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -64,6 +64,7 @@ var tests = []*components.IntegrationTest{ cherry_pick.CherryPickDuringRebase, cherry_pick.CherryPickRange, commit.AddCoAuthor, + commit.AddCoAuthorWhileCommitting, commit.Amend, commit.Commit, commit.CommitMultiline,