twitterapi: fix remaining test failures
[akkoma] / test / web / twitter_api / representers / activity_representer_test.exs
index bb47d440928d9f2742ea000a4106d3cf9636e320..314f2b51ff5b0780cb4265987f5d6c36026d7e81 100644 (file)
@@ -58,7 +58,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
   end
 
   test "an activity" do
-    {:ok, user} = UserBuilder.insert()
+    user = insert(:user)
     #   {:ok, mentioned_user } = UserBuilder.insert(%{nickname: "shp", ap_id: "shp"})
     mentioned_user = insert(:user, %{nickname: "shp"})
 
@@ -87,6 +87,26 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
 
     {:ok, convo_object} = Object.context_mapping("2hu") |> Repo.insert()
 
+    note_object = %{
+      "id" => "https://example.com/id/1",
+      "published" => date,
+      "type" => "Note",
+      "content" => content_html,
+      "summary" => "2hu",
+      "inReplyToStatusId" => 213_123,
+      "attachment" => [object.data],
+      "external_url" => "some url",
+      "like_count" => 5,
+      "announcement_count" => 3,
+      "context" => "2hu",
+      "tag" => ["content", "mentioning", "nsfw"],
+      "emoji" => %{
+        "2hu" => "corndog.png"
+      }
+    }
+
+    Object.create(note_object)
+
     to = [
       User.ap_followers(user),
       "https://www.w3.org/ns/activitystreams#Public",
@@ -100,24 +120,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
         "id" => "id",
         "to" => to,
         "actor" => User.ap_id(user),
-        "object" => %{
-          "published" => date,
-          "type" => "Note",
-          "content" => content_html,
-          "summary" => "2hu",
-          "inReplyToStatusId" => 213_123,
-          "attachment" => [
-            object
-          ],
-          "external_url" => "some url",
-          "like_count" => 5,
-          "announcement_count" => 3,
-          "context" => "2hu",
-          "tag" => ["content", "mentioning", "nsfw"],
-          "emoji" => %{
-            "2hu" => "corndog.png"
-          }
-        },
+        "object" => note_object["id"],
         "published" => date,
         "context" => "2hu"
       },
@@ -126,7 +129,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
     }
 
     expected_html =
-      "<span>2hu</span><br />alert('YAY')Some <img height='32px' width='32px' alt='2hu' title='2hu' src='corndog.png' /> content mentioning <a href=\"#{
+      "<p>2hu</p>alert('YAY')Some <img height=\"32px\" width=\"32px\" alt=\"2hu\" title=\"2hu\" src=\"corndog.png\" /> content mentioning <a href=\"#{
         mentioned_user.ap_id
       }\">@shp</a>"
 
@@ -139,6 +142,10 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
       "is_post_verb" => true,
       "created_at" => "Tue May 24 13:26:08 +0000 2016",
       "in_reply_to_status_id" => 213_123,
+      "in_reply_to_screen_name" => nil,
+      "in_reply_to_user_id" => nil,
+      "in_reply_to_profileurl" => nil,
+      "in_reply_to_ostatus_uri" => nil,
       "statusnet_conversation_id" => convo_object.id,
       "attachments" => [
         ObjectRepresenter.to_map(object)
@@ -154,7 +161,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
       "tags" => ["nsfw", "content", "mentioning"],
       "activity_type" => "post",
       "possibly_sensitive" => true,
-      "uri" => activity.data["object"]["id"]
+      "uri" => note_object["id"],
+      "visibility" => "direct",
+      "summary" => "2hu"
     }
 
     assert ActivityRepresenter.to_map(activity, %{