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.ObjectValidators.ArticleNotePageValidatorTest do
6 use Pleroma.DataCase, async: true
8 alias Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator
9 alias Pleroma.Web.ActivityPub.Utils
11 import Pleroma.Factory
18 "id" => Utils.generate_activity_id(),
20 "actor" => user.ap_id,
21 "to" => [user.follower_address],
23 "content" => "Hellow this is content.",
28 %{user: user, note: note}
31 test "a basic note validates", %{note: note} do
32 %{valid?: true} = ArticleNotePageValidator.cast_and_validate(note)
35 test "a note with a remote replies collection should validate", _ do
36 insert(:user, %{ap_id: "https://bookwyrm.com/user/TestUser"})
37 collection = File.read!("test/fixtures/bookwyrm-replies-collection.json")
41 url: "https://bookwyrm.com/user/TestUser/review/17/replies?page=1"
46 headers: HttpRequestMock.activitypub_object_headers()
50 note = Jason.decode!(File.read!("test/fixtures/bookwyrm-article.json"))
52 %{valid?: true, changes: %{replies: ["https://bookwyrm.com/user/TestUser/status/18"]}} =
53 ArticleNotePageValidator.cast_and_validate(note)
56 test "a note with an attachment should work", _ do
57 insert(:user, %{ap_id: "https://owncast.localhost.localdomain/federation/user/streamer"})
60 "test/fixtures/owncast-note-with-attachment.json"
64 %{valid?: true} = ArticleNotePageValidator.cast_and_validate(note)