Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
[akkoma] / test / web / pleroma_api / views / chat_view_test.exs
index 8568d98c631423bf605aadfbae3a51c81ea45c7f..14eecb1bdcdb626a1372b650862a80020e2c088a 100644 (file)
@@ -6,11 +6,13 @@ defmodule Pleroma.Web.PleromaAPI.ChatViewTest do
   use Pleroma.DataCase
 
   alias Pleroma.Chat
+  alias Pleroma.Chat.MessageReference
   alias Pleroma.Object
   alias Pleroma.Web.CommonAPI
+  alias Pleroma.Web.CommonAPI.Utils
   alias Pleroma.Web.MastodonAPI.AccountView
+  alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
   alias Pleroma.Web.PleromaAPI.ChatView
-  alias Pleroma.Web.PleromaAPI.ChatMessageView
 
   import Pleroma.Factory
 
@@ -26,7 +28,8 @@ defmodule Pleroma.Web.PleromaAPI.ChatViewTest do
              id: "#{chat.id}",
              account: AccountView.render("show.json", user: recipient),
              unread: 0,
-             last_message: nil
+             last_message: nil,
+             updated_at: Utils.to_masto_date(chat.updated_at)
            }
 
     {:ok, chat_message_creation} = CommonAPI.post_chat_message(user, recipient, "hello")
@@ -37,7 +40,9 @@ defmodule Pleroma.Web.PleromaAPI.ChatViewTest do
 
     represented_chat = ChatView.render("show.json", chat: chat)
 
+    cm_ref = MessageReference.for_chat_and_object(chat, chat_message)
+
     assert represented_chat[:last_message] ==
-             ChatMessageView.render("show.json", chat: chat, object: chat_message)
+             MessageReferenceView.render("show.json", chat_message_reference: cm_ref)
   end
 end