Merge branch 'bugfix/1543-streaming-boosts' into 'develop'
[akkoma] / test / web / streamer / streamer_test.exs
index eb082b79f49943e44de47655e622ca52801b6e26..8b8d8af6c51521dac9046715814c22d24fcc6731 100644 (file)
@@ -28,6 +28,42 @@ defmodule Pleroma.Web.StreamerTest do
       {:ok, %{user: user, notify: notify}}
     end
 
+    test "it streams the user's post in the 'user' stream", %{user: user} do
+      task =
+        Task.async(fn ->
+          assert_receive {:text, _}, @streamer_timeout
+        end)
+
+      Streamer.add_socket(
+        "user",
+        %{transport_pid: task.pid, assigns: %{user: user}}
+      )
+
+      {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
+
+      Streamer.stream("user", activity)
+      Task.await(task)
+    end
+
+    test "it streams boosts of the user in the 'user' stream", %{user: user} do
+      task =
+        Task.async(fn ->
+          assert_receive {:text, _}, @streamer_timeout
+        end)
+
+      Streamer.add_socket(
+        "user",
+        %{transport_pid: task.pid, assigns: %{user: user}}
+      )
+
+      other_user = insert(:user)
+      {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hey"})
+      {:ok, announce, _} = CommonAPI.repeat(activity.id, user)
+
+      Streamer.stream("user", announce)
+      Task.await(task)
+    end
+
     test "it sends notify to in the 'user' stream", %{user: user, notify: notify} do
       task =
         Task.async(fn ->