Revert Activity tombstones, add ObjectTombstone struct
[akkoma] / test / web / mastodon_api / status_view_test.exs
index 31554a07d101e48a8ef7795edef929271ed08569..b7ac92760a35a6f23c9c9e1fd80a71e32ee795e1 100644 (file)
@@ -6,6 +6,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
   alias Pleroma.Web.OStatus
   alias Pleroma.Web.CommonAPI
   import Pleroma.Factory
+  import Tesla.Mock
+
+  setup do
+    mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
+    :ok
+  end
 
   test "a note with null content" do
     note = insert(:note_activity)
@@ -18,7 +24,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
       note
       |> Map.put(:data, data)
 
-    user = User.get_cached_by_ap_id(note.data["actor"])
+    User.get_cached_by_ap_id(note.data["actor"])
 
     status = StatusView.render("status.json", %{activity: note})
 
@@ -56,7 +62,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
       visibility: "public",
       media_attachments: [],
       mentions: [],
-      tags: [],
+      tags: [
+        %{
+          name: "#{note.data["object"]["tag"]}",
+          url: "/tag/#{note.data["object"]["tag"]}"
+        }
+      ],
       application: %{
         name: "Web",
         website: nil
@@ -145,4 +156,25 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
     assert represented[:reblog][:id] == to_string(activity.id)
     assert represented[:emojis] == []
   end
+
+  describe "build_tags/1" do
+    test "it returns a a dictionary tags" do
+      object_tags = [
+        "fediverse",
+        "mastodon",
+        "nextcloud",
+        %{
+          "href" => "https://kawen.space/users/lain",
+          "name" => "@lain@kawen.space",
+          "type" => "Mention"
+        }
+      ]
+
+      assert StatusView.build_tags(object_tags) == [
+               %{name: "fediverse", url: "/tag/fediverse"},
+               %{name: "mastodon", url: "/tag/mastodon"},
+               %{name: "nextcloud", url: "/tag/nextcloud"}
+             ]
+    end
+  end
 end