mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-23 12:18:51 +02:00
Improve and adapt commit persistence test-cases
This commit is contained in:
parent
a32be7e9fa
commit
6065908b0d
@ -52,6 +52,11 @@ func (self *CommitDescriptionPanelDriver) AddCoAuthor(author string) *CommitDesc
|
|||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *CommitDescriptionPanelDriver) Clear() *CommitDescriptionPanelDriver {
|
||||||
|
self.getViewDriver().Clear()
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
func (self *CommitDescriptionPanelDriver) Title(expected *TextMatcher) *CommitDescriptionPanelDriver {
|
func (self *CommitDescriptionPanelDriver) Title(expected *TextMatcher) *CommitDescriptionPanelDriver {
|
||||||
self.getViewDriver().Title(expected)
|
self.getViewDriver().Title(expected)
|
||||||
|
|
||||||
|
@ -39,20 +39,7 @@ func (self *CommitMessagePanelDriver) SwitchToDescription() *CommitDescriptionPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitMessagePanelDriver) Clear() *CommitMessagePanelDriver {
|
func (self *CommitMessagePanelDriver) Clear() *CommitMessagePanelDriver {
|
||||||
// clearing multiple times in case there's multiple lines
|
self.getViewDriver().Clear()
|
||||||
// (the clear button only clears a single line at a time)
|
|
||||||
maxAttempts := 100
|
|
||||||
for i := 0; i < maxAttempts+1; i++ {
|
|
||||||
if self.getViewDriver().getView().Buffer() == "" {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
self.t.press(ClearKey)
|
|
||||||
if i == maxAttempts {
|
|
||||||
panic("failed to clear commit message panel")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,24 @@ func (self *ViewDriver) Title(expected *TextMatcher) *ViewDriver {
|
|||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *ViewDriver) Clear() *ViewDriver {
|
||||||
|
// clearing multiple times in case there's multiple lines
|
||||||
|
// (the clear button only clears a single line at a time)
|
||||||
|
maxAttempts := 100
|
||||||
|
for i := 0; i < maxAttempts+1; i++ {
|
||||||
|
if self.getView().Buffer() == "" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
self.t.press(ClearKey)
|
||||||
|
if i == maxAttempts {
|
||||||
|
panic("failed to clear view buffer")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
// asserts that the view has lines matching the given matchers. One matcher must be passed for each line.
|
// asserts that the view has lines matching the given matchers. One matcher must be passed for each line.
|
||||||
// If you only care about the top n lines, use the TopLines method instead.
|
// If you only care about the top n lines, use the TopLines method instead.
|
||||||
// If you only care about a subset of lines, use the ContainsLines method instead.
|
// If you only care about a subset of lines, use the ContainsLines method instead.
|
||||||
|
@ -28,6 +28,8 @@ var PreserveCommitMessage = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Type("second paragraph").
|
Type("second paragraph").
|
||||||
Cancel()
|
Cancel()
|
||||||
|
|
||||||
|
t.FileSystem().PathPresent(".git/LAZYGIT_PENDING_COMMIT")
|
||||||
|
|
||||||
t.Views().Files().
|
t.Views().Files().
|
||||||
IsFocused().
|
IsFocused().
|
||||||
Press(keys.Files.CommitChanges)
|
Press(keys.Files.CommitChanges)
|
||||||
@ -35,6 +37,22 @@ var PreserveCommitMessage = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
t.ExpectPopup().CommitMessagePanel().
|
t.ExpectPopup().CommitMessagePanel().
|
||||||
Content(Equals("my commit message")).
|
Content(Equals("my commit message")).
|
||||||
SwitchToDescription().
|
SwitchToDescription().
|
||||||
Content(Equals("first paragraph\n\nsecond paragraph"))
|
Content(Equals("first paragraph\n\nsecond paragraph")).
|
||||||
|
Clear().
|
||||||
|
SwitchToSummary().
|
||||||
|
Clear().
|
||||||
|
Cancel()
|
||||||
|
|
||||||
|
t.FileSystem().PathNotPresent(".git/LAZYGIT_PENDING_COMMIT")
|
||||||
|
|
||||||
|
t.Views().Files().
|
||||||
|
IsFocused().
|
||||||
|
Press(keys.Files.CommitChanges)
|
||||||
|
|
||||||
|
t.ExpectPopup().CommitMessagePanel().
|
||||||
|
Type("my new commit message").
|
||||||
|
Confirm()
|
||||||
|
|
||||||
|
t.FileSystem().PathNotPresent(".git/LAZYGIT_PENDING_COMMIT")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user