logo

pleroma

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

conversation_view_test.exs (1050B)


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