diff options
author | lain <lain@soykaf.club> | 2020-05-29 15:24:41 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-29 15:24:41 +0200 |
commit | c86a88edec75223f650faa2bb442c09aa95ad694 (patch) | |
tree | 23105518be633fc4c1e2d1ea3071da1f532e3111 /test | |
parent | af6d01ec93a07cd896bc4f0a2c2cf437c6fd51fc (diff) | |
download | pleroma-c86a88edec75223f650faa2bb442c09aa95ad694.tar.gz |
Streamer: Add a chat message stream.
Diffstat (limited to 'test')
-rw-r--r-- | test/web/streamer/streamer_test.exs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/web/streamer/streamer_test.exs b/test/web/streamer/streamer_test.exs index 115ba4703..ffbff35ca 100644 --- a/test/web/streamer/streamer_test.exs +++ b/test/web/streamer/streamer_test.exs @@ -9,9 +9,11 @@ defmodule Pleroma.Web.StreamerTest do alias Pleroma.Conversation.Participation alias Pleroma.List + alias Pleroma.Object alias Pleroma.User alias Pleroma.Web.CommonAPI alias Pleroma.Web.Streamer + alias Pleroma.Web.StreamerView @moduletag needs_streamer: true, capture_log: true @@ -126,6 +128,28 @@ defmodule Pleroma.Web.StreamerTest do refute Streamer.filtered_by_user?(user, notify) end + test "it sends chat messages to the 'user:pleroma_chat' stream", %{user: user} do + other_user = insert(:user) + + {:ok, create_activity} = CommonAPI.post_chat_message(other_user, user, "hey") + object = Object.normalize(create_activity, false) + Streamer.get_topic_and_add_socket("user:pleroma_chat", user) + Streamer.stream("user:pleroma_chat", object) + text = StreamerView.render("chat_update.json", object, user, [user.ap_id, other_user.ap_id]) + assert_receive {:text, ^text} + end + + test "it sends chat messages to the 'user' stream", %{user: user} do + other_user = insert(:user) + + {:ok, create_activity} = CommonAPI.post_chat_message(other_user, user, "hey") + object = Object.normalize(create_activity, false) + Streamer.get_topic_and_add_socket("user", user) + Streamer.stream("user", object) + text = StreamerView.render("chat_update.json", object, user, [user.ap_id, other_user.ap_id]) + assert_receive {:text, ^text} + end + test "it sends chat message notifications to the 'user:notification' stream", %{user: user} do other_user = insert(:user) |