summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/chat_test.exs6
-rw-r--r--test/web/activity_pub/side_effects_test.exs2
-rw-r--r--test/web/pleroma_api/controllers/chat_controller_test.exs11
3 files changed, 8 insertions, 11 deletions
diff --git a/test/chat_test.exs b/test/chat_test.exs
index 42e01fe27..332f2180a 100644
--- a/test/chat_test.exs
+++ b/test/chat_test.exs
@@ -6,7 +6,6 @@ defmodule Pleroma.ChatTest do
use Pleroma.DataCase, async: true
alias Pleroma.Chat
- alias Pleroma.Web.CommonAPI
import Pleroma.Factory
@@ -35,7 +34,6 @@ defmodule Pleroma.ChatTest do
{:ok, chat_two} = Chat.bump_or_create(user.id, other_user.ap_id)
assert chat.id == chat_two.id
- assert chat_two.unread == 2
end
test "it returns a chat for a user and recipient if it already exists" do
@@ -48,15 +46,13 @@ defmodule Pleroma.ChatTest do
assert chat.id == chat_two.id
end
- test "a returning chat will have an updated `update_at` field and an incremented unread count" do
+ test "a returning chat will have an updated `update_at` field" do
user = insert(:user)
other_user = insert(:user)
{:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
- assert chat.unread == 1
:timer.sleep(1500)
{:ok, chat_two} = Chat.bump_or_create(user.id, other_user.ap_id)
- assert chat_two.unread == 2
assert chat.id == chat_two.id
assert chat.updated_at != chat_two.updated_at
diff --git a/test/web/activity_pub/side_effects_test.exs b/test/web/activity_pub/side_effects_test.exs
index ff6b3ac15..f2fa062b4 100644
--- a/test/web/activity_pub/side_effects_test.exs
+++ b/test/web/activity_pub/side_effects_test.exs
@@ -346,7 +346,6 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
SideEffects.handle(create_activity, local: false, object_data: chat_message_data)
chat = Chat.get(author.id, recipient.ap_id)
- assert chat.unread == 0
[cm_ref] = ChatMessageReference.for_chat_query(chat) |> Repo.all()
@@ -354,7 +353,6 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
assert cm_ref.seen == true
chat = Chat.get(recipient.id, author.ap_id)
- assert chat.unread == 1
[cm_ref] = ChatMessageReference.for_chat_query(chat) |> Repo.all()
diff --git a/test/web/pleroma_api/controllers/chat_controller_test.exs b/test/web/pleroma_api/controllers/chat_controller_test.exs
index bd4024c09..e62b71799 100644
--- a/test/web/pleroma_api/controllers/chat_controller_test.exs
+++ b/test/web/pleroma_api/controllers/chat_controller_test.exs
@@ -19,9 +19,12 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
test "it marks all messages in a chat as read", %{conn: conn, user: user} do
other_user = insert(:user)
- {:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
+ {:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
+ {:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
+ object = Object.normalize(create, false)
+ cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
- assert chat.unread == 1
+ assert cm_ref.seen == false
result =
conn
@@ -30,9 +33,9 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
assert result["unread"] == 0
- {:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
+ cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
- assert chat.unread == 0
+ assert cm_ref.seen == true
end
end