X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fmastodon_api%2Fcontrollers%2Fnotification_controller_test.exs;h=8c815b415eff8eb0d4c61b1838b1535dfb101a1a;hb=a185b5455fc1ddf0d91c983c66c2161f9ade8867;hp=42a311f99ce42c585030ce3698ebd52401cd92a8;hpb=2f2bd7fe72f474b7177c751a2dc3af716622ba91;p=akkoma
diff --git a/test/web/mastodon_api/controllers/notification_controller_test.exs b/test/web/mastodon_api/controllers/notification_controller_test.exs
index 42a311f99..8c815b415 100644
--- a/test/web/mastodon_api/controllers/notification_controller_test.exs
+++ b/test/web/mastodon_api/controllers/notification_controller_test.exs
@@ -46,7 +46,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|> get("/api/v1/notifications")
expected_response =
- "hi @#{user.nickname}"
@@ -65,7 +65,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
conn = get(conn, "/api/v1/notifications/#{notification.id}")
expected_response =
- "hi @#{user.nickname}"
@@ -73,7 +73,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
assert response == expected_response
end
- test "dismissing a single notification" do
+ test "dismissing a single notification (deprecated endpoint)" do
%{user: user, conn: conn} = oauth_access(["write:notifications"])
other_user = insert(:user)
@@ -89,6 +89,22 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
assert %{} = json_response(conn, 200)
end
+ test "dismissing a single notification" do
+ %{user: user, conn: conn} = oauth_access(["write:notifications"])
+ other_user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+
+ {:ok, [notification]} = Notification.create_notifications(activity)
+
+ conn =
+ conn
+ |> assign(:user, user)
+ |> post("/api/v1/notifications/#{notification.id}/dismiss")
+
+ assert %{} = json_response(conn, 200)
+ end
+
test "clearing all notifications" do
%{user: user, conn: conn} = oauth_access(["write:notifications", "read:notifications"])
other_user = insert(:user)
@@ -214,10 +230,10 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
{:ok, private_activity} =
CommonAPI.post(other_user, %{"status" => ".", "visibility" => "private"})
- {:ok, _, _} = CommonAPI.favorite(public_activity.id, user)
- {:ok, _, _} = CommonAPI.favorite(direct_activity.id, user)
- {:ok, _, _} = CommonAPI.favorite(unlisted_activity.id, user)
- {:ok, _, _} = CommonAPI.favorite(private_activity.id, user)
+ {:ok, _} = CommonAPI.favorite(user, public_activity.id)
+ {:ok, _} = CommonAPI.favorite(user, direct_activity.id)
+ {:ok, _} = CommonAPI.favorite(user, unlisted_activity.id)
+ {:ok, _} = CommonAPI.favorite(user, private_activity.id)
activity_ids =
conn
@@ -294,7 +310,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
{:ok, mention_activity} = CommonAPI.post(other_user, %{"status" => "hey @#{user.nickname}"})
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
- {:ok, favorite_activity, _} = CommonAPI.favorite(create_activity.id, other_user)
+ {:ok, favorite_activity} = CommonAPI.favorite(other_user, create_activity.id)
{:ok, reblog_activity, _} = CommonAPI.repeat(create_activity.id, other_user)
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
@@ -330,7 +346,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
{:ok, mention_activity} = CommonAPI.post(other_user, %{"status" => "hey @#{user.nickname}"})
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
- {:ok, favorite_activity, _} = CommonAPI.favorite(create_activity.id, other_user)
+ {:ok, favorite_activity} = CommonAPI.favorite(other_user, create_activity.id)
{:ok, reblog_activity, _} = CommonAPI.repeat(create_activity.id, other_user)
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
@@ -472,11 +488,24 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
assert length(json_response(conn, 200)) == 1
end
+ @tag capture_log: true
test "see move notifications" do
old_user = insert(:user)
new_user = insert(:user, also_known_as: [old_user.ap_id])
%{user: follower, conn: conn} = oauth_access(["read:notifications"])
+ old_user_url = old_user.ap_id
+
+ body =
+ File.read!("test/fixtures/users_mock/localhost.json")
+ |> String.replace("{{nickname}}", old_user.nickname)
+ |> Jason.encode!()
+
+ Tesla.Mock.mock(fn
+ %{method: :get, url: ^old_user_url} ->
+ %Tesla.Env{status: 200, body: body}
+ end)
+
User.follow(follower, old_user)
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
Pleroma.Tests.ObanHelpers.perform_all()