Make it possible to handle toasts in integration tests
Use it in two selected tests to demonstrate what it looks like.
This commit is contained in:
@@ -102,8 +102,19 @@ func (self *TestDriver) ExpectPopup() *Popup {
|
||||
return &Popup{t: self}
|
||||
}
|
||||
|
||||
func (self *TestDriver) ExpectToast(matcher *TextMatcher) {
|
||||
self.Views().AppStatus().Content(matcher)
|
||||
func (self *TestDriver) ExpectToast(matcher *TextMatcher) *TestDriver {
|
||||
t := self.gui.NextToast()
|
||||
if t == nil {
|
||||
self.gui.Fail("Expected toast, but didn't get one")
|
||||
} else {
|
||||
self.matchString(matcher, "Unexpected toast message",
|
||||
func() string {
|
||||
return *t
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *TestDriver) ExpectClipboard(matcher *TextMatcher) {
|
||||
|
||||
@@ -78,6 +78,10 @@ func (self *fakeGuiDriver) SetCaption(string) {
|
||||
func (self *fakeGuiDriver) SetCaptionPrefix(string) {
|
||||
}
|
||||
|
||||
func (self *fakeGuiDriver) NextToast() *string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestManualFailure(t *testing.T) {
|
||||
test := NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: unitTestDescription,
|
||||
|
||||
@@ -65,6 +65,7 @@ var CrudAnnotated = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Title(Equals("Delete tag 'new-tag'?")).
|
||||
Content(Equals("Are you sure you want to delete the remote tag 'new-tag' from 'origin'?")).
|
||||
Confirm()
|
||||
t.ExpectToast(Equals("Remote tag deleted"))
|
||||
}).
|
||||
Lines(
|
||||
MatchesRegexp(`new-tag.*message`).IsSelected(),
|
||||
|
||||
@@ -70,6 +70,7 @@ var CrudLightweight = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Title(Equals("Delete tag 'new-tag'?")).
|
||||
Content(Equals("Are you sure you want to delete the remote tag 'new-tag' from 'origin'?")).
|
||||
Confirm()
|
||||
t.ExpectToast(Equals("Remote tag deleted"))
|
||||
}).
|
||||
Lines(
|
||||
MatchesRegexp(`new-tag.*initial commit`).IsSelected(),
|
||||
|
||||
@@ -43,4 +43,6 @@ type GuiDriver interface {
|
||||
View(viewName string) *gocui.View
|
||||
SetCaption(caption string)
|
||||
SetCaptionPrefix(prefix string)
|
||||
// Pop the next toast that was displayed; returns nil if there was none
|
||||
NextToast() *string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user