X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fpleroma%2Fweb%2Fpush%2Fimpl_test.exs;h=326872ccd66cb13c5fca35489eee5ecfd648b894;hb=e49b583147748be73062acc92ea510f6f55a503a;hp=6cab46696dede96a40a9a4a618f0834ec3892968;hpb=b3d6cf90229ff3e9a5bd0028d4a6cbd3b68da9fe;p=akkoma
diff --git a/test/pleroma/web/push/impl_test.exs b/test/pleroma/web/push/impl_test.exs
index 6cab46696..326872ccd 100644
--- a/test/pleroma/web/push/impl_test.exs
+++ b/test/pleroma/web/push/impl_test.exs
@@ -1,16 +1,14 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Push.ImplTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
- alias Pleroma.Notification
alias Pleroma.Object
alias Pleroma.User
- alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.Push.Impl
alias Pleroma.Web.Push.Subscription
@@ -118,7 +116,7 @@ defmodule Pleroma.Web.Push.ImplTest do
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.format_body(
%{
@@ -137,7 +135,7 @@ defmodule Pleroma.Web.Push.ImplTest do
user = insert(:user, nickname: "Bob")
other_user = insert(:user)
{:ok, _, _, activity} = CommonAPI.follow(user, other_user)
- object = Object.normalize(activity, false)
+ object = Object.normalize(activity, fetch: false)
assert Impl.format_body(%{activity: activity, type: "follow"}, user, object) ==
"@Bob has followed you"
@@ -156,7 +154,7 @@ defmodule Pleroma.Web.Push.ImplTest do
})
{:ok, announce_activity} = CommonAPI.repeat(activity.id, user)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.format_body(%{activity: announce_activity}, user, object) ==
"@#{user.nickname} repeated: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
@@ -175,7 +173,7 @@ defmodule Pleroma.Web.Push.ImplTest do
})
{:ok, activity} = CommonAPI.favorite(user, activity.id)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.format_body(%{activity: activity, type: "favourite"}, user, object) ==
"@Bob has favorited your post"
@@ -184,60 +182,53 @@ defmodule Pleroma.Web.Push.ImplTest do
"New Favorite"
end
- test "renders title for create activity with direct visibility" do
+ test "renders title and body for pleroma:emoji_reaction activity" do
user = insert(:user, nickname: "Bob")
{:ok, activity} =
CommonAPI.post(user, %{
- visibility: "direct",
- status: "This is just between you and me, pal"
+ status: "This post is a really good post!"
})
- assert Impl.format_title(%{activity: activity}) ==
- "New Direct Message"
- end
+ {:ok, activity} = CommonAPI.react_with_emoji(activity.id, user, "ð")
+ object = Object.normalize(activity, fetch: false)
- describe "build_content/3" do
- test "builds content for chat messages" do
- user = insert(:user)
- recipient = insert(:user)
+ assert Impl.format_body(%{activity: activity, type: "pleroma:emoji_reaction"}, user, object) ==
+ "@Bob reacted with ð"
- {:ok, chat} = CommonAPI.post_chat_message(user, recipient, "hey")
- object = Object.normalize(chat, false)
- [notification] = Notification.for_user(recipient)
+ assert Impl.format_title(%{activity: activity, type: "pleroma:emoji_reaction"}) ==
+ "New Reaction"
+ end
- res = Impl.build_content(notification, user, object)
+ test "renders title and body for update activity" do
+ user = insert(:user)
- assert res == %{
- body: "@#{user.nickname}: hey",
- title: "New Chat Message"
- }
- end
+ {:ok, activity} = CommonAPI.post(user, %{status: "lorem ipsum"})
- test "builds content for chat messages with no content" do
- user = insert(:user)
- recipient = insert(:user)
+ {:ok, activity} = CommonAPI.update(user, activity, %{status: "edited status"})
+ object = Object.normalize(activity, fetch: false)
- file = %Plug.Upload{
- content_type: "image/jpg",
- path: Path.absname("test/fixtures/image.jpg"),
- filename: "an_image.jpg"
- }
+ assert Impl.format_body(%{activity: activity, type: "update"}, user, object) ==
+ "@#{user.nickname} edited a status"
- {:ok, upload} = ActivityPub.upload(file, actor: user.ap_id)
+ assert Impl.format_title(%{activity: activity, type: "update"}) ==
+ "New Update"
+ end
- {:ok, chat} = CommonAPI.post_chat_message(user, recipient, nil, media_id: upload.id)
- object = Object.normalize(chat, false)
- [notification] = Notification.for_user(recipient)
+ test "renders title for create activity with direct visibility" do
+ user = insert(:user, nickname: "Bob")
- res = Impl.build_content(notification, user, object)
+ {:ok, activity} =
+ CommonAPI.post(user, %{
+ visibility: "direct",
+ status: "This is just between you and me, pal"
+ })
- assert res == %{
- body: "@#{user.nickname}: (Attachment)",
- title: "New Chat Message"
- }
- end
+ assert Impl.format_title(%{activity: activity}) ==
+ "New Direct Message"
+ end
+ describe "build_content/3" do
test "hides contents of notifications when option enabled" do
user = insert(:user, nickname: "Bob")
@@ -253,7 +244,7 @@ defmodule Pleroma.Web.Push.ImplTest do
notif = insert(:notification, user: user2, activity: activity)
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body: "New Direct Message"
@@ -268,7 +259,7 @@ defmodule Pleroma.Web.Push.ImplTest do
notif = insert(:notification, user: user2, activity: activity, type: "mention")
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body: "New Mention"
@@ -279,7 +270,7 @@ defmodule Pleroma.Web.Push.ImplTest do
notif = insert(:notification, user: user2, activity: activity, type: "favourite")
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body: "New Favorite"
@@ -302,7 +293,7 @@ defmodule Pleroma.Web.Push.ImplTest do
notif = insert(:notification, user: user2, activity: activity)
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body:
@@ -320,7 +311,7 @@ defmodule Pleroma.Web.Push.ImplTest do
notif = insert(:notification, user: user2, activity: activity, type: "mention")
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body:
@@ -333,7 +324,7 @@ defmodule Pleroma.Web.Push.ImplTest do
notif = insert(:notification, user: user2, activity: activity, type: "favourite")
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body: "@Bob has favorited your post",