1 defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
4 alias Pleroma.Web.CommonAPI
5 alias Pleroma.Web.CommonAPI.Utils
6 alias Pleroma.Web.TwitterAPI.ActivityView
7 alias Pleroma.Web.TwitterAPI.UserView
8 alias Pleroma.Web.TwitterAPI.TwitterAPI
11 test "a create activity with a note" do
13 other_user = insert(:user, %{nickname: "shp"})
15 {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
17 result = ActivityView.render("activity.json", activity: activity)
19 convo_id = TwitterAPI.context_to_conversation_id(activity.data["object"]["context"])
22 "activity_type" => "post",
25 UserView.render("show.json", %{user: other_user})
27 "created_at" => activity.data["object"]["published"] |> Utils.date_to_asctime(),
28 "external_url" => activity.data["object"]["id"],
32 "in_reply_to_status_id" => nil,
34 "is_post_verb" => true,
35 "possibly_sensitive" => false,
38 "statusnet_conversation_id" => convo_id,
40 "Hey <span><a href=\"#{other_user.ap_id}\">@<span>shp</span></a></span>!",
42 "text" => "Hey @shp!",
43 "uri" => activity.data["object"]["id"],
44 "user" => UserView.render("show.json", %{user: user})
47 assert result == expected
50 test "an activity that is a reply" do
52 other_user = insert(:user, %{nickname: "shp"})
54 {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
57 CommonAPI.post(other_user, %{"status" => "Hi!", "in_reply_to_status_id" => activity.id})
59 result = ActivityView.render("activity.json", %{activity: answer})
61 assert result["in_reply_to_status_id"] == activity.id
64 test "a like activity" do
66 other_user = insert(:user, %{nickname: "shp"})
68 {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
69 {:ok, like, _object} = CommonAPI.favorite(activity.id, other_user)
71 result = ActivityView.render("activity.json", activity: like)
74 "activity_type" => "like",
75 "created_at" => like.data["published"] |> Utils.date_to_asctime(),
76 "external_url" => like.data["id"],
78 "in_reply_to_status_id" => activity.id,
80 "is_post_verb" => false,
81 "statusnet_html" => "shp favorited a status.",
82 "text" => "shp favorited a status.",
83 "uri" => "tag:#{like.data["id"]}:objectType=Favourite",
84 "user" => UserView.render("show.json", user: other_user)
87 assert result == expected