Quote posting (#113)
[akkoma] / test / pleroma / web / mastodon_api / views / status_view_test.exs
index 3ee53d95c0389cb9a42a7450ec9f0ce259e1bad7..9ef44cacaf33994000a470efa67a118fb49f35cf 100644 (file)
@@ -302,7 +302,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
         emoji_reactions: [],
         parent_visible: false,
         pinned_at: nil
-      }
+      },
+      akkoma: %{
+        source: HTML.filter_tags(object_data["content"])
+      },
+      quote_id: nil,
+      quote: nil
     }
 
     assert status == expected
@@ -390,6 +395,30 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
     assert status.in_reply_to_id == to_string(note.id)
   end
 
+  test "a quote" do
+    note = insert(:note_activity)
+    user = insert(:user)
+
+    {:ok, activity} = CommonAPI.post(user, %{status: "hehe", quote_id: note.id})
+
+    status = StatusView.render("show.json", %{activity: activity})
+
+    assert status.quote_id == to_string(note.id)
+
+    [status] = StatusView.render("index.json", %{activities: [activity], as: :activity})
+
+    assert status.quote_id == to_string(note.id)
+  end
+
+  test "a quote that we can't resolve" do
+    note = insert(:note_activity, quoteUri: "oopsie")
+
+    status = StatusView.render("show.json", %{activity: note})
+
+    assert is_nil(status.quote_id)
+    assert is_nil(status.quote)
+  end
+
   test "contains mentions" do
     user = insert(:user)
     mentioned = insert(:user)