Fetch user feed on externalprofile request.
[akkoma] / test / web / twitter_api / representers / user_representer_test.exs
index 1e92c519046391e6dffbaed50e9187a90e1f3a99..f62ce1da3fba46039b47d63fd0aa8891f88fe232 100644 (file)
@@ -8,7 +8,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenterTest do
   import Pleroma.Factory
 
   setup do
-    user = insert(:user)
+    user = insert(:user, bio: "<span>Here's some html</span>")
     [user: user]
   end
 
@@ -33,11 +33,14 @@ defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenterTest do
 
     image = "https://placehold.it/48x48"
 
+    created_at = user.inserted_at |> DateTime.from_naive!("Etc/UTC") |> UserRepresenter.format_asctime
+
     represented = %{
       "id" => user.id,
       "name" => user.name,
       "screen_name" => user.nickname,
-      "description" => user.bio,
+      "description" => HtmlSanitizeEx.strip_tags(user.bio),
+      "created_at" => created_at,
       # Fake fields
       "favourites_count" => 0,
       "statuses_count" => 1,
@@ -48,7 +51,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenterTest do
       "profile_image_url_profile_size" => image,
       "profile_image_url_original" => image,
       "following" => false,
-      "rights" => %{}
+      "rights" => %{},
+      "statusnet_profile_url" => user.ap_id
     }
 
     assert represented == UserRepresenter.to_map(user)
@@ -57,11 +61,13 @@ defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenterTest do
   test "A user for a given other follower", %{user: user} do
     {:ok, follower} = UserBuilder.insert(%{following: [User.ap_followers(user)]})
     image = "https://placehold.it/48x48"
+    created_at = user.inserted_at |> DateTime.from_naive!("Etc/UTC") |> UserRepresenter.format_asctime
     represented = %{
       "id" => user.id,
       "name" => user.name,
       "screen_name" => user.nickname,
-      "description" => user.bio,
+      "description" => HtmlSanitizeEx.strip_tags(user.bio),
+      "created_at" => created_at,
       # Fake fields
       "favourites_count" => 0,
       "statuses_count" => 0,
@@ -72,7 +78,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenterTest do
       "profile_image_url_profile_size" => image,
       "profile_image_url_original" => image,
       "following" => true,
-      "rights" => %{}
+      "rights" => %{},
+      "statusnet_profile_url" => user.ap_id
     }
 
     assert represented == UserRepresenter.to_map(user, %{for: follower})