diff --git a/pkg/gui/gui_driver.go b/pkg/gui/gui_driver.go index ddeb3fab4..e7fa097d3 100644 --- a/pkg/gui/gui_driver.go +++ b/pkg/gui/gui_driver.go @@ -26,6 +26,8 @@ type GuiDriver struct { var _ integrationTypes.GuiDriver = &GuiDriver{} func (self *GuiDriver) PressKey(keyStr string) { + self.CheckAllToastsAcknowledged() + key := keybindings.GetKey(keyStr) var r rune @@ -47,6 +49,8 @@ func (self *GuiDriver) PressKey(keyStr string) { } func (self *GuiDriver) Click(x, y int) { + self.CheckAllToastsAcknowledged() + self.gui.g.ReplayedEvents.MouseEvents <- gocui.NewTcellMouseEventWrapper( tcell.NewEventMouse(x, y, tcell.ButtonPrimary, 0), 0, @@ -59,6 +63,12 @@ func (self *GuiDriver) waitTillIdle() { <-self.isIdleChan } +func (self *GuiDriver) CheckAllToastsAcknowledged() { + if t := self.NextToast(); t != nil { + self.Fail("Toast not acknowledged: " + *t) + } +} + func (self *GuiDriver) Keys() config.KeybindingConfig { return self.gui.Config.GetUserConfig().Keybinding } diff --git a/pkg/integration/components/test.go b/pkg/integration/components/test.go index c837d8be8..203436ae7 100644 --- a/pkg/integration/components/test.go +++ b/pkg/integration/components/test.go @@ -194,6 +194,8 @@ func (self *IntegrationTest) Run(gui integrationTypes.GuiDriver) { self.run(testDriver, keys) + gui.CheckAllToastsAcknowledged() + if InputDelay() > 0 { // Clear whatever caption there was so it doesn't linger testDriver.SetCaption("") diff --git a/pkg/integration/components/test_test.go b/pkg/integration/components/test_test.go index fa4401de5..047ee507c 100644 --- a/pkg/integration/components/test_test.go +++ b/pkg/integration/components/test_test.go @@ -82,6 +82,8 @@ func (self *fakeGuiDriver) NextToast() *string { return nil } +func (self *fakeGuiDriver) CheckAllToastsAcknowledged() {} + func TestManualFailure(t *testing.T) { test := NewIntegrationTest(NewIntegrationTestArgs{ Description: unitTestDescription, diff --git a/pkg/integration/tests/file/copy_menu.go b/pkg/integration/tests/file/copy_menu.go index f00425c96..5f7f00623 100644 --- a/pkg/integration/tests/file/copy_menu.go +++ b/pkg/integration/tests/file/copy_menu.go @@ -101,6 +101,8 @@ var CopyMenu = NewIntegrationTest(NewIntegrationTestArgs{ Select(Contains("File name")). Confirm() + t.ExpectToast(Equals("File name copied to clipboard")) + expectClipboard(t, Contains("unstaged_file")) }) @@ -113,6 +115,8 @@ var CopyMenu = NewIntegrationTest(NewIntegrationTestArgs{ Select(Contains("Path")). Confirm() + t.ExpectToast(Equals("File path copied to clipboard")) + expectClipboard(t, Contains("dir/1-unstaged_file")) }) @@ -126,6 +130,8 @@ var CopyMenu = NewIntegrationTest(NewIntegrationTestArgs{ Tooltip(Equals("If there are staged items, this command considers only them. Otherwise, it considers all the unstaged ones.")). Confirm() + t.ExpectToast(Equals("File diff copied to clipboard")) + expectClipboard(t, Contains("+unstaged content (new)")) }) @@ -145,6 +151,8 @@ var CopyMenu = NewIntegrationTest(NewIntegrationTestArgs{ Tooltip(Equals("If there are staged items, this command considers only them. Otherwise, it considers all the unstaged ones.")). Confirm() + t.ExpectToast(Equals("File diff copied to clipboard")) + expectClipboard(t, Contains("+staged content (new)")) }) @@ -158,6 +166,8 @@ var CopyMenu = NewIntegrationTest(NewIntegrationTestArgs{ Tooltip(Equals("If there are staged items, this command considers only them. Otherwise, it considers all the unstaged ones.")). Confirm() + t.ExpectToast(Equals("All files diff copied to clipboard")) + expectClipboard(t, Contains("+staged content (new)")) }) @@ -179,6 +189,8 @@ var CopyMenu = NewIntegrationTest(NewIntegrationTestArgs{ Tooltip(Equals("If there are staged items, this command considers only them. Otherwise, it considers all the unstaged ones.")). Confirm() + t.ExpectToast(Equals("All files diff copied to clipboard")) + expectClipboard(t, Contains("+staged content (new)").Contains("+unstaged content (new)")) }) }, diff --git a/pkg/integration/tests/misc/copy_to_clipboard.go b/pkg/integration/tests/misc/copy_to_clipboard.go index 48fae8136..6b1d5d1f6 100644 --- a/pkg/integration/tests/misc/copy_to_clipboard.go +++ b/pkg/integration/tests/misc/copy_to_clipboard.go @@ -27,6 +27,8 @@ var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{ ). Press(keys.Universal.CopyToClipboard) + t.ExpectToast(Equals("'branch-a' Copied to clipboard")) + t.Views().Files(). Focus() diff --git a/pkg/integration/tests/staging/diff_context_change.go b/pkg/integration/tests/staging/diff_context_change.go index ca0aa0780..141f8bcec 100644 --- a/pkg/integration/tests/staging/diff_context_change.go +++ b/pkg/integration/tests/staging/diff_context_change.go @@ -62,6 +62,9 @@ var DiffContextChange = NewIntegrationTest(NewIntegrationTestArgs{ Contains(` 6a`), ). Press(keys.Universal.IncreaseContextInDiffView). + Tap(func() { + t.ExpectToast(Equals("Changed diff context size to 4")) + }). SelectedLines( Contains(`@@ -1,7 +1,7 @@`), Contains(` 1a`), @@ -74,6 +77,9 @@ var DiffContextChange = NewIntegrationTest(NewIntegrationTestArgs{ Contains(` 7a`), ). Press(keys.Universal.DecreaseContextInDiffView). + Tap(func() { + t.ExpectToast(Equals("Changed diff context size to 3")) + }). SelectedLines( Contains(`@@ -1,6 +1,6 @@`), Contains(` 1a`), @@ -85,6 +91,9 @@ var DiffContextChange = NewIntegrationTest(NewIntegrationTestArgs{ Contains(` 6a`), ). Press(keys.Universal.DecreaseContextInDiffView). + Tap(func() { + t.ExpectToast(Equals("Changed diff context size to 2")) + }). SelectedLines( Contains(`@@ -1,5 +1,5 @@`), Contains(` 1a`), @@ -95,6 +104,9 @@ var DiffContextChange = NewIntegrationTest(NewIntegrationTestArgs{ Contains(` 5a`), ). Press(keys.Universal.DecreaseContextInDiffView). + Tap(func() { + t.ExpectToast(Equals("Changed diff context size to 1")) + }). SelectedLines( Contains(`@@ -2,3 +2,3 @@`), Contains(` 2a`), @@ -116,6 +128,9 @@ var DiffContextChange = NewIntegrationTest(NewIntegrationTestArgs{ Contains(` 4a`), ). Press(keys.Universal.IncreaseContextInDiffView). + Tap(func() { + t.ExpectToast(Equals("Changed diff context size to 2")) + }). SelectedLines( Contains(`@@ -1,5 +1,5 @@`), Contains(` 1a`), diff --git a/pkg/integration/types/types.go b/pkg/integration/types/types.go index b9b981d74..a30aeb055 100644 --- a/pkg/integration/types/types.go +++ b/pkg/integration/types/types.go @@ -45,4 +45,5 @@ type GuiDriver interface { SetCaptionPrefix(prefix string) // Pop the next toast that was displayed; returns nil if there was none NextToast() *string + CheckAllToastsAcknowledged() }