summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2024-05-21 05:01:45 +0000
committerlain <lain@soykaf.club>2024-05-21 05:01:45 +0000
commit7fca5982686e9da2ef449af65b6ec2602a3c9f69 (patch)
treea1f2c66df8dcb666d008a54e57b5b2cf7015c126 /test
parente8cd6662eb2a534e3be16b522bf81b25b194edab (diff)
parent36fa0debfe66d3b706eeaa09227edd8b82c70aba (diff)
downloadpleroma-7fca5982686e9da2ef449af65b6ec2602a3c9f69.tar.gz
pleroma-7fca5982686e9da2ef449af65b6ec2602a3c9f69.zip
Merge branch 'status-notification-type' into 'develop'
Add "status" notification type See merge request pleroma/pleroma!3659
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/notification_test.exs16
-rw-r--r--test/pleroma/web/mastodon_api/views/notification_view_test.exs27
2 files changed, 43 insertions, 0 deletions
diff --git a/test/pleroma/notification_test.exs b/test/pleroma/notification_test.exs
index 1dd0c26f7..ecdb32e32 100644
--- a/test/pleroma/notification_test.exs
+++ b/test/pleroma/notification_test.exs
@@ -112,6 +112,7 @@ defmodule Pleroma.NotificationTest do
{:ok, [notification]} = Notification.create_notifications(status)
assert notification.user_id == subscriber.id
+ assert notification.type == "status"
end
test "does not create a notification for subscribed users if status is a reply" do
@@ -136,6 +137,21 @@ defmodule Pleroma.NotificationTest do
assert Enum.empty?(subscriber_notifications)
end
+ test "does not create subscriber notification if mentioned" do
+ user = insert(:user)
+ subscriber = insert(:user)
+
+ User.subscribe(subscriber, user)
+
+ {:ok, status} = CommonAPI.post(user, %{status: "mentioning @#{subscriber.nickname}"})
+ {:ok, [notification] = notifications} = Notification.create_notifications(status)
+
+ assert length(notifications) == 1
+
+ assert notification.user_id == subscriber.id
+ assert notification.type == "mention"
+ end
+
test "it sends edited notifications to those who repeated a status" do
user = insert(:user)
repeated_user = insert(:user)
diff --git a/test/pleroma/web/mastodon_api/views/notification_view_test.exs b/test/pleroma/web/mastodon_api/views/notification_view_test.exs
index 47425d2a9..9896f81b6 100644
--- a/test/pleroma/web/mastodon_api/views/notification_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/notification_view_test.exs
@@ -331,4 +331,31 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
test_notifications_rendering([notification], user, [expected])
end
+
+ test "Subscribed status notification" do
+ user = insert(:user)
+ subscriber = insert(:user)
+
+ User.subscribe(subscriber, user)
+
+ {:ok, activity} = CommonAPI.post(user, %{status: "hi"})
+ {:ok, [notification]} = Notification.create_notifications(activity)
+
+ user = User.get_cached_by_id(user.id)
+
+ expected = %{
+ id: to_string(notification.id),
+ pleroma: %{is_seen: false, is_muted: false},
+ type: "status",
+ account:
+ AccountView.render("show.json", %{
+ user: user,
+ for: subscriber
+ }),
+ status: StatusView.render("show.json", %{activity: activity, for: subscriber}),
+ created_at: Utils.to_masto_date(notification.inserted_at)
+ }
+
+ test_notifications_rendering([notification], subscriber, [expected])
+ end
end