Merge branch 'transmogrifier-test-errors' into 'develop'
[akkoma] / test / web / streamer / streamer_test.exs
index d33eb1e4228e1a3a911b49e604626b745b77d170..d6968f4d049f975d5cc9ff195b46026aa43641d1 100644 (file)
@@ -110,6 +110,24 @@ defmodule Pleroma.Web.StreamerTest do
       Streamer.stream("user:notification", notif)
       Task.await(task)
     end
+
+    test "it sends follow activities to the 'user:notification' stream", %{
+      user: user
+    } do
+      user2 = insert(:user)
+      task = Task.async(fn -> assert_receive {:text, _}, 4_000 end)
+
+      Streamer.add_socket(
+        "user:notification",
+        %{transport_pid: task.pid, assigns: %{user: user}}
+      )
+
+      {:ok, _follower, _followed, _activity} = CommonAPI.follow(user2, user)
+
+      # We don't directly pipe the notification to the streamer as it's already
+      # generated as a side effect of CommonAPI.follow().
+      Task.await(task)
+    end
   end
 
   test "it sends to public" do
@@ -169,7 +187,8 @@ defmodule Pleroma.Web.StreamerTest do
     test "it doesn't send to user if recipients invalid and thread containment is enabled" do
       Pleroma.Config.put([:instance, :skip_thread_containment], false)
       author = insert(:user)
-      user = insert(:user, following: [author.ap_id])
+      user = insert(:user)
+      User.follow(user, author, "accept")
 
       activity =
         insert(:note_activity,
@@ -191,7 +210,8 @@ defmodule Pleroma.Web.StreamerTest do
     test "it sends message if recipients invalid and thread containment is disabled" do
       Pleroma.Config.put([:instance, :skip_thread_containment], true)
       author = insert(:user)
-      user = insert(:user, following: [author.ap_id])
+      user = insert(:user)
+      User.follow(user, author, "accept")
 
       activity =
         insert(:note_activity,
@@ -213,7 +233,8 @@ defmodule Pleroma.Web.StreamerTest do
     test "it sends message if recipients invalid and thread containment is enabled but user's thread containment is disabled" do
       Pleroma.Config.put([:instance, :skip_thread_containment], false)
       author = insert(:user)
-      user = insert(:user, following: [author.ap_id], info: %{skip_thread_containment: true})
+      user = insert(:user, skip_thread_containment: true)
+      User.follow(user, author, "accept")
 
       activity =
         insert(:note_activity,