1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-08 04:04:22 +02:00
lazygit/pkg/integration/components/menu_driver.go

56 lines
1.2 KiB
Go
Raw Normal View History

2022-12-28 02:27:48 +02:00
package components
type MenuDriver struct {
t *TestDriver
hasCheckedTitle bool
}
func (self *MenuDriver) getViewDriver() *ViewDriver {
return self.t.Views().Menu()
}
// asserts that the popup has the expected title
func (self *MenuDriver) Title(expected *TextMatcher) *MenuDriver {
2022-12-28 02:27:48 +02:00
self.getViewDriver().Title(expected)
self.hasCheckedTitle = true
return self
}
func (self *MenuDriver) Confirm() {
self.checkNecessaryChecksCompleted()
self.getViewDriver().PressEnter()
}
func (self *MenuDriver) Cancel() {
self.checkNecessaryChecksCompleted()
self.getViewDriver().PressEscape()
}
func (self *MenuDriver) Select(option *TextMatcher) *MenuDriver {
2023-02-26 02:49:15 +02:00
self.getViewDriver().NavigateToLine(option)
2022-12-28 02:27:48 +02:00
return self
}
func (self *MenuDriver) Lines(matchers ...*TextMatcher) *MenuDriver {
2023-02-19 05:47:07 +02:00
self.getViewDriver().Lines(matchers...)
return self
}
func (self *MenuDriver) TopLines(matchers ...*TextMatcher) *MenuDriver {
2023-02-19 05:47:07 +02:00
self.getViewDriver().TopLines(matchers...)
return self
}
2022-12-28 02:27:48 +02:00
func (self *MenuDriver) checkNecessaryChecksCompleted() {
if !self.hasCheckedTitle {
self.t.Fail("You must check the title of a menu popup by calling Title() before calling Confirm()/Cancel().")
}
}