summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormarcin mikołajczak <git@mkljczk.pl>2024-08-14 19:25:51 +0200
committermarcin mikołajczak <git@mkljczk.pl>2024-08-14 19:28:11 +0200
commit8cd8cea3fb5ce87e5f92dfb45a667c47f78b6b02 (patch)
tree34aa9a26ac35dfa7e546370715b71159cc50fa29 /test
parent5174c29d4c8475d93f5635c56251064a415b1f57 (diff)
downloadpleroma-8cd8cea3fb5ce87e5f92dfb45a667c47f78b6b02.tar.gz
pleroma-8cd8cea3fb5ce87e5f92dfb45a667c47f78b6b02.zip
Fix 'Setting a marker should mark notifications as read'
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs
index d8f7b2638..4050528ff 100644
--- a/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs
@@ -5,6 +5,10 @@
defmodule Pleroma.Web.MastodonAPI.MarkerControllerTest do
use Pleroma.Web.ConnCase, async: true
+ alias Pleroma.Notification
+ alias Pleroma.Repo
+ alias Pleroma.Web.CommonAPI
+
import Pleroma.Factory
describe "GET /api/v1/markers" do
@@ -127,5 +131,36 @@ defmodule Pleroma.Web.MastodonAPI.MarkerControllerTest do
assert response == %{"error" => "Insufficient permissions: write:statuses."}
end
+
+ test "marks notifications as read", %{conn: conn} do
+ user1 = insert(:user)
+ token = insert(:oauth_token, user: user1, scopes: ["write:statuses"])
+
+ user2 = insert(:user)
+ {:ok, _activity1} = CommonAPI.post(user2, %{status: "hi @#{user1.nickname}"})
+ {:ok, _activity2} = CommonAPI.post(user2, %{status: "hi @#{user1.nickname}"})
+ {:ok, _activity3} = CommonAPI.post(user2, %{status: "HIE @#{user1.nickname}"})
+
+ [notification3, notification2, notification1] = Notification.for_user(user1, %{limit: 3})
+
+ refute Repo.get(Notification, notification1.id).seen
+ refute Repo.get(Notification, notification2.id).seen
+ refute Repo.get(Notification, notification3.id).seen
+
+ conn
+ |> assign(:user, user1)
+ |> assign(:token, token)
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/markers", %{
+ notifications: %{last_read_id: to_string(notification2.id)}
+ })
+ |> json_response_and_validate_schema(200)
+
+ [notification3, notification2, notification1] = Notification.for_user(user1, %{limit: 3})
+
+ assert Repo.get(Notification, notification1.id).seen
+ assert Repo.get(Notification, notification2.id).seen
+ refute Repo.get(Notification, notification3.id).seen
+ end
end
end