mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-04 03:48:07 +02:00
Add integration test
This commit is contained in:
parent
8f628296ad
commit
91ec42f3f8
@ -74,6 +74,10 @@ func (self *CommitMessagePanelDriver) Cancel() {
|
||||
self.getViewDriver().PressEscape()
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelDriver) SwitchToEditor() {
|
||||
self.getViewDriver().Press(self.t.keys.CommitMessage.SwitchToEditor)
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelDriver) SelectPreviousMessage() *CommitMessagePanelDriver {
|
||||
self.getViewDriver().SelectPreviousItem()
|
||||
return self
|
||||
|
54
pkg/integration/tests/commit/commit_switch_to_editor.go
Normal file
54
pkg/integration/tests/commit/commit_switch_to_editor.go
Normal file
@ -0,0 +1,54 @@
|
||||
package commit
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var CommitSwitchToEditor = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Commit, then switch from built-in commit message panel to editor",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFile("file1", "file1 content")
|
||||
shell.CreateFile("file2", "file2 content")
|
||||
|
||||
// Set an editor that appends a line to the existing message. Since
|
||||
// git adds all this "# Please enter the commit message for your changes"
|
||||
// stuff, this will result in an extra blank line before the added line.
|
||||
shell.SetConfig("core.editor", "sh -c 'echo third line >>.git/COMMIT_EDITMSG'")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
IsEmpty()
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
PressPrimaryAction(). // stage one of the files
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
t.ExpectPopup().CommitMessagePanel().
|
||||
Type("first line").
|
||||
SwitchToDescription().
|
||||
Type("second line").
|
||||
SwitchToSummary().
|
||||
SwitchToEditor()
|
||||
t.Views().Commits().
|
||||
Lines(
|
||||
Contains("first line"),
|
||||
)
|
||||
|
||||
t.Views().Commits().Focus()
|
||||
t.Views().Main().Content(MatchesRegexp(`first line\n\s*\n\s*second line\n\s*\n\s*third line`))
|
||||
|
||||
// Now check that the preserved commit message was cleared:
|
||||
t.Views().Files().
|
||||
Focus().
|
||||
PressPrimaryAction(). // stage the other file
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
t.ExpectPopup().CommitMessagePanel().
|
||||
InitialText(Equals(""))
|
||||
},
|
||||
})
|
@ -55,6 +55,7 @@ var tests = []*components.IntegrationTest{
|
||||
commit.Amend,
|
||||
commit.Commit,
|
||||
commit.CommitMultiline,
|
||||
commit.CommitSwitchToEditor,
|
||||
commit.CommitWipWithPrefix,
|
||||
commit.CommitWithPrefix,
|
||||
commit.CreateTag,
|
||||
|
Loading…
Reference in New Issue
Block a user