diff options
author | lain <lain@soykaf.club> | 2020-06-15 07:57:58 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-06-15 12:05:09 +0200 |
commit | 43eb4144d601442b0edb7f7e87c2f50d64276e1e (patch) | |
tree | 43c28b196fa5ba62bf303dcc512e8cd0128bc526 /test | |
parent | 271ea5068f4e3b901cb3f682e132378246daf452 (diff) | |
parent | b15cfc3d365dcfa5f99159fe06e29de6f8aceb4f (diff) | |
download | pleroma-namespace-move-notification.tar.gz |
Merge branch 'notifications-filtering' into 'develop'namespace-move-notification
Mastodon API return full result set in notifications
See merge request pleroma/pleroma!2552
Diffstat (limited to 'test')
-rw-r--r-- | test/notification_test.exs | 8 | ||||
-rw-r--r-- | test/web/mastodon_api/controllers/notification_controller_test.exs | 27 | ||||
-rw-r--r-- | test/web/mastodon_api/views/notification_view_test.exs | 6 |
3 files changed, 37 insertions, 4 deletions
diff --git a/test/notification_test.exs b/test/notification_test.exs index b9bbdceca..526f43fab 100644 --- a/test/notification_test.exs +++ b/test/notification_test.exs @@ -306,6 +306,14 @@ defmodule Pleroma.NotificationTest do assert {:ok, []} == Notification.create_notifications(status) end + + test "it disables notifications from people who are invisible" do + author = insert(:user, invisible: true) + user = insert(:user) + + {:ok, status} = CommonAPI.post(author, %{status: "hey @#{user.nickname}"}) + refute Notification.create_notification(status, user) + end end describe "follow / follow_request notifications" do diff --git a/test/web/mastodon_api/controllers/notification_controller_test.exs b/test/web/mastodon_api/controllers/notification_controller_test.exs index 698c99711..70ef0e8b5 100644 --- a/test/web/mastodon_api/controllers/notification_controller_test.exs +++ b/test/web/mastodon_api/controllers/notification_controller_test.exs @@ -313,6 +313,33 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do assert public_activity.id in activity_ids refute unlisted_activity.id in activity_ids end + + test "doesn't return less than the requested amount of records when the user's reply is liked" do + user = insert(:user) + %{user: other_user, conn: conn} = oauth_access(["read:notifications"]) + + {:ok, mention} = + CommonAPI.post(user, %{status: "@#{other_user.nickname}", visibility: "public"}) + + {:ok, activity} = CommonAPI.post(user, %{status: ".", visibility: "public"}) + + {:ok, reply} = + CommonAPI.post(other_user, %{ + status: ".", + visibility: "public", + in_reply_to_status_id: activity.id + }) + + {:ok, _favorite} = CommonAPI.favorite(user, reply.id) + + activity_ids = + conn + |> get("/api/v1/notifications?exclude_visibilities[]=direct&limit=2") + |> json_response_and_validate_schema(200) + |> Enum.map(& &1["status"]["id"]) + + assert [reply.id, mention.id] == activity_ids + end end test "filters notifications using exclude_types" do diff --git a/test/web/mastodon_api/views/notification_view_test.exs b/test/web/mastodon_api/views/notification_view_test.exs index b2fa5b302..aa1196db0 100644 --- a/test/web/mastodon_api/views/notification_view_test.exs +++ b/test/web/mastodon_api/views/notification_view_test.exs @@ -139,9 +139,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do test_notifications_rendering([notification], followed, [expected]) User.perform(:delete, follower) - notification = Notification |> Repo.one() |> Repo.preload(:activity) - - test_notifications_rendering([notification], followed, []) + refute Repo.one(Notification) end @tag capture_log: true @@ -174,7 +172,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do expected = %{ id: to_string(notification.id), pleroma: %{is_seen: false}, - type: "move", + type: "pleroma:move", account: AccountView.render("show.json", %{user: old_user, for: follower}), target: AccountView.render("show.json", %{user: new_user, for: follower}), created_at: Utils.to_masto_date(notification.inserted_at) |