diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-01-26 13:25:56 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-01-26 13:25:56 +1100 |
commit | f7f24dbfc198679dbcd2781db644354bf5b40856 (patch) | |
tree | 21aaeb6e06ea7e9f9d2d9d20b97b37fca9dffbca /pkg/integration/components | |
parent | c6929c36aeb17c54ffc54e38b80e9f1b27cef309 (diff) |
better test
Diffstat (limited to 'pkg/integration/components')
-rw-r--r-- | pkg/integration/components/test_driver.go | 16 | ||||
-rw-r--r-- | pkg/integration/components/views.go | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/pkg/integration/components/test_driver.go b/pkg/integration/components/test_driver.go index 5f2e15435..1128de3f5 100644 --- a/pkg/integration/components/test_driver.go +++ b/pkg/integration/components/test_driver.go @@ -5,6 +5,7 @@ import ( "strings" "time" + "github.com/atotto/clipboard" "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/gui/types" integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" @@ -143,6 +144,21 @@ func (self *TestDriver) ExpectPopup() *Popup { return &Popup{t: self} } +func (self *TestDriver) ExpectToast(matcher *matcher) { + self.Views().AppStatus().Content(matcher) +} + +func (self *TestDriver) ExpectClipboard(matcher *matcher) { + self.assertWithRetries(func() (bool, string) { + text, err := clipboard.ReadAll() + if err != nil { + return false, "Error occured when reading from clipboard: " + err.Error() + } + ok, _ := matcher.test(text) + return ok, fmt.Sprintf("Expected clipboard to match %s, but got %s", matcher.name(), text) + }) +} + // for making assertions through git itself func (self *TestDriver) Git() *Git { return &Git{assertionHelper: self.assertionHelper, shell: self.shell} diff --git a/pkg/integration/components/views.go b/pkg/integration/components/views.go index 906c17f4f..5641f1cd4 100644 --- a/pkg/integration/components/views.go +++ b/pkg/integration/components/views.go @@ -64,6 +64,10 @@ func (self *Views) Information() *ViewDriver { return self.byName("information") } +func (self *Views) AppStatus() *ViewDriver { + return self.byName("appStatus") +} + func (self *Views) Branches() *ViewDriver { return self.byName("localBranches") } |