Merge branch 'develop' into command-available-check
[akkoma] / test / user / welcome_chat_massage_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 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.Config
9 alias Pleroma.User.WelcomeChatMessage
10
11 import Pleroma.Factory
12
13 setup do: clear_config([:welcome])
14
15 describe "post_message/1" do
16 test "send a chat welcome message" do
17 welcome_user = insert(:user, name: "mewmew")
18 user = insert(:user)
19
20 Config.put([:welcome, :chat_message, :enabled], true)
21 Config.put([:welcome, :chat_message, :sender_nickname], welcome_user.nickname)
22
23 Config.put(
24 [:welcome, :chat_message, :message],
25 "Hello, welcome to Blob/Cat!"
26 )
27
28 {:ok, %Pleroma.Activity{} = activity} = WelcomeChatMessage.post_message(user)
29
30 assert user.ap_id in activity.recipients
31 assert Pleroma.Object.normalize(activity).data["type"] == "ChatMessage"
32 assert Pleroma.Object.normalize(activity).data["content"] == "Hello, welcome to Blob/Cat!"
33 end
34 end
35 end