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,
71 assert expected == AccountView.render("account.json", %{user: user})
74 test "Represent the user account for the account owner" do
77 notification_settings = %{
84 assert %{pleroma: %{notification_settings: ^notification_settings}} =
85 AccountView.render("account.json", %{user: user, for: user})
88 test "Represent a Service(bot) account" do
91 info: %{note_count: 5, follower_count: 3, source_data: %{"type" => "Service"}},
92 nickname: "shp@shitposter.club",
93 inserted_at: ~N[2017-08-15 15:47:06.597036]
97 id: to_string(user.id),
100 display_name: user.name,
102 created_at: "2017-08-15T15:47:06.000Z",
108 avatar: "http://localhost:4001/images/avi.png",
109 avatar_static: "http://localhost:4001/images/avi.png",
110 header: "http://localhost:4001/images/banner.png",
111 header_static: "http://localhost:4001/images/banner.png",
121 confirmation_pending: false,
129 assert expected == AccountView.render("account.json", %{user: user})
132 test "Represent a smaller mention" do
136 id: to_string(user.id),
138 username: user.nickname,
142 assert expected == AccountView.render("mention.json", %{user: user})
145 test "represent a relationship" do
147 other_user = insert(:user)
149 {:ok, user} = User.follow(user, other_user)
150 {:ok, user} = User.block(user, other_user)
153 id: to_string(other_user.id),
158 muting_notifications: false,
161 domain_blocking: false,
162 showing_reblogs: true,
166 assert expected == AccountView.render("relationship.json", %{user: user, target: other_user})
169 test "represent an embedded relationship" do
172 info: %{note_count: 5, follower_count: 3, source_data: %{"type" => "Service"}},
173 nickname: "shp@shitposter.club",
174 inserted_at: ~N[2017-08-15 15:47:06.597036]
177 other_user = insert(:user)
179 {:ok, other_user} = User.follow(other_user, user)
180 {:ok, other_user} = User.block(other_user, user)
183 id: to_string(user.id),
186 display_name: user.name,
188 created_at: "2017-08-15T15:47:06.000Z",
194 avatar: "http://localhost:4001/images/avi.png",
195 avatar_static: "http://localhost:4001/images/avi.png",
196 header: "http://localhost:4001/images/banner.png",
197 header_static: "http://localhost:4001/images/banner.png",
207 confirmation_pending: false,
212 id: to_string(user.id),
218 muting_notifications: false,
220 domain_blocking: false,
221 showing_reblogs: true,
227 assert expected == AccountView.render("account.json", %{user: user, for: other_user})