summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2023-12-29 08:12:27 +0000
committerlain <lain@soykaf.club>2023-12-29 08:12:27 +0000
commita6fc97ffecc7c48d46354c28af2275bafe4b7301 (patch)
tree701df434abee9a50839f4deb3eb046daa7b505d1 /test
parent3954dfd4f1881845a60f117a86ef96f3997c6c3c (diff)
parent39dc6c65ef7a95412a985a3edce019914af12df8 (diff)
Merge branch 'bugfix/chat-attachment-empty-array' into 'develop'
ChatMessage: Tolerate attachment field set to an empty array Closes #3224 See merge request pleroma/pleroma!4020
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs
index 812944452..301fed60d 100644
--- a/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs
@@ -147,6 +147,21 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
assert object["attachment"]
end
+ test "validates for a basic object with content but attachment set to empty array", %{
+ user: user,
+ recipient: recipient
+ } do
+ {:ok, valid_chat_message, _} = Builder.chat_message(user, recipient.ap_id, "Hello!")
+
+ valid_chat_message =
+ valid_chat_message
+ |> Map.put("attachment", [])
+
+ assert {:ok, object, _meta} = ObjectValidator.validate(valid_chat_message, [])
+
+ assert object == Map.drop(valid_chat_message, ["attachment"])
+ end
+
test "does not validate if the message has no content", %{
valid_chat_message: valid_chat_message
} do