summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2024-06-08 17:55:01 +0000
committerfeld <feld@feld.me>2024-06-08 17:55:01 +0000
commit9d67827619e7f770d7dd6cea98ad33f5cfa33991 (patch)
tree239c66ad5a60368bdc83727488d7f6081e2654e5 /test
parentc24e222887808ea7e2080ad54dea340212a5e9df (diff)
parent471412ad34e87106641101c9e9e44fb1df2ca905 (diff)
downloadpleroma-9d67827619e7f770d7dd6cea98ad33f5cfa33991.tar.gz
pleroma-9d67827619e7f770d7dd6cea98ad33f5cfa33991.zip
Merge branch 'stream-poll-end' into 'develop'
Stream end of poll notification over websockets and web push See merge request pleroma/pleroma!4137
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/notification_test.exs27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/pleroma/notification_test.exs b/test/pleroma/notification_test.exs
index 2c582c708..02ae06c63 100644
--- a/test/pleroma/notification_test.exs
+++ b/test/pleroma/notification_test.exs
@@ -5,6 +5,7 @@
defmodule Pleroma.NotificationTest do
use Pleroma.DataCase, async: false
+ import Mock
import Pleroma.Factory
alias Pleroma.FollowingRelationship
@@ -183,9 +184,31 @@ defmodule Pleroma.NotificationTest do
{:ok, _, _} = CommonAPI.vote(user2, question, [0])
{:ok, _, _} = CommonAPI.vote(user3, question, [1])
- {:ok, notifications} = Notification.create_poll_notifications(activity)
+ with_mocks([
+ {
+ Pleroma.Web.Streamer,
+ [],
+ [
+ stream: fn _, _ -> nil end
+ ]
+ },
+ {
+ Pleroma.Web.Push,
+ [],
+ [
+ send: fn _ -> nil end
+ ]
+ }
+ ]) do
+ {:ok, notifications} = Notification.create_poll_notifications(activity)
+
+ Enum.each(notifications, fn notification ->
+ assert called(Pleroma.Web.Streamer.stream(["user", "user:notification"], notification))
+ assert called(Pleroma.Web.Push.send(notification))
+ end)
- assert [user2.id, user3.id, user1.id] == Enum.map(notifications, & &1.user_id)
+ assert [user2.id, user3.id, user1.id] == Enum.map(notifications, & &1.user_id)
+ end
end
describe "create_notification" do