projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update mastofe paths (#95)
[akkoma]
/
test
/
pleroma
/
web
/
pleroma_api
/
controllers
/
chat_controller_test.exs
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 24efeeb73a36ef445a34ceec718fab2df7601ae5..1114da242aad153c53d708a102a82b6fdabfaae6 100644
(file)
--- a/
test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
+++ b/
test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
use Pleroma.Web.ConnCase
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
use Pleroma.Web.ConnCase
@@
-106,6
+106,9
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
test "it works with an attachment", %{conn: conn, user: user} do
end
test "it works with an attachment", %{conn: conn, user: user} do
+ clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
+ clear_config([Pleroma.Uploaders.Local, :uploads], "uploads")
+
file = %Plug.Upload{
content_type: "image/jpeg",
path: Path.absname("test/fixtures/image.jpg"),
file = %Plug.Upload{
content_type: "image/jpeg",
path: Path.absname("test/fixtures/image.jpg"),
@@
-211,12
+214,12
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
assert String.match?(
next,
assert String.match?(
next,
- ~r(#{api_endpoint}.*/messages\?
id=.*&
limit=\d+&max_id=.*; rel=\"next\"$)
+ ~r(#{api_endpoint}.*/messages\?limit=\d+&max_id=.*; rel=\"next\"$)
)
assert String.match?(
prev,
)
assert String.match?(
prev,
- ~r(#{api_endpoint}.*/messages\?
id=.*&
limit=\d+&min_id=.*; rel=\"prev\"$)
+ ~r(#{api_endpoint}.*/messages\?limit=\d+&min_id=.*; rel=\"prev\"$)
)
assert length(result) == 20
)
assert length(result) == 20
@@
-229,12
+232,12
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
assert String.match?(
next,
assert String.match?(
next,
- ~r(#{api_endpoint}.*/messages\?
id=.*&
limit=\d+&max_id=.*; rel=\"next\"$)
+ ~r(#{api_endpoint}.*/messages\?limit=\d+&max_id=.*; rel=\"next\"$)
)
assert String.match?(
prev,
)
assert String.match?(
prev,
- ~r(#{api_endpoint}.*/messages\?
id=.*&
limit=\d+&max_id=.*&min_id=.*; rel=\"prev\"$)
+ ~r(#{api_endpoint}.*/messages\?limit=\d+&max_id=.*&min_id=.*; rel=\"prev\"$)
)
assert length(result) == 10
)
assert length(result) == 10
@@
-304,7
+307,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
end
end
end
end
- describe "GET /api/v
1
/pleroma/chats" do
+ describe "GET /api/v
2
/pleroma/chats" do
setup do: oauth_access(["read:chats"])
test "it does not return chats with deleted users", %{conn: conn, user: user} do
setup do: oauth_access(["read:chats"])
test "it does not return chats with deleted users", %{conn: conn, user: user} do
@@
-316,7
+319,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
result =
conn
result =
conn
- |> get("/api/v
1
/pleroma/chats")
+ |> get("/api/v
2
/pleroma/chats")
|> json_response_and_validate_schema(200)
assert length(result) == 0
|> json_response_and_validate_schema(200)
assert length(result) == 0
@@
-329,7
+332,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
result =
conn
result =
conn
- |> get("/api/v
1
/pleroma/chats")
+ |> get("/api/v
2
/pleroma/chats")
|> json_response_and_validate_schema(200)
assert length(result) == 1
|> json_response_and_validate_schema(200)
assert length(result) == 1
@@
-338,7
+341,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
result =
conn
result =
conn
- |> get("/api/v
1
/pleroma/chats")
+ |> get("/api/v
2
/pleroma/chats")
|> json_response_and_validate_schema(200)
assert length(result) == 0
|> json_response_and_validate_schema(200)
assert length(result) == 0
@@
-351,7
+354,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
result =
conn
result =
conn
- |> get("/api/v
1
/pleroma/chats")
+ |> get("/api/v
2
/pleroma/chats")
|> json_response_and_validate_schema(200)
assert length(result) == 1
|> json_response_and_validate_schema(200)
assert length(result) == 1
@@
-360,20
+363,20
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
result =
conn
result =
conn
- |> get("/api/v
1
/pleroma/chats")
+ |> get("/api/v
2
/pleroma/chats")
|> json_response_and_validate_schema(200)
assert length(result) == 0
result =
conn
|> json_response_and_validate_schema(200)
assert length(result) == 0
result =
conn
- |> get("/api/v
1
/pleroma/chats?with_muted=true")
+ |> get("/api/v
2
/pleroma/chats?with_muted=true")
|> json_response_and_validate_schema(200)
assert length(result) == 1
end
|> json_response_and_validate_schema(200)
assert length(result) == 1
end
- test "it
returns all
chats", %{conn: conn, user: user} do
+ test "it
paginates
chats", %{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)
@@
-381,10
+384,18
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
result =
conn
result =
conn
- |> get("/api/v1/pleroma/chats")
+ |> get("/api/v2/pleroma/chats")
+ |> json_response_and_validate_schema(200)
+
+ assert length(result) == 20
+ last_id = List.last(result)["id"]
+
+ result =
+ conn
+ |> get("/api/v2/pleroma/chats?max_id=#{last_id}")
|> json_response_and_validate_schema(200)
|> json_response_and_validate_schema(200)
- assert length(result) ==
3
0
+ assert length(result) ==
1
0
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",
@@
-405,7
+416,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
result =
conn
result =
conn
- |> get("/api/v
1
/pleroma/chats")
+ |> get("/api/v
2
/pleroma/chats")
|> json_response_and_validate_schema(200)
ids = Enum.map(result, & &1["id"])
|> json_response_and_validate_schema(200)
ids = Enum.map(result, & &1["id"])
@@
-432,7
+443,7
@@
defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
result =
conn
result =
conn
- |> get("/api/v
1
/pleroma/chats")
+ |> get("/api/v
2
/pleroma/chats")
|> json_response_and_validate_schema(200)
account_ids = Enum.map(result, &get_in(&1, ["account", "id"]))
|> json_response_and_validate_schema(200)
account_ids = Enum.map(result, &get_in(&1, ["account", "id"]))