mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-29 22:48:24 +02:00
migrate more tests
This commit is contained in:
@@ -32,8 +32,7 @@ func (self *PromptDriver) Type(value string) *PromptDriver {
|
||||
}
|
||||
|
||||
func (self *PromptDriver) Clear() *PromptDriver {
|
||||
// TODO: soft-code this
|
||||
self.t.press("<c-u>")
|
||||
self.t.press(ClearKey)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
39
pkg/integration/components/search_driver.go
Normal file
39
pkg/integration/components/search_driver.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package components
|
||||
|
||||
// TODO: soft-code this
|
||||
const ClearKey = "<c-u>"
|
||||
|
||||
type SearchDriver struct {
|
||||
t *TestDriver
|
||||
}
|
||||
|
||||
func (self *SearchDriver) getViewDriver() *ViewDriver {
|
||||
return self.t.Views().Search()
|
||||
}
|
||||
|
||||
// asserts on the text initially present in the prompt
|
||||
func (self *SearchDriver) InitialText(expected *matcher) *SearchDriver {
|
||||
self.getViewDriver().Content(expected)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *SearchDriver) Type(value string) *SearchDriver {
|
||||
self.t.typeContent(value)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *SearchDriver) Clear() *SearchDriver {
|
||||
self.t.press(ClearKey)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *SearchDriver) Confirm() {
|
||||
self.getViewDriver().PressEnter()
|
||||
}
|
||||
|
||||
func (self *SearchDriver) Cancel() {
|
||||
self.getViewDriver().PressEscape()
|
||||
}
|
||||
@@ -179,7 +179,7 @@ func (self *Shell) StashWithMessage(message string) *Shell {
|
||||
}
|
||||
|
||||
func (self *Shell) SetConfig(key string, value string) *Shell {
|
||||
self.RunCommand(fmt.Sprintf(`git config --local "%s" %s`, key, value))
|
||||
self.RunCommand(fmt.Sprintf(`git config --local "%s" "%s"`, key, value))
|
||||
return self
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,19 @@ func (self *TestDriver) ExpectClipboard(matcher *matcher) {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *TestDriver) ExpectSearch() *SearchDriver {
|
||||
self.inSearch()
|
||||
|
||||
return &SearchDriver{t: self}
|
||||
}
|
||||
|
||||
func (self *TestDriver) inSearch() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "search", "Expected search prompt to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
// for making assertions through git itself
|
||||
func (self *TestDriver) Git() *Git {
|
||||
return &Git{assertionHelper: self.assertionHelper, shell: self.shell}
|
||||
|
||||
@@ -127,3 +127,7 @@ func (self *Views) Suggestions() *ViewDriver {
|
||||
func (self *Views) MergeConflicts() *ViewDriver {
|
||||
return self.byName("mergeConflicts")
|
||||
}
|
||||
|
||||
func (self *Views) Search() *ViewDriver {
|
||||
return self.byName("search")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user