From ea01e647df4466975b9382f123f0a2aa35ebfe76 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 7 May 2020 09:13:43 -0500 Subject: [PATCH] Test Direct, Public, and Favorite notifications with privacy option --- test/web/push/impl_test.exs | 60 +++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/test/web/push/impl_test.exs b/test/web/push/impl_test.exs index 3de911810..b855d72ba 100644 --- a/test/web/push/impl_test.exs +++ b/test/web/push/impl_test.exs @@ -193,7 +193,7 @@ test "renders title for create activity with direct visibility" 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}) @@ -211,9 +211,35 @@ test "returns info content for direct message with enabled privacy option" do assert Impl.build_content(notif, actor, object) == %{ body: "New Direct Message" } + + {:ok, activity} = + CommonAPI.post(user, %{ + "visibility" => "public", + "status" => " "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