aboutsummaryrefslogtreecommitdiff
path: root/test/web/mastodon_api
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2019-12-03 22:13:38 +0700
committerEgor Kislitsyn <egor@kislitsyn.com>2019-12-03 22:13:38 +0700
commit624e720aa45fd54575d17a2b5e77c67deef6eb86 (patch)
tree68783e20f8bc9cc16837a194de4f15d526a60d61 /test/web/mastodon_api
parent7722e5a67a46304f3ae0e37f674a44ca9268be5e (diff)
downloadpleroma-624e720aa45fd54575d17a2b5e77c67deef6eb86.tar.gz
Add `with_move` query param to the notifications API
Diffstat (limited to 'test/web/mastodon_api')
-rw-r--r--test/web/mastodon_api/controllers/notification_controller_test.exs26
-rw-r--r--test/web/mastodon_api/views/notification_view_test.exs8
2 files changed, 30 insertions, 4 deletions
diff --git a/test/web/mastodon_api/controllers/notification_controller_test.exs b/test/web/mastodon_api/controllers/notification_controller_test.exs
index fa55a7cf9..349cca682 100644
--- a/test/web/mastodon_api/controllers/notification_controller_test.exs
+++ b/test/web/mastodon_api/controllers/notification_controller_test.exs
@@ -341,6 +341,32 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
assert length(json_response(conn, 200)) == 1
end
+ test "see move notifications with `with_move` parameter", %{
+ conn: conn
+ } do
+ old_user = insert(:user)
+ new_user = insert(:user, also_known_as: [old_user.ap_id])
+ follower = insert(:user)
+
+ User.follow(follower, old_user)
+ Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
+ Pleroma.Tests.ObanHelpers.perform_all()
+
+ conn =
+ conn
+ |> assign(:user, follower)
+ |> get("/api/v1/notifications")
+
+ assert json_response(conn, 200) == []
+
+ conn =
+ build_conn()
+ |> assign(:user, follower)
+ |> get("/api/v1/notifications", %{"with_move" => "true"})
+
+ assert length(json_response(conn, 200)) == 1
+ end
+
defp get_notification_id_by_activity(%{id: id}) do
Notification
|> Repo.get_by(activity_id: id)
diff --git a/test/web/mastodon_api/views/notification_view_test.exs b/test/web/mastodon_api/views/notification_view_test.exs
index 80b6d414c..cd36cb538 100644
--- a/test/web/mastodon_api/views/notification_view_test.exs
+++ b/test/web/mastodon_api/views/notification_view_test.exs
@@ -109,22 +109,22 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
end
test "Move notification" do
- %{ap_id: old_ap_id} = old_user = insert(:user)
- %{ap_id: _new_ap_id} = new_user = insert(:user, also_known_as: [old_ap_id])
+ old_user = insert(:user)
+ new_user = insert(:user, also_known_as: [old_user.ap_id])
follower = insert(:user)
User.follow(follower, old_user)
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
Pleroma.Tests.ObanHelpers.perform_all()
- [notification] = Notification.for_user(follower)
+ [notification] = Notification.for_user(follower, %{with_move: true})
expected = %{
id: to_string(notification.id),
pleroma: %{is_seen: false},
type: "move",
account: AccountView.render("show.json", %{user: old_user, for: follower}),
- target: AccountView.render("show.json", %{user: new_user, for: follower}),
+ target: AccountView.render("show.json", %{user: refresh_record(new_user), for: follower}),
created_at: Utils.to_masto_date(notification.inserted_at)
}