Merge branch 'support/issue_449' into 'develop'
[akkoma] / test / web / twitter_api / views / activity_view_test.exs
index 5cef06f882e7017c3c473685a978d92fa96bcacd..8aa9e3130dc4aaba2be6a972a6c6616442fa3bd6 100644 (file)
@@ -14,6 +14,22 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
   import Pleroma.Factory
   import Mock
 
+  test "a create activity with a html status" do
+    text = """
+    #Bike log - Commute Tuesday\nhttps://pla.bike/posts/20181211/\n#cycling #CHScycling #commute\nMVIMG_20181211_054020.jpg
+    """
+
+    {:ok, activity} = CommonAPI.post(insert(:user), %{"status" => text})
+
+    result = ActivityView.render("activity.json", activity: activity)
+
+    assert result["statusnet_html"] ==
+             "<a data-tag=\"bike\" href=\"http://localhost:4001/tag/bike\">#Bike</a> log - Commute Tuesday<br /><a href=\"https://pla.bike/posts/20181211/\">https://pla.bike/posts/20181211/</a><br /><a data-tag=\"cycling\" href=\"http://localhost:4001/tag/cycling\">#cycling</a> <a data-tag=\"chscycling\" href=\"http://localhost:4001/tag/chscycling\">#CHScycling</a> <a data-tag=\"commute\" href=\"http://localhost:4001/tag/commute\">#commute</a><br />MVIMG_20181211_054020.jpg"
+
+    assert result["text"] ==
+             "#Bike log - Commute Tuesday\nhttps://pla.bike/posts/20181211/\n#cycling #CHScycling #commute\nMVIMG_20181211_054020.jpg"
+  end
+
   test "a create activity with a note" do
     user = insert(:user)
     other_user = insert(:user, %{nickname: "shp"})
@@ -47,7 +63,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
       "repeated" => false,
       "statusnet_conversation_id" => convo_id,
       "statusnet_html" =>
-        "Hey <span><a href=\"#{other_user.ap_id}\">@<span>shp</span></a></span>!",
+        "Hey <span><a data-user=\"#{other_user.id}\" href=\"#{other_user.ap_id}\">@<span>shp</span></a></span>!",
       "tags" => [],
       "text" => "Hey @shp!",
       "uri" => activity.data["object"]["id"],
@@ -112,6 +128,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
     {:ok, like, _object} = CommonAPI.favorite(activity.id, other_user)
 
     result = ActivityView.render("activity.json", activity: like)
+    activity = Pleroma.Activity.get_by_ap_id(activity.data["id"])
 
     expected = %{
       "activity_type" => "like",
@@ -121,6 +138,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
       "in_reply_to_status_id" => activity.id,
       "is_local" => true,
       "is_post_verb" => false,
+      "favorited_status" => ActivityView.render("activity.json", activity: activity),
       "statusnet_html" => "shp favorited a status.",
       "text" => "shp favorited a status.",
       "uri" => "tag:#{like.data["id"]}:objectType=Favourite",
@@ -148,6 +166,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
       "in_reply_to_status_id" => nil,
       "is_local" => true,
       "is_post_verb" => false,
+      "favorited_status" => nil,
       "statusnet_html" => "shp favorited a status.",
       "text" => "shp favorited a status.",
       "uri" => "tag:#{like.data["id"]}:objectType=Favourite",