First
[anni] / test / pleroma / web / activity_pub / transmogrifier / page_handling_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.Transmogrifier.PageHandlingTest do
6   use Oban.Testing, repo: Pleroma.Repo
7   use Pleroma.DataCase
8
9   alias Pleroma.Object.Fetcher
10
11   test "Lemmy Page" do
12     Tesla.Mock.mock(fn
13       %{url: "https://enterprise.lemmy.ml/post/3"} ->
14         %Tesla.Env{
15           status: 200,
16           headers: [{"content-type", "application/activity+json"}],
17           body: File.read!("test/fixtures/tesla_mock/lemmy-page.json")
18         }
19
20       %{url: "https://enterprise.lemmy.ml/u/nutomic"} ->
21         %Tesla.Env{
22           status: 200,
23           headers: [{"content-type", "application/activity+json"}],
24           body: File.read!("test/fixtures/tesla_mock/lemmy-user.json")
25         }
26     end)
27
28     {:ok, object} = Fetcher.fetch_object_from_id("https://enterprise.lemmy.ml/post/3")
29
30     assert object.data["summary"] == "Hello Federation!"
31     assert object.data["published"] == "2020-09-14T15:03:11.909105Z"
32
33     # WAT
34     assert object.data["url"] == "https://enterprise.lemmy.ml/pictrs/image/US52d9DPvf.jpg"
35   end
36 end