mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
add prompt asserter
This commit is contained in:
@ -215,17 +215,16 @@ func (self *Input) NavigateToListItem(matcher *matcher) {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Input) InConfirm() *ConfirmationAsserter {
|
||||
func (self *Input) Confirmation() *ConfirmationAsserter {
|
||||
self.assert.InConfirm()
|
||||
|
||||
return &ConfirmationAsserter{assert: self.assert, input: self}
|
||||
}
|
||||
|
||||
func (self *Input) Prompt(title *matcher, textToType string) {
|
||||
func (self *Input) Prompt() *PromptAsserter {
|
||||
self.assert.InPrompt()
|
||||
self.assert.CurrentView().Title(title)
|
||||
self.Type(textToType)
|
||||
self.Confirm()
|
||||
|
||||
return &PromptAsserter{assert: self.assert, input: self}
|
||||
}
|
||||
|
||||
// type some text into a prompt, then switch to the suggestions panel and expect the first
|
||||
|
59
pkg/integration/components/prompt_asserter.go
Normal file
59
pkg/integration/components/prompt_asserter.go
Normal file
@ -0,0 +1,59 @@
|
||||
package components
|
||||
|
||||
type PromptAsserter struct {
|
||||
assert *Assert
|
||||
input *Input
|
||||
hasCheckedTitle bool
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) getViewAsserter() *ViewAsserter {
|
||||
return self.assert.View("confirmation")
|
||||
}
|
||||
|
||||
// asserts that the popup has the expected title
|
||||
func (self *PromptAsserter) Title(expected *matcher) *PromptAsserter {
|
||||
self.getViewAsserter().Title(expected)
|
||||
|
||||
self.hasCheckedTitle = true
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// asserts on the text initially present in the prompt
|
||||
func (self *PromptAsserter) InitialText(expected *matcher) *PromptAsserter {
|
||||
self.getViewAsserter().Content(expected)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) Confirm() *PromptAsserter {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.input.Confirm()
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) Cancel() *PromptAsserter {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.input.Press(self.input.keys.Universal.Return)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) Type(value string) *PromptAsserter {
|
||||
self.input.Type(value)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) Clear() *PromptAsserter {
|
||||
panic("Clear method not yet implemented!")
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) checkNecessaryChecksCompleted() {
|
||||
if !self.hasCheckedTitle {
|
||||
self.assert.Fail("You must check the title of a prompt popup by calling Title() before calling Confirm()/Cancel().")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user