Don't show toasts when running integration tests (#2975)

This commit is contained in:
Stefan Haller 2023-08-30 11:21:52 +02:00 committed by GitHub
commit acfce07aa0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View file

@ -21,6 +21,13 @@ func NewAppStatusHelper(c *HelperCommon, statusMgr func() *status.StatusManager)
}
func (self *AppStatusHelper) Toast(message string) {
if self.c.RunningIntegrationTest() {
// Don't bother showing toasts in integration tests. You can't check for
// them anyway, and they would only slow down the test unnecessarily by
// two seconds.
return
}
self.statusMgr().AddToastStatus(message)
self.renderAppStatus()

View file

@ -182,6 +182,10 @@ func (self *guiCommon) AfterLayout(f func() error) {
}
}
func (self *guiCommon) RunningIntegrationTest() bool {
return self.gui.integrationTest != nil
}
func (self *guiCommon) InDemo() bool {
return self.gui.integrationTest != nil && self.gui.integrationTest.IsDemo()
}

View file

@ -107,6 +107,9 @@ type IGuiCommon interface {
// hopefully we can remove this once we've moved all our keybinding stuff out of the gui god struct.
GetInitialKeybindingsWithCustomCommands() ([]*Binding, []*gocui.ViewMouseBinding)
// Returns true if we're running an integration test
RunningIntegrationTest() bool
// Returns true if we're in a demo recording/playback
InDemo() bool
}