X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fpush%2Fimpl_test.exs;h=2acd0939fa71c3c4951cf871ed6b287f1cfda088;hb=da550be066a15108ceef7874c3b2549c049a7f88;hp=737976f1f635679655525a04eb5d71ff677c5245;hpb=514c899275a32e6ef63305f9424c50344d41b12e;p=akkoma
diff --git a/test/web/push/impl_test.exs b/test/web/push/impl_test.exs
index 737976f1f..2acd0939f 100644
--- a/test/web/push/impl_test.exs
+++ b/test/web/push/impl_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Push.ImplTest do
@@ -13,8 +13,8 @@ defmodule Pleroma.Web.Push.ImplTest do
import Pleroma.Factory
- setup_all do
- Tesla.Mock.mock_global(fn
+ setup do
+ Tesla.Mock.mock(fn
%{method: :post, url: "https://example.com/example/1234"} ->
%Tesla.Env{status: 200}
@@ -55,7 +55,7 @@ defmodule Pleroma.Web.Push.ImplTest do
data: %{alerts: %{"follow" => true, "mention" => false}}
)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "
+ status:
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
@@ -139,7 +147,7 @@ defmodule Pleroma.Web.Push.ImplTest do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
+ status:
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
@@ -158,11 +166,11 @@ defmodule Pleroma.Web.Push.ImplTest do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
+ status:
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
- {:ok, activity, _} = CommonAPI.favorite(activity.id, user)
+ {:ok, activity} = CommonAPI.favorite(user, activity.id)
object = Object.normalize(activity)
assert Impl.format_body(%{activity: activity}, user, object) == "@Bob has favorited your post"
@@ -176,8 +184,8 @@ defmodule Pleroma.Web.Push.ImplTest do
{:ok, activity} =
CommonAPI.post(user, %{
- "visibility" => "direct",
- "status" => "This is just between you and me, pal"
+ visibility: "direct",
+ status: "This is just between you and me, pal"
})
assert Impl.format_title(%{activity: activity}) ==
@@ -185,14 +193,14 @@ defmodule Pleroma.Web.Push.ImplTest do
end
describe "build_content/3" do
- test "returns info content for direct message with enabled privacy option" do
+ test "hides details for notifications when privacy option enabled" do
user = insert(:user, nickname: "Bob")
user2 = insert(:user, nickname: "Rob", notification_settings: %{privacy_option: true})
{:ok, activity} =
CommonAPI.post(user, %{
- "visibility" => "direct",
- "status" => " "direct",
- "status" =>
+ visibility: "direct",
+ status:
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
@@ -227,6 +260,36 @@ defmodule Pleroma.Web.Push.ImplTest do
"@Bob: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini...",
title: "New Direct Message"
}
+
+ {:ok, activity} =
+ CommonAPI.post(user, %{
+ visibility: "public",
+ status:
+ "Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
+ })
+
+ notif = insert(:notification, user: user2, activity: activity)
+
+ actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
+ object = Object.normalize(activity)
+
+ assert Impl.build_content(notif, actor, object) == %{
+ body:
+ "@Bob: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini...",
+ title: "New Mention"
+ }
+
+ {:ok, activity} = CommonAPI.favorite(user, activity.id)
+
+ notif = insert(:notification, user: user2, activity: activity)
+
+ actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
+ object = Object.normalize(activity)
+
+ assert Impl.build_content(notif, actor, object) == %{
+ body: "@Bob has favorited your post",
+ title: "New Favorite"
+ }
end
end
end