mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-25 12:24:47 +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()
|
self.getViewDriver().PressEscape()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *CommitMessagePanelDriver) SwitchToEditor() {
|
||||||
|
self.getViewDriver().Press(self.t.keys.CommitMessage.SwitchToEditor)
|
||||||
|
}
|
||||||
|
|
||||||
func (self *CommitMessagePanelDriver) SelectPreviousMessage() *CommitMessagePanelDriver {
|
func (self *CommitMessagePanelDriver) SelectPreviousMessage() *CommitMessagePanelDriver {
|
||||||
self.getViewDriver().SelectPreviousItem()
|
self.getViewDriver().SelectPreviousItem()
|
||||||
return self
|
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.Amend,
|
||||||
commit.Commit,
|
commit.Commit,
|
||||||
commit.CommitMultiline,
|
commit.CommitMultiline,
|
||||||
|
commit.CommitSwitchToEditor,
|
||||||
commit.CommitWipWithPrefix,
|
commit.CommitWipWithPrefix,
|
||||||
commit.CommitWithPrefix,
|
commit.CommitWithPrefix,
|
||||||
commit.CreateTag,
|
commit.CreateTag,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user