alias Pleroma.Web.Streamer.Worker
@moduletag needs_streamer: true, capture_log: true
+
+ @streamer_timeout 150
+ @streamer_start_wait 10
+
clear_config_all([:instance, :skip_thread_containment])
describe "user streams" do
test "it sends notify to in the 'user' stream", %{user: user, notify: notify} do
task =
Task.async(fn ->
- assert_receive {:text, _}, 4_000
+ assert_receive {:text, _}, @streamer_timeout
end)
Streamer.add_socket(
test "it sends notify to in the 'user:notification' stream", %{user: user, notify: notify} do
task =
Task.async(fn ->
- assert_receive {:text, _}, 4_000
+ assert_receive {:text, _}, @streamer_timeout
end)
Streamer.add_socket(
blocked = insert(:user)
{:ok, _user_relationship} = User.block(user, blocked)
- task = Task.async(fn -> refute_receive {:text, _}, 4_000 end)
+ task = Task.async(fn -> refute_receive {:text, _}, @streamer_timeout end)
Streamer.add_socket(
"user:notification",
user: user
} do
user2 = insert(:user)
- task = Task.async(fn -> refute_receive {:text, _}, 4_000 end)
+ task = Task.async(fn -> refute_receive {:text, _}, @streamer_timeout end)
Streamer.add_socket(
"user:notification",
user: user
} do
user2 = insert(:user, %{ap_id: "https://hecking-lewd-place.com/user/meanie"})
- task = Task.async(fn -> refute_receive {:text, _}, 4_000 end)
+ task = Task.async(fn -> refute_receive {:text, _}, @streamer_timeout end)
Streamer.add_socket(
"user:notification",
user: user
} do
user2 = insert(:user)
- task = Task.async(fn -> assert_receive {:text, _}, 4_000 end)
+ task = Task.async(fn -> assert_receive {:text, _}, @streamer_timeout end)
+
+ Process.sleep(@streamer_start_wait)
Streamer.add_socket(
"user:notification",
task =
Task.async(fn ->
- assert_receive {:text, _}, 4_000
+ assert_receive {:text, _}, @streamer_timeout
end)
fake_socket = %StreamerSocket{
}
|> Jason.encode!()
- assert_receive {:text, received_event}, 4_000
+ assert_receive {:text, received_event}, @streamer_timeout
assert received_event == expected_event
end)
{:ok, activity} = CommonAPI.add_mute(user2, activity)
- task = Task.async(fn -> refute_receive {:text, _}, 4_000 end)
-
- Process.sleep(4000)
+ task = Task.async(fn -> refute_receive {:text, _}, @streamer_timeout end)
Streamer.add_socket(
"user",
task =
Task.async(fn ->
- assert_receive {:text, received_event}, 4_000
+ assert_receive {:text, received_event}, @streamer_timeout
assert %{"event" => "conversation", "payload" => received_payload} =
Jason.decode!(received_event)
task =
Task.async(fn ->
- assert_receive {:text, received_event}, 4_000
+ assert_receive {:text, received_event}, @streamer_timeout
assert %{"event" => "delete", "payload" => _} = Jason.decode!(received_event)
- refute_receive {:text, _}, 4_000
+ refute_receive {:text, _}, @streamer_timeout
end)
- Process.sleep(1000)
+ Process.sleep(@streamer_start_wait)
Streamer.add_socket(
"direct",
task =
Task.async(fn ->
- assert_receive {:text, received_event}, 4_000
- assert %{"event" => "delete", "payload" => _} = Jason.decode!(received_event)
- assert_receive {:text, received_event}, 4_000
+ assert_receive {:text, received_event}, @streamer_timeout
+ assert %{"event" => "delete", "payload" => _} = Jason.decode!(received_event)
+ assert_receive {:text, received_event}, @streamer_timeout
assert %{"event" => "conversation", "payload" => received_payload} =
Jason.decode!(received_event)
assert last_status["id"] == to_string(create_activity.id)
end)
- Process.sleep(1000)
+ Process.sleep(@streamer_start_wait)
Streamer.add_socket(
"direct",