summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorrinpatch <rin@patch.cx>2021-02-17 15:14:27 +0000
committerrinpatch <rin@patch.cx>2021-02-17 15:14:27 +0000
commit158f9f18ee61fda5371ee62314c46da90b57eb5a (patch)
tree866d598011ffb17f8b8e193fbf5d3829e3e20833 /test
parent264cb2c77f51d0caacffa6e84f631cec1131eec5 (diff)
parentcf6d3db58f20de5224fa77dbf902e78a653ced96 (diff)
Merge branch 'remove-conversation-api' into 'develop'
Add API endpoint to remove a conversation Closes #2488 See merge request pleroma/pleroma!3321
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/conversation/participation_test.exs12
-rw-r--r--test/pleroma/web/mastodon_api/controllers/conversation_controller_test.exs26
2 files changed, 38 insertions, 0 deletions
diff --git a/test/pleroma/conversation/participation_test.exs b/test/pleroma/conversation/participation_test.exs
index 8b039cd78..a25e17c95 100644
--- a/test/pleroma/conversation/participation_test.exs
+++ b/test/pleroma/conversation/participation_test.exs
@@ -359,4 +359,16 @@ defmodule Pleroma.Conversation.ParticipationTest do
assert Participation.unread_count(blocked) == 1
end
end
+
+ test "deletes a conversation" do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, _activity} =
+ CommonAPI.post(user, %{status: "Hey @#{other_user.nickname}.", visibility: "direct"})
+
+ assert [participation] = Participation.for_user(other_user)
+ assert {:ok, _} = Participation.delete(participation)
+ assert [] == Participation.for_user(other_user)
+ end
end
diff --git a/test/pleroma/web/mastodon_api/controllers/conversation_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/conversation_controller_test.exs
index 29bc4fd17..3176f1296 100644
--- a/test/pleroma/web/mastodon_api/controllers/conversation_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/conversation_controller_test.exs
@@ -217,6 +217,32 @@ defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest do
assert %{"ancestors" => [], "descendants" => []} == json_response(res_conn, 200)
end
+ test "Removes a conversation", %{user: user_one, conn: conn} do
+ user_two = insert(:user)
+ token = insert(:oauth_token, user: user_one, scopes: ["read:statuses", "write:conversations"])
+
+ {:ok, _direct} = create_direct_message(user_one, [user_two])
+ {:ok, _direct} = create_direct_message(user_one, [user_two])
+
+ assert [%{"id" => conv1_id}, %{"id" => conv2_id}] =
+ conn
+ |> assign(:token, token)
+ |> get("/api/v1/conversations")
+ |> json_response_and_validate_schema(200)
+
+ assert %{} =
+ conn
+ |> assign(:token, token)
+ |> delete("/api/v1/conversations/#{conv1_id}")
+ |> json_response_and_validate_schema(200)
+
+ assert [%{"id" => ^conv2_id}] =
+ conn
+ |> assign(:token, token)
+ |> get("/api/v1/conversations")
+ |> json_response_and_validate_schema(200)
+ end
+
defp create_direct_message(sender, recips) do
hellos =
recips