projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
AccountController: Remove unused `update_?` routes.
[akkoma]
/
test
/
web
/
pleroma_api
/
controllers
/
chat_controller_test.exs
diff --git
a/test/web/pleroma_api/controllers/chat_controller_test.exs
b/test/web/pleroma_api/controllers/chat_controller_test.exs
index e73e4a32e605f4640dff33c4de2b97a2fe8bc86b..82e16741db325b457a61457c83db3a34679fee00 100644
(file)
--- a/
test/web/pleroma_api/controllers/chat_controller_test.exs
+++ b/
test/web/pleroma_api/controllers/chat_controller_test.exs
@@
-14,7
+14,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
import Pleroma.Factory
describe "POST /api/v1/pleroma/chats/:id/messages/:message_id/read" do
import Pleroma.Factory
describe "POST /api/v1/pleroma/chats/:id/messages/:message_id/read" do
- setup do: oauth_access(["write:
statuse
s"])
+ setup do: oauth_access(["write:
chat
s"])
test "it marks one message as read", %{conn: conn, user: user} do
other_user = insert(:user)
test "it marks one message as read", %{conn: conn, user: user} do
other_user = insert(:user)
@@
-41,9
+41,12
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "POST /api/v1/pleroma/chats/:id/read" do
end
describe "POST /api/v1/pleroma/chats/:id/read" do
- setup do: oauth_access(["write:
statuse
s"])
+ setup do: oauth_access(["write:
chat
s"])
- test "it marks all messages in a chat as read", %{conn: conn, user: user} do
+ test "given a `last_read_id`, it marks everything until then as read", %{
+ conn: conn,
+ user: user
+ } do
other_user = insert(:user)
{:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
other_user = insert(:user)
{:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
@@
-56,10
+59,11
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
result =
conn
result =
conn
- |> post("/api/v1/pleroma/chats/#{chat.id}/read")
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/pleroma/chats/#{chat.id}/read", %{"last_read_id" => cm_ref.id})
|> json_response_and_validate_schema(200)
|> json_response_and_validate_schema(200)
- assert result["unread"] ==
0
+ assert result["unread"] ==
1
cm_ref = MessageReference.for_chat_and_object(chat, object)
cm_ref = MessageReference.for_chat_and_object(chat, object)
@@
-68,7
+72,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "POST /api/v1/pleroma/chats/:id/messages" do
end
describe "POST /api/v1/pleroma/chats/:id/messages" do
- setup do: oauth_access(["write:
statuse
s"])
+ setup do: oauth_access(["write:
chat
s"])
test "it posts a message to the chat", %{conn: conn, user: user} do
other_user = insert(:user)
test "it posts a message to the chat", %{conn: conn, user: user} do
other_user = insert(:user)
@@
-125,7
+129,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "DELETE /api/v1/pleroma/chats/:id/messages/:message_id" do
end
describe "DELETE /api/v1/pleroma/chats/:id/messages/:message_id" do
- setup do: oauth_access(["write:
statuse
s"])
+ setup do: oauth_access(["write:
chat
s"])
test "it deletes a message from the chat", %{conn: conn, user: user} do
recipient = insert(:user)
test "it deletes a message from the chat", %{conn: conn, user: user} do
recipient = insert(:user)
@@
-169,7
+173,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "GET /api/v1/pleroma/chats/:id/messages" do
end
describe "GET /api/v1/pleroma/chats/:id/messages" do
- setup do: oauth_access(["read:
statuse
s"])
+ setup do: oauth_access(["read:
chat
s"])
test "it paginates", %{conn: conn, user: user} do
recipient = insert(:user)
test "it paginates", %{conn: conn, user: user} do
recipient = insert(:user)
@@
-229,7
+233,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "POST /api/v1/pleroma/chats/by-account-id/:id" do
end
describe "POST /api/v1/pleroma/chats/by-account-id/:id" do
- setup do: oauth_access(["write:
statuse
s"])
+ setup do: oauth_access(["write:
chat
s"])
test "it creates or returns a chat", %{conn: conn} do
other_user = insert(:user)
test "it creates or returns a chat", %{conn: conn} do
other_user = insert(:user)
@@
-244,7
+248,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "GET /api/v1/pleroma/chats/:id" do
end
describe "GET /api/v1/pleroma/chats/:id" do
- setup do: oauth_access(["read:
statuse
s"])
+ setup do: oauth_access(["read:
chat
s"])
test "it returns a chat", %{conn: conn, user: user} do
other_user = insert(:user)
test "it returns a chat", %{conn: conn, user: user} do
other_user = insert(:user)
@@
-261,7
+265,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
describe "GET /api/v1/pleroma/chats" do
end
describe "GET /api/v1/pleroma/chats" do
- setup do: oauth_access(["read:
statuse
s"])
+ setup do: oauth_access(["read:
chat
s"])
test "it does not return chats with users you blocked", %{conn: conn, user: user} do
recipient = insert(:user)
test "it does not return chats with users you blocked", %{conn: conn, user: user} do
recipient = insert(:user)
@@
-285,7
+289,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
assert length(result) == 0
end
assert length(result) == 0
end
- test "it
paginate
s", %{conn: conn, user: user} do
+ test "it
returns all chat
s", %{conn: conn, user: user} do
Enum.each(1..30, fn _ ->
recipient = insert(:user)
{:ok, _} = Chat.get_or_create(user.id, recipient.ap_id)
Enum.each(1..30, fn _ ->
recipient = insert(:user)
{:ok, _} = Chat.get_or_create(user.id, recipient.ap_id)
@@
-296,14
+300,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
|> get("/api/v1/pleroma/chats")
|> json_response_and_validate_schema(200)
|> get("/api/v1/pleroma/chats")
|> json_response_and_validate_schema(200)
- assert length(result) == 20
-
- result =
- conn
- |> get("/api/v1/pleroma/chats?max_id=#{List.last(result)["id"]}")
- |> json_response_and_validate_schema(200)
-
- assert length(result) == 10
+ assert length(result) == 30
end
test "it return a list of chats the current user is participating in, in descending order of updates",
end
test "it return a list of chats the current user is participating in, in descending order of updates",