X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fmastodon_api%2Fviews%2Fstatus_view_test.exs;h=9ef44cacaf33994000a470efa67a118fb49f35cf;hb=1419eee5dfe1f3d76c28ab7c6f3cb24ba652fef2;hp=9dfdf8bf064da99035d867dc7f2a022cb84fc0f9;hpb=cc9e456c0a5110ee17342e70de59fde75bf742fe;p=akkoma 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 9dfdf8bf0..9ef44caca 100644 --- a/test/pleroma/web/mastodon_api/views/status_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/status_view_test.exs @@ -34,16 +34,25 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do {:ok, activity} = CommonAPI.post(user, %{status: "dae cofe??"}) {:ok, _} = CommonAPI.react_with_emoji(activity.id, user, "☕") + {:ok, _} = CommonAPI.react_with_emoji(activity.id, user, ":dinosaur:") {:ok, _} = CommonAPI.react_with_emoji(activity.id, third_user, "🍵") {:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "☕") + {:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, ":dinosaur:") + activity = Repo.get(Activity, activity.id) status = StatusView.render("show.json", activity: activity) assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec()) assert status[:pleroma][:emoji_reactions] == [ - %{name: "☕", count: 2, me: false}, - %{name: "🍵", count: 1, me: false} + %{name: "☕", count: 2, me: false, url: nil}, + %{ + count: 2, + me: false, + name: "dinosaur", + url: "http://localhost:4001/emoji/dino walking.gif" + }, + %{name: "🍵", count: 1, me: false, url: nil} ] status = StatusView.render("show.json", activity: activity, for: user) @@ -51,8 +60,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec()) assert status[:pleroma][:emoji_reactions] == [ - %{name: "☕", count: 2, me: true}, - %{name: "🍵", count: 1, me: false} + %{name: "☕", count: 2, me: true, url: nil}, + %{ + count: 2, + me: true, + name: "dinosaur", + url: "http://localhost:4001/emoji/dino walking.gif" + }, + %{name: "🍵", count: 1, me: false, url: nil} ] end @@ -65,11 +80,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do |> Object.update_data(%{"reactions" => %{"☕" => [user.ap_id], "x" => 1}}) activity = Activity.get_by_id(activity.id) - status = StatusView.render("show.json", activity: activity, for: user) assert status[:pleroma][:emoji_reactions] == [ - %{name: "☕", count: 1, me: true} + %{name: "☕", count: 1, me: true, url: nil} ] end @@ -89,7 +103,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do status = StatusView.render("show.json", activity: activity) assert status[:pleroma][:emoji_reactions] == [ - %{name: "☕", count: 1, me: false} + %{name: "☕", count: 1, me: false, url: nil} ] status = StatusView.render("show.json", activity: activity, for: user) @@ -101,19 +115,19 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do status = StatusView.render("show.json", activity: activity) assert status[:pleroma][:emoji_reactions] == [ - %{name: "☕", count: 2, me: false} + %{name: "☕", count: 2, me: false, url: nil} ] status = StatusView.render("show.json", activity: activity, for: user) assert status[:pleroma][:emoji_reactions] == [ - %{name: "☕", count: 1, me: false} + %{name: "☕", count: 1, me: false, url: nil} ] status = StatusView.render("show.json", activity: activity, for: other_user) assert status[:pleroma][:emoji_reactions] == [ - %{name: "☕", count: 1, me: true} + %{name: "☕", count: 1, me: true, url: nil} ] end @@ -288,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 @@ -376,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)