From b8e44cb2310899880189df3d0ec9395c80491757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 21 Aug 2022 23:23:19 +0200 Subject: [PATCH] Notification test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- test/pleroma/notification_test.exs | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/pleroma/notification_test.exs b/test/pleroma/notification_test.exs index 3169d06c1a..0d475bec0d 100644 --- a/test/pleroma/notification_test.exs +++ b/test/pleroma/notification_test.exs @@ -128,6 +128,47 @@ test "does not create a notification for subscribed users if status is a reply" subscriber_notifications = Notification.for_user(subscriber) assert Enum.empty?(subscriber_notifications) end + + test "creates notification for event join request" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.event(user, %{name: "test event", status: "", join_mode: "restricted"}) + + CommonAPI.join(other_user, activity.id) + + user_notifications = Notification.for_user(user) + assert length(user_notifications) == 1 + end + + test "creates notification for event join approval" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.event(user, %{name: "test event", status: "", join_mode: "restricted"}) + + CommonAPI.join(other_user, activity.id) + + CommonAPI.accept_join_request(user, other_user, activity.data["object"]) + + user_notifications = Notification.for_user(other_user) + assert length(user_notifications) == 1 + end + + test "doesn't create notification for events without participation approval" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.event(user, %{name: "test event", status: "", join_mode: "free"}) + + CommonAPI.join(other_user, activity.id) + + user_notifications = Notification.for_user(user) + assert length(user_notifications) == 0 + + user_notifications = Notification.for_user(other_user) + assert length(user_notifications) == 0 + end end test "create_poll_notifications/1" do