mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-21 04:46:29 +03:00
The commit message panel handles pasted text differently from typed
text (see ba6cfc1f85), but integration tests couldn't simulate a
paste, so this had no tests. Let tests replay the events that a
terminal sends for a bracketed paste: the start of the paste, a key
press for each character, and the end of the paste.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.0 KiB
Go
77 lines
2.0 KiB
Go
package components
|
|
|
|
type CommitDescriptionPanelDriver struct {
|
|
t *TestDriver
|
|
}
|
|
|
|
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)
|
|
|
|
return self
|
|
}
|
|
|
|
// Paste the text the way a terminal does it, as opposed to pasting it with the
|
|
// commit menu
|
|
func (self *CommitDescriptionPanelDriver) Paste(text string) *CommitDescriptionPanelDriver {
|
|
self.t.paste(text)
|
|
|
|
return self
|
|
}
|
|
|
|
func (self *CommitDescriptionPanelDriver) SwitchToSummary() *CommitMessagePanelDriver {
|
|
self.getViewDriver().PressTab()
|
|
return &CommitMessagePanelDriver{t: self.t}
|
|
}
|
|
|
|
func (self *CommitDescriptionPanelDriver) AddNewline() *CommitDescriptionPanelDriver {
|
|
self.t.pressFast("<enter>")
|
|
return self
|
|
}
|
|
|
|
func (self *CommitDescriptionPanelDriver) GoToBeginning() *CommitDescriptionPanelDriver {
|
|
numLines := len(self.getViewDriver().getView().BufferLines())
|
|
for range numLines {
|
|
self.t.pressFast("<up>")
|
|
}
|
|
|
|
self.t.pressFast("<ctrl+a>")
|
|
return self
|
|
}
|
|
|
|
func (self *CommitDescriptionPanelDriver) AddCoAuthor(author string) *CommitDescriptionPanelDriver {
|
|
self.t.press(self.t.keys.CommitMessage.CommitMenu[0])
|
|
self.t.ExpectPopup().Menu().Title(Equals("Commit Menu")).
|
|
Select(Contains("Add co-author")).
|
|
Confirm()
|
|
self.t.ExpectPopup().Prompt().Title(Contains("Add co-author")).
|
|
Type(author).
|
|
Confirm()
|
|
return self
|
|
}
|
|
|
|
func (self *CommitDescriptionPanelDriver) Clear() *CommitDescriptionPanelDriver {
|
|
self.getViewDriver().Clear()
|
|
return self
|
|
}
|
|
|
|
func (self *CommitDescriptionPanelDriver) Title(expected *TextMatcher) *CommitDescriptionPanelDriver {
|
|
self.getViewDriver().Title(expected)
|
|
|
|
return self
|
|
}
|
|
|
|
func (self *CommitDescriptionPanelDriver) Cancel() {
|
|
self.getViewDriver().PressEscape()
|
|
}
|