diff options
author | Tusooa Zhu <tusooa@kazv.moe> | 2022-07-23 22:41:04 -0400 |
---|---|---|
committer | Tusooa Zhu <tusooa@kazv.moe> | 2022-07-23 22:41:04 -0400 |
commit | fc7ce5f93c4031863cbaf62b72dce55b5b6b0390 (patch) | |
tree | e044d0653d6517688a7cdee45f3b68b1940bb49a /test | |
parent | dce7e429286dfe8cb44a27c50713a03f0e696357 (diff) | |
download | pleroma-fc7ce5f93c4031863cbaf62b72dce55b5b6b0390.tar.gz |
Make NoPlaceholderTextPolicy history-aware
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/activity_pub/mrf/no_placeholder_text_policy_test.exs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/pleroma/web/activity_pub/mrf/no_placeholder_text_policy_test.exs b/test/pleroma/web/activity_pub/mrf/no_placeholder_text_policy_test.exs index acc7c3566..3533c2bc8 100644 --- a/test/pleroma/web/activity_pub/mrf/no_placeholder_text_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/no_placeholder_text_policy_test.exs @@ -4,6 +4,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicyTest do use Pleroma.DataCase, async: true + alias Pleroma.Web.ActivityPub.MRF alias Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicy test "it clears content object" do @@ -20,6 +21,46 @@ defmodule Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicyTest do assert res["object"]["content"] == "" end + test "history-aware" do + message = %{ + "type" => "Create", + "object" => %{ + "content" => ".", + "attachment" => "image", + "formerRepresentations" => %{ + "orderedItems" => [%{"content" => ".", "attachment" => "image"}] + } + } + } + + assert {:ok, res} = MRF.filter_one(NoPlaceholderTextPolicy, message) + + assert %{ + "content" => "", + "formerRepresentations" => %{"orderedItems" => [%{"content" => ""}]} + } = res["object"] + end + + test "works with Updates" do + message = %{ + "type" => "Update", + "object" => %{ + "content" => ".", + "attachment" => "image", + "formerRepresentations" => %{ + "orderedItems" => [%{"content" => ".", "attachment" => "image"}] + } + } + } + + assert {:ok, res} = MRF.filter_one(NoPlaceholderTextPolicy, message) + + assert %{ + "content" => "", + "formerRepresentations" => %{"orderedItems" => [%{"content" => ""}]} + } = res["object"] + end + @messages [ %{ "type" => "Create", |