X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Factivity_pub%2Fobject_validators%2Farticle_note_page_validator_test.exs;h=62526d95203551b8644498c1047cce549921f712;hb=5ad256f170c29a864b0f720acc8302b347fd9b25;hp=2bd1e46c131376f719a5c3ede92940c4e99779cf;hpb=680c5d8d897edac726498efd14c510a2ed01e0ae;p=akkoma
diff --git a/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs b/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs
index 2bd1e46c1..62526d952 100644
--- a/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs
@@ -10,6 +10,12 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
import Pleroma.Factory
+ setup_all do
+ Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
+
+ :ok
+ end
+
describe "Notes" do
setup do
user = insert(:user)
@@ -52,5 +58,66 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
%{valid?: true, changes: %{replies: ["https://bookwyrm.com/user/TestUser/status/18"]}} =
ArticleNotePageValidator.cast_and_validate(note)
end
+
+ test "a note with an attachment should work", _ do
+ insert(:user, %{ap_id: "https://owncast.localhost.localdomain/federation/user/streamer"})
+
+ note =
+ "test/fixtures/owncast-note-with-attachment.json"
+ |> File.read!()
+ |> Jason.decode!()
+
+ %{valid?: true} = ArticleNotePageValidator.cast_and_validate(note)
+ end
+
+ test "a misskey MFM status with a content field should work and be linked", _ do
+ local_user = insert(:user, %{nickname: "akkoma_user"})
+
+ insert(:user, %{ap_id: "https://misskey.local.live/users/92hzkskwgy"})
+
+ note =
+ "test/fixtures/misskey/mfm_x_format.json"
+ |> File.read!()
+ |> Jason.decode!()
+
+ expected_content =
+ "@akkoma_user linkifylink #dancedance $[jelly mfm goes here]
## aaa"
+
+ %{
+ valid?: true,
+ changes: %{
+ content: ^expected_content,
+ source: %{
+ "content" => "@akkoma_user linkifylink #dancedance $[jelly mfm goes here] \n\n## aaa",
+ "mediaType" => "text/x.misskeymarkdown"
+ }
+ }
+ } = ArticleNotePageValidator.cast_and_validate(note)
+ end
+
+ test "a misskey MFM status with a _misskey_content field should work and be linked", _ do
+ local_user = insert(:user, %{nickname: "akkoma_user"})
+
+ insert(:user, %{ap_id: "https://misskey.local.live/users/92hzkskwgy"})
+
+ note =
+ "test/fixtures/misskey/mfm_underscore_format.json"
+ |> File.read!()
+ |> Jason.decode!()
+
+ expected_content =
+ "@akkoma_user linkifylink #dancedance $[jelly mfm goes here]
## aaa"
+
+ %{
+ valid?: true,
+ changes: %{
+ content: ^expected_content,
+ source: %{
+ "content" => "@akkoma_user linkifylink #dancedance $[jelly mfm goes here] \n\n## aaa",
+ "mediaType" => "text/x.misskeymarkdown"
+ }
+ }
+ } = ArticleNotePageValidator.cast_and_validate(note)
+ end
end
end