Forgot to fix one of the links in a test
[akkoma] / test / web / twitter_api / twitter_api_test.exs
index 60daeec709b4dbbefdd70b713103f8e1c16c7def..715a746ef7805bc26a82f62653670bfb8d639cbb 100644 (file)
@@ -28,21 +28,24 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     object = Repo.insert!(%Object{data: object_data})
 
     input = %{
-      "status" => "Hello again, @shp.<script></script>\nThis is on another line. #2hu #epic #phantasmagoric",
+      "status" => "Hello again, @shp.<script></script>\nThis is on another :moominmamma: line. #2hu #epic #phantasmagoric",
       "media_ids" => [object.id]
     }
 
     { :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input)
 
-    assert get_in(activity.data, ["object", "content"]) == "Hello again, <a href='shp'>@shp</a>.&lt;script&gt;&lt;/script&gt;<br>This is on another line. #2hu #epic #phantasmagoric<br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
+    expected_text = "Hello again, <span><a href='shp'>@<span>shp</span></a></span>.&lt;script&gt;&lt;/script&gt;<br>This is on another :moominmamma: line. <a href='http://localhost:4001/tag/2hu' rel='tag'>#2hu</a> <a href='http://localhost:4001/tag/epic' rel='tag'>#epic</a> <a href='http://localhost:4001/tag/phantasmagoric' rel='tag'>#phantasmagoric</a><br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
+    assert get_in(activity.data, ["object", "content"]) == expected_text
     assert get_in(activity.data, ["object", "type"]) == "Note"
     assert get_in(activity.data, ["object", "actor"]) == user.ap_id
     assert get_in(activity.data, ["actor"]) == user.ap_id
-    assert Enum.member?(get_in(activity.data, ["to"]), User.ap_followers(user))
+    assert Enum.member?(get_in(activity.data, ["cc"]), User.ap_followers(user))
     assert Enum.member?(get_in(activity.data, ["to"]), "https://www.w3.org/ns/activitystreams#Public")
-    assert Enum.member?(get_in(activity.data, ["to"]), "shp")
+    assert Enum.member?(get_in(activity.data, ["cc"]), "shp")
     assert activity.local == true
 
+    assert %{"moominmamma" => "http://localhost:4001/finmoji/128px/moominmamma-128.png"} = activity.data["object"]["emoji"]
+
     # hashtags
     assert activity.data["object"]["tag"] == ["2hu", "epic", "phantasmagoric"]
 
@@ -78,7 +81,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     assert get_in(reply.data, ["object", "context"]) == get_in(activity.data, ["object", "context"])
     assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
     assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
-    assert Enum.member?(get_in(reply.data, ["to"]), user.ap_id)
   end
 
   test "fetch public statuses, excluding remote ones." do
@@ -97,7 +99,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     %{ public: activity, user: user } = ActivityBuilder.public_and_non_public
     insert(:note_activity, %{local: false})
 
-    follower = insert(:user, following: [User.ap_followers(user)])
+    follower = insert(:user, following: [user.follower_address])
 
     statuses = TwitterAPI.fetch_public_and_external_statuses(follower)
 
@@ -245,7 +247,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     user = insert(:user)
     User.block(user, unblocked)
 
-    {:ok, user, unblocked} = TwitterAPI.unblock(user, %{"user_id" => unblocked.id})
+    {:ok, user, _unblocked} = TwitterAPI.unblock(user, %{"user_id" => unblocked.id})
     assert user.info["blocks"] == []
   end
 
@@ -254,7 +256,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     user = insert(:user)
     User.block(user, unblocked)
 
-    {:ok, user, unblocked} = TwitterAPI.unblock(user, %{"screen_name" => unblocked.nickname})
+    {:ok, user, _unblocked} = TwitterAPI.unblock(user, %{"screen_name" => unblocked.nickname})
     assert user.info["blocks"] == []
   end
 
@@ -281,19 +283,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     assert is_binary(response)
   end
 
-  test "it adds user links to an existing text" do
-    text = "@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme@archae.me"
-
-    gsimg = insert(:user, %{nickname: "gsimg"})
-    archaeme = insert(:user, %{nickname: "archaeme"})
-    archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
-
-    mentions = Pleroma.Formatter.parse_mentions(text)
-    expected_text = "<a href='#{gsimg.ap_id}'>@gsimg</a> According to <a href='#{archaeme.ap_id}'>@archaeme</a>, that is @daggsy. Also hello <a href='#{archaeme_remote.ap_id}'>@archaeme</a>"
-
-    assert Utils.add_user_links(text, mentions) == expected_text
-  end
-
   test "it favorites a status, returns the updated status" do
     user = insert(:user)
     note_activity = insert(:note_activity)
@@ -402,7 +391,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
       assert represented["id"] == UserView.render("show.json", %{user: remote, for: user})["id"]
 
       # Also fetches the feed.
-      assert Activity.get_create_activity_by_object_ap_id("tag:mastodon.social,2017-04-05:objectId=1641750:objectType=Status")
+      assert Activity.get_create_activity_by_object_ap_id("tag:mastodon.social,2017-04-05:objectId=1641750:objectType=Status")
     end
   end
 end