mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-08 04:04:22 +02:00
Add test demonstrating a bug with preserving the commit message
SplitCommitMessageAndDescription splits at the first '\n\n' that it finds (if there is one), which in this case is between the two paragraphs of the description. This is wrong.
This commit is contained in:
parent
9a423c388d
commit
3ebba5f32c
@ -8,6 +8,13 @@ func (self *CommitDescriptionPanelDriver) getViewDriver() *ViewDriver {
|
||||
return self.t.Views().CommitDescription()
|
||||
}
|
||||
|
||||
// asserts on the current context of the description
|
||||
func (self *CommitDescriptionPanelDriver) Content(expected *TextMatcher) *CommitDescriptionPanelDriver {
|
||||
self.getViewDriver().Content(expected)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *CommitDescriptionPanelDriver) Type(value string) *CommitDescriptionPanelDriver {
|
||||
self.t.typeContent(value)
|
||||
|
||||
@ -29,3 +36,7 @@ func (self *CommitDescriptionPanelDriver) Title(expected *TextMatcher) *CommitDe
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *CommitDescriptionPanelDriver) Cancel() {
|
||||
self.getViewDriver().PressEscape()
|
||||
}
|
||||
|
48
pkg/integration/tests/commit/preserve_commit_message.go
Normal file
48
pkg/integration/tests/commit/preserve_commit_message.go
Normal file
@ -0,0 +1,48 @@
|
||||
package commit
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var PreserveCommitMessage = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Test that the commit message is preserved correctly when canceling the commit message panel",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFileAndAdd("myfile", "myfile content")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
t.ExpectPopup().CommitMessagePanel().
|
||||
InitialText(Equals("")).
|
||||
Type("my commit message").
|
||||
SwitchToDescription().
|
||||
Type("first paragraph").
|
||||
AddNewline().
|
||||
AddNewline().
|
||||
Type("second paragraph").
|
||||
Cancel()
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
/* EXPECTED:
|
||||
t.ExpectPopup().CommitMessagePanel().
|
||||
Content(Equals("my commit message")).
|
||||
SwitchToDescription().
|
||||
Content(Equals("first paragraph\n\nsecond paragraph"))
|
||||
|
||||
ACTUAL:
|
||||
*/
|
||||
t.ExpectPopup().CommitMessagePanel().
|
||||
Content(Equals("my commit message\nfirst paragraph")).
|
||||
SwitchToDescription().
|
||||
Content(Equals("second paragraph"))
|
||||
},
|
||||
})
|
@ -74,6 +74,7 @@ var tests = []*components.IntegrationTest{
|
||||
commit.History,
|
||||
commit.HistoryComplex,
|
||||
commit.NewBranch,
|
||||
commit.PreserveCommitMessage,
|
||||
commit.ResetAuthor,
|
||||
commit.Revert,
|
||||
commit.RevertMerge,
|
||||
|
Loading…
Reference in New Issue
Block a user