total rebase
[anni] / test / pleroma / user / welcome_chat_message_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.User.WelcomeChatMessageTest do
6   use Pleroma.DataCase
7
8   alias Pleroma.User.WelcomeChatMessage
9
10   import Pleroma.Factory
11
12   setup do: clear_config([:welcome])
13
14   describe "post_message/1" do
15     test "send a chat welcome message" do
16       welcome_user = insert(:user, name: "mewmew")
17       user = insert(:user)
18
19       clear_config([:welcome, :chat_message, :enabled], true)
20       clear_config([:welcome, :chat_message, :sender_nickname], welcome_user.nickname)
21
22       clear_config(
23         [:welcome, :chat_message, :message],
24         "Hello, welcome to Blob/Cat!"
25       )
26
27       {:ok, %Pleroma.Activity{} = activity} = WelcomeChatMessage.post_message(user)
28
29       assert user.ap_id in activity.recipients
30       assert Pleroma.Object.normalize(activity, fetch: false).data["type"] == "ChatMessage"
31
32       assert Pleroma.Object.normalize(activity, fetch: false).data["content"] ==
33                "Hello, welcome to Blob/Cat!"
34     end
35   end
36 end