1 defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
4 alias Pleroma.Web.MastodonAPI.{StatusView, AccountView}
6 alias Pleroma.Web.OStatus
9 test "a note activity" do
10 note = insert(:note_activity)
11 user = User.get_cached_by_ap_id(note.data["actor"])
13 status = StatusView.render("status.json", %{activity: note})
15 created_at = (note.data["object"]["published"] || "")
16 |> String.replace(~r/\.\d+Z/, ".000Z")
20 uri: note.data["object"]["id"],
21 url: note.data["object"]["external_id"],
22 account: AccountView.render("account.json", %{user: user}),
24 in_reply_to_account_id: nil,
26 content: HtmlSanitizeEx.basic_html(note.data["object"]["content"]),
27 created_at: created_at,
36 media_attachments: [],
46 assert status == expected
49 test "contains mentions" do
50 incoming = File.read!("test/fixtures/incoming_reply_mastodon.xml")
51 user = insert(:user, %{ap_id: "https://pleroma.soykaf.com/users/lain"})
53 {:ok, [activity]} = OStatus.handle_incoming(incoming)
55 status = StatusView.render("status.json", %{activity: activity})
57 assert status.mentions == [AccountView.render("mention.json", %{user: user})]
65 "mediaType" => "image/png",
76 remote_url: "someurl",
77 preview_url: "someurl",
81 assert expected == StatusView.render("attachment.json", %{attachment: object})
83 # If theres a "id", use that instead of the generated one
84 object = Map.put(object, "id", 2)
85 assert %{id: 2} = StatusView.render("attachment.json", %{attachment: object})