diff options
author | lain <lain@soykaf.club> | 2020-05-04 13:10:36 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-04 13:10:36 +0200 |
commit | b04328c3dec4812dbaf3cd89baa2b888d7bb7fbf (patch) | |
tree | 8f8bce14828758f84345505c38cd3aaa701da4d8 /test | |
parent | 30590cf46b88d0008c9a7163b8339aa9376f2378 (diff) | |
download | pleroma-b04328c3dec4812dbaf3cd89baa2b888d7bb7fbf.tar.gz |
ChatController: Add mark_as_read
Diffstat (limited to 'test')
-rw-r--r-- | test/web/pleroma_api/controllers/chat_controller_test.exs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/web/pleroma_api/controllers/chat_controller_test.exs b/test/web/pleroma_api/controllers/chat_controller_test.exs index b1044574b..cdb2683c8 100644 --- a/test/web/pleroma_api/controllers/chat_controller_test.exs +++ b/test/web/pleroma_api/controllers/chat_controller_test.exs @@ -9,6 +9,29 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do import Pleroma.Factory + describe "POST /api/v1/pleroma/chats/:id/read" do + setup do: oauth_access(["write:statuses"]) + + test "it marks all messages in a chat as read", %{conn: conn, user: user} do + other_user = insert(:user) + + {:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id) + + assert chat.unread == 1 + + result = + conn + |> post("/api/v1/pleroma/chats/#{chat.id}/read") + |> json_response_and_validate_schema(200) + + assert result["unread"] == 0 + + {:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id) + + assert chat.unread == 0 + end + end + describe "POST /api/v1/pleroma/chats/:id/messages" do setup do: oauth_access(["write:statuses"]) |