2020-06-03 12:56:39 +02:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-13 07:49:20 +01:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-06-03 12:56:39 +02:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-06-06 11:51:10 +02:00
|
|
|
defmodule Pleroma.Chat.MessageReferenceTest do
|
2020-06-03 12:56:39 +02:00
|
|
|
use Pleroma.DataCase, async: true
|
|
|
|
|
|
|
|
alias Pleroma.Chat
|
2020-06-06 11:51:10 +02:00
|
|
|
alias Pleroma.Chat.MessageReference
|
2020-06-03 12:56:39 +02:00
|
|
|
alias Pleroma.Web.CommonAPI
|
|
|
|
|
|
|
|
import Pleroma.Factory
|
|
|
|
|
|
|
|
describe "messages" do
|
|
|
|
test "it returns the last message in a chat" do
|
|
|
|
user = insert(:user)
|
|
|
|
recipient = insert(:user)
|
|
|
|
|
|
|
|
{:ok, _message_1} = CommonAPI.post_chat_message(user, recipient, "hey")
|
|
|
|
{:ok, _message_2} = CommonAPI.post_chat_message(recipient, user, "ho")
|
|
|
|
|
|
|
|
{:ok, chat} = Chat.get_or_create(user.id, recipient.ap_id)
|
|
|
|
|
2020-06-06 11:51:10 +02:00
|
|
|
message = MessageReference.last_message_for_chat(chat)
|
2020-06-03 12:56:39 +02:00
|
|
|
|
|
|
|
assert message.object.data["content"] == "ho"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|