1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
9 alias Pleroma.Web.MastodonAPI.AccountView
11 test "Represent a user account" do
16 "icon" => %{"url" => "/file.png"},
17 "name" => ":karjalanpiirakka:"
24 info: %{note_count: 5, follower_count: 3, source_data: source_data},
25 nickname: "shp@shitposter.club",
26 name: ":karjalanpiirakka: shp",
27 bio: "<script src=\"invalid-html\"></script><span>valid html</span>",
28 inserted_at: ~N[2017-08-15 15:47:06.597036]
32 id: to_string(user.id),
35 display_name: user.name,
37 created_at: "2017-08-15T15:47:06.000Z",
41 note: "<span>valid html</span>",
43 avatar: "http://localhost:4001/images/avi.png",
44 avatar_static: "http://localhost:4001/images/avi.png",
45 header: "http://localhost:4001/images/banner.png",
46 header_static: "http://localhost:4001/images/banner.png",
49 "static_url" => "/file.png",
51 "shortcode" => "karjalanpiirakka",
52 "visible_in_picker" => false
63 confirmation_pending: false,
68 hide_followers: false,
74 assert expected == AccountView.render("account.json", %{user: user})
77 test "Represent the user account for the account owner" do
80 notification_settings = %{
87 privacy = user.info.default_scope
90 pleroma: %{notification_settings: ^notification_settings},
91 source: %{privacy: ^privacy}
92 } = AccountView.render("account.json", %{user: user, for: user})
95 test "Represent a Service(bot) account" do
98 info: %{note_count: 5, follower_count: 3, source_data: %{"type" => "Service"}},
99 nickname: "shp@shitposter.club",
100 inserted_at: ~N[2017-08-15 15:47:06.597036]
104 id: to_string(user.id),
107 display_name: user.name,
109 created_at: "2017-08-15T15:47:06.000Z",
115 avatar: "http://localhost:4001/images/avi.png",
116 avatar_static: "http://localhost:4001/images/avi.png",
117 header: "http://localhost:4001/images/banner.png",
118 header_static: "http://localhost:4001/images/banner.png",
128 confirmation_pending: false,
132 hide_favorites: true,
133 hide_followers: false,
139 assert expected == AccountView.render("account.json", %{user: user})
142 test "Represent a smaller mention" do
146 id: to_string(user.id),
148 username: user.nickname,
152 assert expected == AccountView.render("mention.json", %{user: user})
155 test "represent a relationship" do
157 other_user = insert(:user)
159 {:ok, user} = User.follow(user, other_user)
160 {:ok, user} = User.block(user, other_user)
163 id: to_string(other_user.id),
168 muting_notifications: false,
171 domain_blocking: false,
172 showing_reblogs: true,
176 assert expected == AccountView.render("relationship.json", %{user: user, target: other_user})
179 test "represent an embedded relationship" do
182 info: %{note_count: 5, follower_count: 0, source_data: %{"type" => "Service"}},
183 nickname: "shp@shitposter.club",
184 inserted_at: ~N[2017-08-15 15:47:06.597036]
187 other_user = insert(:user)
188 {:ok, other_user} = User.follow(other_user, user)
189 {:ok, other_user} = User.block(other_user, user)
190 {:ok, _} = User.follow(insert(:user), user)
193 id: to_string(user.id),
196 display_name: user.name,
198 created_at: "2017-08-15T15:47:06.000Z",
204 avatar: "http://localhost:4001/images/avi.png",
205 avatar_static: "http://localhost:4001/images/avi.png",
206 header: "http://localhost:4001/images/banner.png",
207 header_static: "http://localhost:4001/images/banner.png",
217 confirmation_pending: false,
221 hide_favorites: true,
222 hide_followers: false,
225 id: to_string(user.id),
231 muting_notifications: false,
233 domain_blocking: false,
234 showing_reblogs: true,
240 assert expected == AccountView.render("account.json", %{user: user, for: other_user})