Merge branch 'develop' into feature/compat/push-subscriptions
[akkoma] / test / web / mastodon_api / mastodon_socket_test.exs
1 defmodule Pleroma.Web.MastodonApi.MastodonSocketTest do
2 use Pleroma.DataCase
3
4 alias Pleroma.Web.MastodonApi.MastodonSocket
5 alias Pleroma.Web.{Streamer, CommonAPI}
6 alias Pleroma.User
7
8 import Pleroma.Factory
9
10 test "public is working when non-authenticated" do
11 user = insert(:user)
12
13 task =
14 Task.async(fn ->
15 assert_receive {:text, _}, 4_000
16 end)
17
18 fake_socket = %{
19 transport_pid: task.pid,
20 assigns: %{}
21 }
22
23 topics = %{
24 "public" => [fake_socket]
25 }
26
27 {:ok, activity} = CommonAPI.post(user, %{"status" => "Test"})
28
29 Streamer.push_to_socket(topics, "public", activity)
30
31 Task.await(task)
32 end
33 end