add favicon tests

This commit is contained in:
FloatingGhost 2022-11-04 05:09:49 +00:00
parent c7cdc00af8
commit 139dc54a95

View file

@ -112,7 +112,7 @@ test "Represent a user account" do
describe "favicon" do
setup do
[user: insert(:user)]
[user: insert(:user), instance: insert(:instance, %{host: "localhost", favicon: "https://example.com/favicon.ico"})]
end
test "is parsed when :instance_favicons is enabled", %{user: user} do
@ -121,12 +121,13 @@ test "is parsed when :instance_favicons is enabled", %{user: user} do
assert %{
pleroma: %{
favicon:
"https://shitposter.club/plugins/Qvitter/img/gnusocial-favicons/favicon-16x16.png"
"https://example.com/favicon.ico"
}
} = AccountView.render("show.json", %{user: user, skip_visibility_check: true})
end
test "is nil when :instances_favicons is disabled", %{user: user} do
test "is nil when we have no instance", %{user: user} do
user = %{user | ap_id: "https://wowee.example.com/users/2"}
assert %{pleroma: %{favicon: nil}} =
AccountView.render("show.json", %{user: user, skip_visibility_check: true})
end
@ -188,6 +189,7 @@ test "Represent a Service(bot) account" do
},
fqn: "shp@shitposter.club",
last_status_at: nil,
akkoma: %{instance: nil},
pleroma: %{
ap_id: user.ap_id,
also_known_as: [],
@ -590,6 +592,8 @@ test "uses mediaproxy urls when it's enabled (regardless of media preview proxy
emoji: %{"joker_smile" => "https://evil.website/society.png"}
)
insert(:instance, %{host: "localhost", favicon: "https://evil.website/favicon.png"})
with media_preview_enabled <- [false, true] do
clear_config([:media_preview_proxy, :enabled], media_preview_enabled)
@ -598,6 +602,9 @@ test "uses mediaproxy urls when it's enabled (regardless of media preview proxy
{key, url} when key in [:avatar, :avatar_static, :header, :header_static] ->
String.starts_with?(url, Pleroma.Web.Endpoint.url())
{:akkoma, %{instance: %{favicon: favicon_url}}} ->
String.starts_with?(favicon_url, Pleroma.Web.Endpoint.url())
{:emojis, emojis} ->
Enum.all?(emojis, fn %{url: url, static_url: static_url} ->
String.starts_with?(url, Pleroma.Web.Endpoint.url()) &&