Update tests
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
parent
6ffa90a42a
commit
97b94a2f43
3 changed files with 35 additions and 9 deletions
|
|
@ -31,7 +31,8 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
"The updated chat",
|
"The updated chat",
|
||||||
"application/json",
|
"application/json",
|
||||||
Chat
|
Chat
|
||||||
)
|
),
|
||||||
|
404 => Operation.response("Not Found", "application/json", ApiError)
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
%{
|
%{
|
||||||
|
|
@ -56,7 +57,8 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
"The read ChatMessage",
|
"The read ChatMessage",
|
||||||
"application/json",
|
"application/json",
|
||||||
ChatMessage
|
ChatMessage
|
||||||
)
|
),
|
||||||
|
404 => Operation.response("Not Found", "application/json", ApiError)
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
%{
|
%{
|
||||||
|
|
@ -87,7 +89,8 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
"The existing chat",
|
"The existing chat",
|
||||||
"application/json",
|
"application/json",
|
||||||
Chat
|
Chat
|
||||||
)
|
),
|
||||||
|
404 => Operation.response("Not Found", "application/json", ApiError)
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
%{
|
%{
|
||||||
|
|
@ -118,7 +121,8 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
"The created or existing chat",
|
"The created or existing chat",
|
||||||
"application/json",
|
"application/json",
|
||||||
Chat
|
Chat
|
||||||
)
|
),
|
||||||
|
404 => Operation.response("Not Found", "application/json", ApiError)
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
%{
|
%{
|
||||||
|
|
@ -146,7 +150,8 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
Operation.parameter(:pinned, :query, BooleanLike.schema(), "Include only pinned chats")
|
Operation.parameter(:pinned, :query, BooleanLike.schema(), "Include only pinned chats")
|
||||||
],
|
],
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => Operation.response("The chats of the user", "application/json", chats_response())
|
200 => Operation.response("The chats of the user", "application/json", chats_response()),
|
||||||
|
404 => Operation.response("Not Found", "application/json", ApiError)
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
%{
|
%{
|
||||||
|
|
@ -172,7 +177,8 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
| pagination_params()
|
| pagination_params()
|
||||||
],
|
],
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => Operation.response("The chats of the user", "application/json", chats_response())
|
200 => Operation.response("The chats of the user", "application/json", chats_response()),
|
||||||
|
404 => Operation.response("Not Found", "application/json", ApiError)
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
%{
|
%{
|
||||||
|
|
@ -224,6 +230,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
ChatMessage
|
ChatMessage
|
||||||
),
|
),
|
||||||
400 => Operation.response("Bad Request", "application/json", ApiError),
|
400 => Operation.response("Bad Request", "application/json", ApiError),
|
||||||
|
404 => Operation.response("Not Found", "application/json", ApiError),
|
||||||
422 => Operation.response("MRF Rejection", "application/json", ApiError)
|
422 => Operation.response("MRF Rejection", "application/json", ApiError)
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
|
|
@ -249,7 +256,8 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
"The deleted ChatMessage",
|
"The deleted ChatMessage",
|
||||||
"application/json",
|
"application/json",
|
||||||
ChatMessage
|
ChatMessage
|
||||||
)
|
),
|
||||||
|
404 => Operation.response("Not Found", "application/json", ApiError)
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
%{
|
%{
|
||||||
|
|
@ -268,7 +276,8 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
Operation.parameter(:id, :path, :string, "The id of the chat", required: true)
|
Operation.parameter(:id, :path, :string, "The id of the chat", required: true)
|
||||||
],
|
],
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => Operation.response("The existing chat", "application/json", Chat)
|
200 => Operation.response("The existing chat", "application/json", Chat),
|
||||||
|
404 => Operation.response("Not Found", "application/json", ApiError)
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
%{
|
%{
|
||||||
|
|
@ -287,7 +296,8 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
Operation.parameter(:id, :path, :string, "The id of the chat", required: true)
|
Operation.parameter(:id, :path, :string, "The id of the chat", required: true)
|
||||||
],
|
],
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => Operation.response("The existing chat", "application/json", Chat)
|
200 => Operation.response("The existing chat", "application/json", Chat),
|
||||||
|
404 => Operation.response("Not Found", "application/json", ApiError)
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
%{
|
%{
|
||||||
|
|
|
||||||
|
|
@ -220,5 +220,13 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do
|
||||||
"acceptsChatMessages"
|
"acceptsChatMessages"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it returns false if chat is disabled" do
|
||||||
|
clear_config([Pleroma.Chat, :enabled], false)
|
||||||
|
user = insert(:user, accepts_chat_messages: true)
|
||||||
|
|
||||||
|
assert %{"capabilities" => %{"acceptsChatMessages" => false}} =
|
||||||
|
UserView.render("user.json", user: user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -546,6 +546,14 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
|
||||||
account_ids = Enum.map(result, &get_in(&1, ["account", "id"]))
|
account_ids = Enum.map(result, &get_in(&1, ["account", "id"]))
|
||||||
assert Enum.sort(account_ids) == Enum.sort([user2.id, user3.id])
|
assert Enum.sort(account_ids) == Enum.sort([user2.id, user3.id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it returns 404 when chats are disabled", %{conn: conn} do
|
||||||
|
clear_config([Pleroma.Chat, :enabled], false)
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> get(unquote(tested_endpoint))
|
||||||
|
|> json_response_and_validate_schema(404)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue