diff options
Diffstat (limited to 'pkg/integration/components/view_driver.go')
-rw-r--r-- | pkg/integration/components/view_driver.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/integration/components/view_driver.go b/pkg/integration/components/view_driver.go index 2c4a23572..d1d1571c7 100644 --- a/pkg/integration/components/view_driver.go +++ b/pkg/integration/components/view_driver.go @@ -82,6 +82,20 @@ func (self *ViewDriver) TopLines(matchers ...*TextMatcher) *ViewDriver { return self.assertLines(0, matchers...) } +// Asserts on the visible lines of the view. +// Note, this assumes that the view's viewport is filled with lines +func (self *ViewDriver) VisibleLines(matchers ...*TextMatcher) *ViewDriver { + self.validateMatchersPassed(matchers) + self.validateVisibleLineCount(matchers) + + // Get the origin of the view and offset that. + // Note that we don't do any retrying here so if we want to bring back retry logic + // we'll need to update this. + originY := self.getView().OriginY() + + return self.assertLines(originY, matchers...) +} + // asserts that somewhere in the view there are consequetive lines matching the given matchers. func (self *ViewDriver) ContainsLines(matchers ...*TextMatcher) *ViewDriver { self.validateMatchersPassed(matchers) @@ -212,6 +226,16 @@ func (self *ViewDriver) validateEnoughLines(matchers []*TextMatcher) { }) } +// assumes the view's viewport is filled with lines +func (self *ViewDriver) validateVisibleLineCount(matchers []*TextMatcher) { + view := self.getView() + + self.t.assertWithRetries(func() (bool, string) { + count := view.InnerHeight() + 1 + return count == len(matchers), fmt.Sprintf("unexpected number of visible lines in view '%s'. Expected exactly %d, got %d", view.Name(), len(matchers), count) + }) +} + func (self *ViewDriver) assertLines(offset int, matchers ...*TextMatcher) *ViewDriver { view := self.getView() |