aboutsummaryrefslogtreecommitdiff
path: root/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-11-04 17:48:10 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-11-04 17:48:10 +0300
commit73e66fd31fdfe8cc483fb77df235ddef31708aeb (patch)
tree26e4d4e4f62e95c808dbe3a2a820de9b4ab9dd02 /test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
parent04f6b48ac1a76fe9c6c3fd573427d418bc152adf (diff)
parent9c09ea01aa8c93e02b5697e27f0a8458b624b161 (diff)
downloadpleroma-73e66fd31fdfe8cc483fb77df235ddef31708aeb.tar.gz
Merge remote-tracking branch 'remotes/origin/develop' into auth-improvements
Diffstat (limited to 'test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs')
-rw-r--r--test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
index 6381f9757..c1e6a8cc5 100644
--- a/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
+++ b/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
@@ -82,11 +82,13 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
result =
conn
|> put_req_header("content-type", "application/json")
+ |> put_req_header("idempotency-key", "123")
|> post("/api/v1/pleroma/chats/#{chat.id}/messages", %{"content" => "Hallo!!"})
|> json_response_and_validate_schema(200)
assert result["content"] == "Hallo!!"
assert result["chat_id"] == chat.id |> to_string()
+ assert result["idempotency_key"] == "123"
end
test "it fails if there is no content", %{conn: conn, user: user} do
@@ -341,6 +343,35 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
assert length(result) == 0
end
+ test "it does not return chats with users you muted", %{conn: conn, user: user} do
+ recipient = insert(:user)
+
+ {:ok, _} = Chat.get_or_create(user.id, recipient.ap_id)
+
+ result =
+ conn
+ |> get("/api/v1/pleroma/chats")
+ |> json_response_and_validate_schema(200)
+
+ assert length(result) == 1
+
+ User.mute(user, recipient)
+
+ result =
+ conn
+ |> get("/api/v1/pleroma/chats")
+ |> json_response_and_validate_schema(200)
+
+ assert length(result) == 0
+
+ result =
+ conn
+ |> get("/api/v1/pleroma/chats?with_muted=true")
+ |> json_response_and_validate_schema(200)
+
+ assert length(result) == 1
+ end
+
test "it returns all chats", %{conn: conn, user: user} do
Enum.each(1..30, fn _ ->
recipient = insert(:user)