1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.ConversationViewTest do
8 alias Pleroma.Web.CommonAPI
9 alias Pleroma.Conversation.Participation
10 alias Pleroma.Web.MastodonAPI.ConversationView
12 import Pleroma.Factory
14 test "represents a Mastodon Conversation entity" do
16 other_user = insert(:user)
19 CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}", "visibility" => "direct"})
21 [participation] = Participation.for_user_with_last_activity_id(user)
26 ConversationView.render("participation.json", %{participation: participation, user: user})
28 assert conversation.id == participation.id |> to_string()
29 assert conversation.last_status.id == activity.id
31 assert [account] = conversation.accounts
32 assert account.id == other_user.id
34 assert recipients = conversation.pleroma.recipients
35 recipient_ids = recipients |> Enum.map(& &1.id)
37 assert user.id in recipient_ids
38 assert other_user.id in recipient_ids