1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-21 12:16:54 +02:00

Add integration test

This commit is contained in:
Stefan Haller 2024-01-20 17:55:25 +01:00
parent 7c687938a5
commit 1ec87364fe
3 changed files with 63 additions and 0 deletions

View File

@ -41,6 +41,17 @@ func (self *CommitDescriptionPanelDriver) GoToBeginning() *CommitDescriptionPane
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)

View File

@ -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 <john@doe.com>").
Content(Equals("Here's my message.\n\nCo-authored-by: John Doe <john@doe.com>")).
AddCoAuthor("Jane Smith <jane@smith.com>").
// Second co-author doesn't add a blank line:
Content(Equals("Here's my message.\n\nCo-authored-by: John Doe <john@doe.com>\nCo-authored-by: Jane Smith <jane@smith.com>")).
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 <john@doe.com>"),
Equals(" Co-authored-by: Jane Smith <jane@smith.com>"),
)
})
},
})

View File

@ -64,6 +64,7 @@ var tests = []*components.IntegrationTest{
cherry_pick.CherryPickDuringRebase,
cherry_pick.CherryPickRange,
commit.AddCoAuthor,
commit.AddCoAuthorWhileCommitting,
commit.Amend,
commit.AutoWrapMessage,
commit.Commit,