mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
add view asserter getter struct
This commit is contained in:
@ -8,7 +8,7 @@ type AlertAsserter struct {
|
||||
}
|
||||
|
||||
func (self *AlertAsserter) getViewAsserter() *ViewAsserter {
|
||||
return self.assert.View("confirmation")
|
||||
return self.assert.Views().ByName("confirmation")
|
||||
}
|
||||
|
||||
// asserts that the alert view has the expected title
|
||||
|
@ -182,34 +182,44 @@ func (self *Assert) FileSystemPathNotPresent(path string) {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) CurrentView() *ViewAsserter {
|
||||
func (self *Assert) Views() *ViewAsserterGetter {
|
||||
return &ViewAsserterGetter{
|
||||
assert: self,
|
||||
}
|
||||
}
|
||||
|
||||
type ViewAsserterGetter struct {
|
||||
assert *Assert
|
||||
}
|
||||
|
||||
func (self *ViewAsserterGetter) Current() *ViewAsserter {
|
||||
return &ViewAsserter{
|
||||
context: "current view",
|
||||
getView: func() *gocui.View { return self.gui.CurrentContext().GetView() },
|
||||
assert: self,
|
||||
getView: func() *gocui.View { return self.assert.gui.CurrentContext().GetView() },
|
||||
assert: self.assert,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Assert) View(viewName string) *ViewAsserter {
|
||||
return &ViewAsserter{
|
||||
context: fmt.Sprintf("%s view", viewName),
|
||||
getView: func() *gocui.View { return self.gui.View(viewName) },
|
||||
assert: self,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Assert) MainView() *ViewAsserter {
|
||||
func (self *ViewAsserterGetter) Main() *ViewAsserter {
|
||||
return &ViewAsserter{
|
||||
context: "main view",
|
||||
getView: func() *gocui.View { return self.gui.MainView() },
|
||||
assert: self,
|
||||
getView: func() *gocui.View { return self.assert.gui.MainView() },
|
||||
assert: self.assert,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Assert) SecondaryView() *ViewAsserter {
|
||||
func (self *ViewAsserterGetter) Secondary() *ViewAsserter {
|
||||
return &ViewAsserter{
|
||||
context: "secondary view",
|
||||
getView: func() *gocui.View { return self.gui.SecondaryView() },
|
||||
assert: self,
|
||||
getView: func() *gocui.View { return self.assert.gui.SecondaryView() },
|
||||
assert: self.assert,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ViewAsserterGetter) ByName(viewName string) *ViewAsserter {
|
||||
return &ViewAsserter{
|
||||
context: fmt.Sprintf("%s view", viewName),
|
||||
getView: func() *gocui.View { return self.assert.gui.View(viewName) },
|
||||
assert: self.assert,
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ type CommitMessagePanelAsserter struct {
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelAsserter) getViewAsserter() *ViewAsserter {
|
||||
return self.assert.View("commitMessage")
|
||||
return self.assert.Views().ByName("commitMessage")
|
||||
}
|
||||
|
||||
// asserts on the text initially present in the prompt
|
||||
|
@ -8,7 +8,7 @@ type ConfirmationAsserter struct {
|
||||
}
|
||||
|
||||
func (self *ConfirmationAsserter) getViewAsserter() *ViewAsserter {
|
||||
return self.assert.View("confirmation")
|
||||
return self.assert.Views().ByName("confirmation")
|
||||
}
|
||||
|
||||
// asserts that the confirmation view has the expected title
|
||||
|
@ -48,7 +48,7 @@ func (self *Input) SwitchToStatusWindow() {
|
||||
// switch to status window and assert that the status view is on top
|
||||
func (self *Input) SwitchToStatusView() {
|
||||
self.SwitchToStatusWindow()
|
||||
self.assert.CurrentView().Name("status")
|
||||
self.assert.Views().Current().Name("status")
|
||||
}
|
||||
|
||||
func (self *Input) SwitchToFilesWindow() {
|
||||
@ -59,7 +59,7 @@ func (self *Input) SwitchToFilesWindow() {
|
||||
// switch to files window and assert that the files view is on top
|
||||
func (self *Input) SwitchToFilesView() {
|
||||
self.SwitchToFilesWindow()
|
||||
self.assert.CurrentView().Name("files")
|
||||
self.assert.Views().Current().Name("files")
|
||||
}
|
||||
|
||||
func (self *Input) SwitchToBranchesWindow() {
|
||||
@ -70,7 +70,7 @@ func (self *Input) SwitchToBranchesWindow() {
|
||||
// switch to branches window and assert that the branches view is on top
|
||||
func (self *Input) SwitchToBranchesView() {
|
||||
self.SwitchToBranchesWindow()
|
||||
self.assert.CurrentView().Name("localBranches")
|
||||
self.assert.Views().Current().Name("localBranches")
|
||||
}
|
||||
|
||||
func (self *Input) SwitchToCommitsWindow() {
|
||||
@ -81,7 +81,7 @@ func (self *Input) SwitchToCommitsWindow() {
|
||||
// switch to commits window and assert that the commits view is on top
|
||||
func (self *Input) SwitchToCommitsView() {
|
||||
self.SwitchToCommitsWindow()
|
||||
self.assert.CurrentView().Name("commits")
|
||||
self.assert.Views().Current().Name("commits")
|
||||
}
|
||||
|
||||
func (self *Input) SwitchToStashWindow() {
|
||||
@ -92,7 +92,7 @@ func (self *Input) SwitchToStashWindow() {
|
||||
// switch to stash window and assert that the stash view is on top
|
||||
func (self *Input) SwitchToStashView() {
|
||||
self.SwitchToStashWindow()
|
||||
self.assert.CurrentView().Name("stash")
|
||||
self.assert.Views().Current().Name("stash")
|
||||
}
|
||||
|
||||
func (self *Input) Type(content string) {
|
||||
@ -133,7 +133,7 @@ func (self *Input) PreviousItem() {
|
||||
|
||||
func (self *Input) ContinueMerge() {
|
||||
self.Press(self.keys.Universal.CreateRebaseOptionsMenu)
|
||||
self.assert.CurrentView().SelectedLine(Contains("continue"))
|
||||
self.assert.Views().Current().SelectedLine(Contains("continue"))
|
||||
self.Confirm()
|
||||
}
|
||||
|
||||
@ -197,20 +197,20 @@ func (self *Input) NavigateToListItem(matcher *matcher) {
|
||||
|
||||
selectedLineIdx := view.SelectedLineIdx()
|
||||
if selectedLineIdx == matchIndex {
|
||||
self.assert.CurrentView().SelectedLine(matcher)
|
||||
self.assert.Views().Current().SelectedLine(matcher)
|
||||
return
|
||||
}
|
||||
if selectedLineIdx < matchIndex {
|
||||
for i := selectedLineIdx; i < matchIndex; i++ {
|
||||
self.NextItem()
|
||||
}
|
||||
self.assert.CurrentView().SelectedLine(matcher)
|
||||
self.assert.Views().Current().SelectedLine(matcher)
|
||||
return
|
||||
} else {
|
||||
for i := selectedLineIdx; i > matchIndex; i-- {
|
||||
self.PreviousItem()
|
||||
}
|
||||
self.assert.CurrentView().SelectedLine(matcher)
|
||||
self.assert.Views().Current().SelectedLine(matcher)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ type MenuAsserter struct {
|
||||
}
|
||||
|
||||
func (self *MenuAsserter) getViewAsserter() *ViewAsserter {
|
||||
return self.assert.View("menu")
|
||||
return self.assert.Views().ByName("menu")
|
||||
}
|
||||
|
||||
// asserts that the popup has the expected title
|
||||
|
@ -7,7 +7,7 @@ type PromptAsserter struct {
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) getViewAsserter() *ViewAsserter {
|
||||
return self.assert.View("confirmation")
|
||||
return self.assert.Views().ByName("confirmation")
|
||||
}
|
||||
|
||||
// asserts that the popup has the expected title
|
||||
@ -55,27 +55,27 @@ func (self *PromptAsserter) checkNecessaryChecksCompleted() {
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SuggestionLines(matchers ...*matcher) *PromptAsserter {
|
||||
self.assert.View("suggestions").Lines(matchers...)
|
||||
self.assert.Views().ByName("suggestions").Lines(matchers...)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SuggestionTopLines(matchers ...*matcher) *PromptAsserter {
|
||||
self.assert.View("suggestions").TopLines(matchers...)
|
||||
self.assert.Views().ByName("suggestions").TopLines(matchers...)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SelectFirstSuggestion() *PromptAsserter {
|
||||
self.input.Press(self.input.keys.Universal.TogglePanel)
|
||||
self.assert.CurrentView().Name("suggestions")
|
||||
self.assert.Views().Current().Name("suggestions")
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SelectSuggestion(matcher *matcher) *PromptAsserter {
|
||||
self.input.Press(self.input.keys.Universal.TogglePanel)
|
||||
self.assert.CurrentView().Name("suggestions")
|
||||
self.assert.Views().Current().Name("suggestions")
|
||||
|
||||
self.input.NavigateToListItem(matcher)
|
||||
|
||||
|
Reference in New Issue
Block a user