Save follower count and note count in user.
[akkoma] / test / web / ostatus / ostatus_test.exs
index 11b618fdbfcd1f03b729ddfc4d776cdd09c17f28..959b744afaa4dd2d5f5cfc1540f57a2f6d2c308d 100644 (file)
@@ -15,6 +15,8 @@ defmodule Pleroma.Web.OStatusTest do
     incoming = File.read!("test/fixtures/incoming_note_activity.xml")
     {:ok, [activity]} = OStatus.handle_incoming(incoming)
 
+    user = User.get_by_ap_id(activity.data["actor"])
+    assert user.info["note_count"] == 1
     assert activity.data["type"] == "Create"
     assert activity.data["object"]["type"] == "Note"
     assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note"
@@ -35,6 +37,7 @@ defmodule Pleroma.Web.OStatusTest do
     assert activity.data["object"]["content"] == "Will it blend?"
     user = User.get_cached_by_ap_id(activity.data["actor"])
     assert User.ap_followers(user) in activity.data["to"]
+    assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
   end
 
   test "handle incoming notes with attachments - GS, subscription" do
@@ -45,6 +48,8 @@ defmodule Pleroma.Web.OStatusTest do
     assert activity.data["object"]["type"] == "Note"
     assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211"
     assert activity.data["object"]["attachment"] |> length == 2
+    assert activity.data["object"]["external_url"] == "https://social.heldscal.la/notice/2020923"
+    assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
   end
 
   test "handle incoming notes with tags" do
@@ -52,6 +57,7 @@ defmodule Pleroma.Web.OStatusTest do
     {:ok, [activity]} = OStatus.handle_incoming(incoming)
 
     assert activity.data["object"]["tag"] == ["nsfw"]
+    assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
   end
 
   test "handle incoming notes - Mastodon, salmon, reply" do
@@ -68,6 +74,7 @@ defmodule Pleroma.Web.OStatusTest do
     assert activity.data["object"]["type"] == "Note"
     assert activity.data["object"]["actor"] == "https://mastodon.social/users/lambadalambda"
     assert activity.data["context"] == "2hu"
+    assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
   end
 
   test "handle incoming notes - Mastodon, with CW" do
@@ -78,6 +85,7 @@ defmodule Pleroma.Web.OStatusTest do
     assert activity.data["object"]["type"] == "Note"
     assert activity.data["object"]["actor"] == "https://mastodon.social/users/lambadalambda"
     assert String.contains?(activity.data["object"]["content"], "technologic")
+    assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
   end
 
   test "handle incoming retweets - Mastodon, with CW" do
@@ -96,6 +104,7 @@ defmodule Pleroma.Web.OStatusTest do
     assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211"
     assert activity.data["object"]["content"] == "@<a href=\"https://gs.archae.me/user/4687\" class=\"h-card u-url p-nickname mention\" title=\"shpbot\">shpbot</a> why not indeed."
     assert activity.data["object"]["inReplyTo"] == "tag:gs.archae.me,2017-04-30:noticeId=778260:objectType=note"
+    assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
   end
 
   test "handle incoming retweets - GS, subscription" do
@@ -198,6 +207,7 @@ defmodule Pleroma.Web.OStatusTest do
     assert activity.data["object"]["inReplyTo"] == "http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc"
     assert "http://pleroma.example.org:4000/users/lain5" in activity.data["to"]
     assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note"
+    assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
   end
 
   test "handle incoming follows" do