logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

conversation_view_test.exs (1374B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.MastodonAPI.ConversationViewTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.Conversation.Participation
  7. alias Pleroma.Web.CommonAPI
  8. alias Pleroma.Web.MastodonAPI.ConversationView
  9. import Pleroma.Factory
  10. test "represents a Mastodon Conversation entity" do
  11. user = insert(:user)
  12. other_user = insert(:user)
  13. {:ok, parent} = CommonAPI.post(user, %{status: "parent"})
  14. {:ok, activity} =
  15. CommonAPI.post(user, %{
  16. status: "hey @#{other_user.nickname}",
  17. visibility: "direct",
  18. in_reply_to_id: parent.id
  19. })
  20. {:ok, _reply_activity} =
  21. CommonAPI.post(user, %{status: "hu", visibility: "public", in_reply_to_id: parent.id})
  22. [participation] = Participation.for_user_with_last_activity_id(user)
  23. assert participation
  24. conversation =
  25. ConversationView.render("participation.json", %{participation: participation, for: user})
  26. assert conversation.id == participation.id |> to_string()
  27. assert conversation.last_status.id == activity.id
  28. assert [account] = conversation.accounts
  29. assert account.id == other_user.id
  30. assert conversation.last_status.pleroma.direct_conversation_id == participation.id
  31. end
  32. end