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.ActivityPub.MRF.NoPlaceholderTextPolicyTest do
6 use Pleroma.DataCase, async: true
7 alias Pleroma.Web.ActivityPub.MRF
8 alias Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicy
10 test "it clears content object" do
13 "object" => %{"content" => ".", "attachment" => "image"}
16 assert {:ok, res} = NoPlaceholderTextPolicy.filter(message)
17 assert res["object"]["content"] == ""
19 message = put_in(message, ["object", "content"], "<p>.</p>")
20 assert {:ok, res} = NoPlaceholderTextPolicy.filter(message)
21 assert res["object"]["content"] == ""
24 test "history-aware" do
29 "attachment" => "image",
30 "formerRepresentations" => %{
31 "orderedItems" => [%{"content" => ".", "attachment" => "image"}]
36 assert {:ok, res} = MRF.filter_one(NoPlaceholderTextPolicy, message)
40 "formerRepresentations" => %{"orderedItems" => [%{"content" => ""}]}
44 test "works with Updates" do
49 "attachment" => "image",
50 "formerRepresentations" => %{
51 "orderedItems" => [%{"content" => ".", "attachment" => "image"}]
56 assert {:ok, res} = MRF.filter_one(NoPlaceholderTextPolicy, message)
60 "formerRepresentations" => %{"orderedItems" => [%{"content" => ""}]}
67 "object" => %{"content" => "test", "attachment" => "image"}
69 %{"type" => "Create", "object" => %{"content" => "."}},
70 %{"type" => "Create", "object" => %{"content" => "<p>.</p>"}}
72 test "it skips filter" do
73 Enum.each(@messages, fn message ->
74 assert {:ok, res} = NoPlaceholderTextPolicy.filter(message)