diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/activity/ir/topics_test.exs | 2 | ||||
-rw-r--r-- | test/pleroma/web/activity_pub/mrf/simple_policy_test.exs | 6 | ||||
-rw-r--r-- | test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs | 4 | ||||
-rw-r--r-- | test/pleroma/web/activity_pub/transmogrifier_test.exs | 41 | ||||
-rw-r--r-- | test/pleroma/web/common_api/utils_test.exs | 3 | ||||
-rw-r--r-- | test/pleroma/web/common_api_test.exs | 3 | ||||
-rw-r--r-- | test/pleroma/web/mastodon_api/views/status_view_test.exs | 4 | ||||
-rw-r--r-- | test/support/factory.ex | 2 |
8 files changed, 37 insertions, 28 deletions
diff --git a/test/pleroma/activity/ir/topics_test.exs b/test/pleroma/activity/ir/topics_test.exs index b464822d9..dd1611bbe 100644 --- a/test/pleroma/activity/ir/topics_test.exs +++ b/test/pleroma/activity/ir/topics_test.exs @@ -78,7 +78,7 @@ defmodule Pleroma.Activity.Ir.TopicsTest do end test "converts tags to hash tags", %{activity: %{object: %{data: data} = object} = activity} do - tagged_data = Map.put(data, "tag", ["foo", "bar"]) + tagged_data = Map.put(data, "hashtags", ["foo", "bar"]) activity = %{activity | object: %{object | data: tagged_data}} topics = Topics.get_activity_topics(activity) diff --git a/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs b/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs index d7dde62c4..9777fcde1 100644 --- a/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs @@ -78,7 +78,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do assert SimplePolicy.filter(media_message) == {:ok, media_message - |> put_in(["object", "tag"], ["foo", "nsfw"]) + |> put_in(["object", "hashtags"], ["foo", "nsfw"]) |> put_in(["object", "sensitive"], true)} assert SimplePolicy.filter(local_message) == {:ok, local_message} @@ -92,7 +92,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do assert SimplePolicy.filter(media_message) == {:ok, media_message - |> put_in(["object", "tag"], ["foo", "nsfw"]) + |> put_in(["object", "hashtags"], ["foo", "nsfw"]) |> put_in(["object", "sensitive"], true)} assert SimplePolicy.filter(local_message) == {:ok, local_message} @@ -105,7 +105,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do "type" => "Create", "object" => %{ "attachment" => [%{}], - "tag" => ["foo"], + "hashtags" => ["foo"], "sensitive" => false } } diff --git a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs index b4a006aec..528636f04 100644 --- a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs @@ -39,7 +39,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) object = Object.normalize(data["object"]) - assert "test" in object.data["tag"] + assert ["test"] == object.data["hashtags"] end test "it cleans up incoming notices which are not really DMs" do @@ -220,7 +220,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) object = Object.normalize(data["object"]) - assert Enum.at(object.data["tag"], 2) == "moo" + assert object.data["hashtags"] == ["moo"] end test "it works for incoming notices with contentMap" do diff --git a/test/pleroma/web/activity_pub/transmogrifier_test.exs b/test/pleroma/web/activity_pub/transmogrifier_test.exs index 66ea7664a..d0bd00b58 100644 --- a/test/pleroma/web/activity_pub/transmogrifier_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier_test.exs @@ -204,30 +204,37 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do {:ok, activity} = CommonAPI.post(user, %{status: "#2hu :firefox:"}) - {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data) - - assert length(modified["object"]["tag"]) == 2 - - assert is_nil(modified["object"]["emoji"]) - assert is_nil(modified["object"]["like_count"]) - assert is_nil(modified["object"]["announcements"]) - assert is_nil(modified["object"]["announcement_count"]) - assert is_nil(modified["object"]["context_id"]) + {:ok, %{"object" => modified_object}} = Transmogrifier.prepare_outgoing(activity.data) + + assert [ + %{"name" => "#2hu", "type" => "Hashtag"}, + %{"name" => ":firefox:", "type" => "Emoji"} + ] = modified_object["tag"] + + refute Map.has_key?(modified_object, "hashtags") + refute Map.has_key?(modified_object, "emoji") + refute Map.has_key?(modified_object, "like_count") + refute Map.has_key?(modified_object, "announcements") + refute Map.has_key?(modified_object, "announcement_count") + refute Map.has_key?(modified_object, "context_id") end test "it strips internal fields of article" do activity = insert(:article_activity) - {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data) + {:ok, %{"object" => modified_object}} = Transmogrifier.prepare_outgoing(activity.data) - assert length(modified["object"]["tag"]) == 2 + assert [ + %{"name" => "#2hu", "type" => "Hashtag"}, + %{"name" => ":2hu:", "type" => "Emoji"} + ] = modified_object["tag"] - assert is_nil(modified["object"]["emoji"]) - assert is_nil(modified["object"]["like_count"]) - assert is_nil(modified["object"]["announcements"]) - assert is_nil(modified["object"]["announcement_count"]) - assert is_nil(modified["object"]["context_id"]) - assert is_nil(modified["object"]["likes"]) + refute Map.has_key?(modified_object, "hashtags") + refute Map.has_key?(modified_object, "emoji") + refute Map.has_key?(modified_object, "like_count") + refute Map.has_key?(modified_object, "announcements") + refute Map.has_key?(modified_object, "announcement_count") + refute Map.has_key?(modified_object, "context_id") end test "the directMessage flag is present" do diff --git a/test/pleroma/web/common_api/utils_test.exs b/test/pleroma/web/common_api/utils_test.exs index 4d6c9ea26..211042192 100644 --- a/test/pleroma/web/common_api/utils_test.exs +++ b/test/pleroma/web/common_api/utils_test.exs @@ -591,7 +591,8 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do "context" => "2hu", "sensitive" => false, "summary" => "test summary", - "tag" => ["jimm"], + "hashtags" => ["jimm"], + "tag" => [], "to" => [user2.ap_id], "type" => "Note", "custom_tag" => "test" diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs index 585b2c174..3b7ac2033 100644 --- a/test/pleroma/web/common_api_test.exs +++ b/test/pleroma/web/common_api_test.exs @@ -493,7 +493,8 @@ defmodule Pleroma.Web.CommonAPITest do object = Object.normalize(activity) - assert object.data["tag"] == ["2hu"] + assert object.data["tag"] == [] + assert object.data["hashtags"] == ["2hu"] end test "it adds emoji in the object" do diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs index fa9066716..d4378ccbc 100644 --- a/test/pleroma/web/mastodon_api/views/status_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/status_view_test.exs @@ -262,8 +262,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do mentions: [], tags: [ %{ - name: "#{object_data["tag"]}", - url: "/tag/#{object_data["tag"]}" + name: "2hu", + url: "/tag/2hu" } ], application: %{ diff --git a/test/support/factory.ex b/test/support/factory.ex index 8eb07dc3c..a709d0dae 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -93,7 +93,7 @@ defmodule Pleroma.Factory do "like_count" => 0, "context" => "2hu", "summary" => "2hu", - "tag" => ["2hu"], + "hashtags" => ["2hu"], "emoji" => %{ "2hu" => "corndog.png" } |