b8a96f71a7ed87218291db58ac65a822546042ca
[akkoma] / test / web / mastodon_api / status_view_test.exs
1 defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
2 use Pleroma.DataCase
3
4 alias Pleroma.Web.MastodonAPI.{StatusView, AccountView}
5 alias Pleroma.User
6 alias Pleroma.Web.OStatus
7 import Pleroma.Factory
8
9 test "a note activity" do
10 note = insert(:note_activity)
11 user = User.get_cached_by_ap_id(note.data["actor"])
12
13 status = StatusView.render("status.json", %{activity: note})
14
15 expected = %{
16 id: note.id,
17 uri: note.data["object"]["id"],
18 url: note.data["object"]["external_id"],
19 account: AccountView.render("account.json", %{user: user}),
20 in_reply_to_id: nil,
21 in_reply_to_account_id: nil,
22 reblog: nil,
23 content: HtmlSanitizeEx.basic_html(note.data["object"]["content"]),
24 created_at: note.data["object"]["published"],
25 reblogs_count: 0,
26 favourites_count: 0,
27 reblogged: false,
28 favourited: false,
29 muted: false,
30 sensitive: false,
31 spoiler_text: "",
32 visibility: "public",
33 media_attachments: [],
34 mentions: [],
35 tags: [],
36 application: nil,
37 language: nil
38 }
39
40 assert status == expected
41 end
42
43 test "contains mentions" do
44 incoming = File.read!("test/fixtures/incoming_reply_mastodon.xml")
45 user = insert(:user, %{ap_id: "https://pleroma.soykaf.com/users/lain"})
46
47 {:ok, [activity]} = OStatus.handle_incoming(incoming)
48
49 status = StatusView.render("status.json", %{activity: activity})
50
51 assert status.mentions == [AccountView.render("mention.json", %{user: user})]
52 end
53 end