aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2020-10-31 17:01:29 +0000
committerfeld <feld@feld.me>2020-10-31 17:01:29 +0000
commit37e8e8bf8ef560bc42d8b470c25e6022b369590b (patch)
treecc8d402d6fc77b23a62db3011643885f34029f30 /test
parent4fbdd1c8a12fd2b3dc6b63ccbbaa7d4241fa778e (diff)
parent8e41baff40555ef7c74c8842d6fbfebc2368631a (diff)
downloadpleroma-37e8e8bf8ef560bc42d8b470c25e6022b369590b.tar.gz
Merge branch 'idempotency-key-optimistic-posting' into 'develop'
Add `idempotency_key` to the chat message entity Closes #2126 See merge request pleroma/pleroma!3015
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs2
-rw-r--r--test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs5
-rw-r--r--test/pleroma/web/streamer_test.exs4
3 files changed, 9 insertions, 2 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..fa6b9db65 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
diff --git a/test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs b/test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs
index f171a1e55..ae8257870 100644
--- a/test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs
+++ b/test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs
@@ -25,7 +25,9 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
}
{:ok, upload} = ActivityPub.upload(file, actor: user.ap_id)
- {:ok, activity} = CommonAPI.post_chat_message(user, recipient, "kippis :firefox:")
+
+ {:ok, activity} =
+ CommonAPI.post_chat_message(user, recipient, "kippis :firefox:", idempotency_key: "123")
chat = Chat.get(user.id, recipient.ap_id)
@@ -42,6 +44,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
assert chat_message[:created_at]
assert chat_message[:unread] == false
assert match?([%{shortcode: "firefox"}], chat_message[:emojis])
+ assert chat_message[:idempotency_key] == "123"
clear_config([:rich_media, :enabled], true)
diff --git a/test/pleroma/web/streamer_test.exs b/test/pleroma/web/streamer_test.exs
index 185724a9f..395016da2 100644
--- a/test/pleroma/web/streamer_test.exs
+++ b/test/pleroma/web/streamer_test.exs
@@ -255,7 +255,9 @@ defmodule Pleroma.Web.StreamerTest do
} do
other_user = insert(:user)
- {:ok, create_activity} = CommonAPI.post_chat_message(other_user, user, "hey cirno")
+ {:ok, create_activity} =
+ CommonAPI.post_chat_message(other_user, user, "hey cirno", idempotency_key: "123")
+
object = Object.normalize(create_activity, false)
chat = Chat.get(user.id, other_user.ap_id)
cm_ref = MessageReference.for_chat_and_object(chat, object)