From 139dc54a95d62e6a3ddccac5e715ae93a3f30925 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Fri, 4 Nov 2022 05:09:49 +0000 Subject: [PATCH] add favicon tests --- .../web/mastodon_api/views/account_view_test.exs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/pleroma/web/mastodon_api/views/account_view_test.exs b/test/pleroma/web/mastodon_api/views/account_view_test.exs index 19224f126..541525520 100644 --- a/test/pleroma/web/mastodon_api/views/account_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs @@ -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()) &&