1
0
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:
Jesse Duffield
2023-02-22 21:57:32 +11:00
parent 22c10479d5
commit eabe7f462a
258 changed files with 380 additions and 548 deletions

View File

@@ -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
}

View 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()
}

View File

@@ -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
}

View File

@@ -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}

View File

@@ -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")
}