1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ShoutChannelTest do
6 use Pleroma.Web.ChannelCase
7 alias Pleroma.Web.ShoutChannel
8 alias Pleroma.Web.UserSocket
10 import Pleroma.Factory
16 socket(UserSocket, "", %{user_name: user.nickname})
17 |> subscribe_and_join(ShoutChannel, "chat:public")
22 test "it broadcasts a message", %{socket: socket} do
23 push(socket, "new_msg", %{"text" => "why is tenshi eating a corndog so cute?"})
24 assert_broadcast("new_msg", %{text: "why is tenshi eating a corndog so cute?"})
27 describe "message lengths" do
28 setup do: clear_config([:shout, :limit])
30 test "it ignores messages of length zero", %{socket: socket} do
31 push(socket, "new_msg", %{"text" => ""})
32 refute_broadcast("new_msg", %{text: ""})
35 test "it ignores messages above a certain length", %{socket: socket} do
36 clear_config([:shout, :limit], 2)
37 push(socket, "new_msg", %{"text" => "123"})
38 refute_broadcast("new_msg", %{text: "123"})