From 47f84b6aea493d3dcfe4f72b9c584b8225171f5c Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 22 Aug 2022 18:51:24 +1000 Subject: [PATCH] better assertions --- pkg/integration/components/assert.go | 8 ++++++++ pkg/integration/components/input.go | 3 +++ 2 files changed, 11 insertions(+) diff --git a/pkg/integration/components/assert.go b/pkg/integration/components/assert.go index ae363eb8d..7316eafe4 100644 --- a/pkg/integration/components/assert.go +++ b/pkg/integration/components/assert.go @@ -78,6 +78,14 @@ func (self *Assert) CommitCount(expectedCount int) { }) } +func (self *Assert) AtLeastOneCommit() { + self.assertWithRetries(func() (bool, string) { + actualCount := len(self.gui.Model().Commits) + + return actualCount > 0, "Expected at least one commit present" + }) +} + func (self *Assert) MatchHeadCommitMessage(matcher *matcher) { self.assertWithRetries(func() (bool, string) { return len(self.gui.Model().Commits) > 0, "Expected at least one commit to be present" diff --git a/pkg/integration/components/input.go b/pkg/integration/components/input.go index 63e902613..2f0666ebc 100644 --- a/pkg/integration/components/input.go +++ b/pkg/integration/components/input.go @@ -147,17 +147,20 @@ func (self *Input) NavigateToListItemContainingText(text string) { if matchCount == 1 { selectedLineIdx := view.SelectedLineIdx() if selectedLineIdx == matchIndex { + self.assert.MatchSelectedLine(Contains(text)) return } if selectedLineIdx < matchIndex { for i := selectedLineIdx; i < matchIndex; i++ { self.NextItem() } + self.assert.MatchSelectedLine(Contains(text)) return } else { for i := selectedLineIdx; i > matchIndex; i-- { self.PreviousItem() } + self.assert.MatchSelectedLine(Contains(text)) return } }