2022-12-28 02:27:48 +02:00
|
|
|
package components
|
|
|
|
|
|
|
|
type CommitMessagePanelDriver struct {
|
|
|
|
t *TestDriver
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *CommitMessagePanelDriver) getViewDriver() *ViewDriver {
|
|
|
|
return self.t.Views().CommitMessage()
|
|
|
|
}
|
|
|
|
|
|
|
|
// asserts on the text initially present in the prompt
|
2023-02-25 04:08:45 +02:00
|
|
|
func (self *CommitMessagePanelDriver) InitialText(expected *Matcher) *CommitMessagePanelDriver {
|
2022-12-28 02:27:48 +02:00
|
|
|
self.getViewDriver().Content(expected)
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *CommitMessagePanelDriver) Type(value string) *CommitMessagePanelDriver {
|
|
|
|
self.t.typeContent(value)
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *CommitMessagePanelDriver) AddNewline() *CommitMessagePanelDriver {
|
|
|
|
self.t.press(self.t.keys.Universal.AppendNewline)
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *CommitMessagePanelDriver) Clear() *CommitMessagePanelDriver {
|
2023-02-23 13:29:40 +02:00
|
|
|
// 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.getViewDriver().getView().Buffer() == "" {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
self.t.press(ClearKey)
|
|
|
|
if i == maxAttempts {
|
|
|
|
panic("failed to clear commit message panel")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return self
|
2022-12-28 02:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *CommitMessagePanelDriver) Confirm() {
|
|
|
|
self.getViewDriver().PressEnter()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *CommitMessagePanelDriver) Cancel() {
|
|
|
|
self.getViewDriver().PressEscape()
|
|
|
|
}
|