1 defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
4 alias Pleroma.Web.MastodonAPI.{StatusView, AccountView}
6 alias Pleroma.Web.OStatus
7 alias Pleroma.Web.CommonAPI
10 test "a note activity" do
11 note = insert(:note_activity)
12 user = User.get_cached_by_ap_id(note.data["actor"])
14 status = StatusView.render("status.json", %{activity: note})
16 created_at = (note.data["object"]["published"] || "")
17 |> String.replace(~r/\.\d+Z/, ".000Z")
20 id: to_string(note.id),
21 uri: note.data["object"]["id"],
22 url: note.data["object"]["id"],
23 account: AccountView.render("account.json", %{user: user}),
25 in_reply_to_account_id: nil,
27 content: HtmlSanitizeEx.basic_html(note.data["object"]["content"]),
28 created_at: created_at,
35 spoiler_text: note.data["object"]["summary"],
37 media_attachments: [],
49 static_url: "corndog.png"
54 assert status == expected
57 test "contains mentions" do
58 incoming = File.read!("test/fixtures/incoming_reply_mastodon.xml")
59 user = insert(:user, %{ap_id: "https://pleroma.soykaf.com/users/lain"})
61 {:ok, [activity]} = OStatus.handle_incoming(incoming)
63 status = StatusView.render("status.json", %{activity: activity})
65 assert status.mentions == [AccountView.render("mention.json", %{user: user})]
73 "mediaType" => "image/png",
84 remote_url: "someurl",
85 preview_url: "someurl",
89 assert expected == StatusView.render("attachment.json", %{attachment: object})
91 # If theres a "id", use that instead of the generated one
92 object = Map.put(object, "id", 2)
93 assert %{id: "2"} = StatusView.render("attachment.json", %{attachment: object})
98 activity = insert(:note_activity)
100 {:ok, reblog, _} = CommonAPI.repeat(activity.id, user)
102 represented = StatusView.render("status.json", %{for: user, activity: reblog})
104 assert represented[:id] == to_string(reblog.id)
105 assert represented[:reblog][:id] == to_string(activity.id)
106 assert represented[:emojis] == []