Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhaller committed Mar 3, 2024
1 parent 93d39c8 commit d36d887
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/integration/components/commit_description_panel_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
51 changes: 51 additions & 0 deletions pkg/integration/tests/commit/add_co_author_while_committing.go
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>").
Content(Equals("Here's my message.\n\nCo-authored-by: John Doe <[email protected]>")).
AddCoAuthor("Jane Smith <[email protected]>").
// Second co-author doesn't add a blank line:
Content(Equals("Here's my message.\n\nCo-authored-by: John Doe <[email protected]>\nCo-authored-by: Jane Smith <[email protected]>")).
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 <[email protected]>"),
Equals(" Co-authored-by: Jane Smith <[email protected]>"),
)
})
},
})
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var tests = []*components.IntegrationTest{
cherry_pick.CherryPickDuringRebase,
cherry_pick.CherryPickRange,
commit.AddCoAuthor,
commit.AddCoAuthorWhileCommitting,
commit.Amend,
commit.Commit,
commit.CommitMultiline,
Expand Down

0 comments on commit d36d887

Please sign in to comment.