Spin off imports into n oban jobs
[akkoma] / test / pleroma / user / welcome_message_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.User.WelcomeMessageTest do
6 use Pleroma.DataCase
7
8 alias Pleroma.User.WelcomeMessage
9
10 import Pleroma.Factory
11
12 setup do: clear_config([:welcome])
13
14 describe "post_message/1" do
15 test "send a direct welcome message" do
16 welcome_user = insert(:user)
17 user = insert(:user, name: "Jimm")
18
19 clear_config([:welcome, :direct_message, :enabled], true)
20 clear_config([:welcome, :direct_message, :sender_nickname], welcome_user.nickname)
21
22 clear_config(
23 [:welcome, :direct_message, :message],
24 "Hello. Welcome to Pleroma"
25 )
26
27 {:ok, %Pleroma.Activity{} = activity} = WelcomeMessage.post_message(user)
28 assert user.ap_id in activity.recipients
29 assert activity.data["directMessage"] == true
30
31 assert Pleroma.Object.normalize(activity, fetch: false).data["content"] =~
32 "Hello. Welcome to Pleroma"
33 end
34 end
35 end