summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/support/factory.ex13
-rw-r--r--test/web/activity_pub/activity_pub_controller_test.exs12
-rw-r--r--test/web/twitter_api/views/activity_view_test.exs33
3 files changed, 56 insertions, 2 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex
index e5c0c5bcc..57fa4a79d 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -57,6 +57,19 @@ defmodule Pleroma.Factory do
%Pleroma.Object{data: Map.merge(data, %{"to" => [user2.ap_id]})}
end
+ def tombstone_factory do
+ data = %{
+ "type" => "Tombstone",
+ "id" => Pleroma.Web.ActivityPub.Utils.generate_object_id(),
+ "formerType" => "Note",
+ "deleted" => DateTime.utc_now() |> DateTime.to_iso8601()
+ }
+
+ %Pleroma.Object{
+ data: data
+ }
+ end
+
def direct_note_activity_factory do
dm = insert(:direct_note)
diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs
index 620e03674..7d1fe184e 100644
--- a/test/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/web/activity_pub/activity_pub_controller_test.exs
@@ -75,6 +75,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
assert json_response(conn, 404)
end
+
+ test "it returns 404 for tombstone objects", %{conn: conn} do
+ tombstone = insert(:tombstone)
+ uuid = String.split(tombstone.data["id"], "/") |> List.last()
+
+ conn =
+ conn
+ |> put_req_header("accept", "application/activity+json")
+ |> get("/objects/#{uuid}")
+
+ assert json_response(conn, 404)
+ end
end
describe "/inbox" do
diff --git a/test/web/twitter_api/views/activity_view_test.exs b/test/web/twitter_api/views/activity_view_test.exs
index 013245033..05780a54a 100644
--- a/test/web/twitter_api/views/activity_view_test.exs
+++ b/test/web/twitter_api/views/activity_view_test.exs
@@ -41,6 +41,35 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
"#Bike log - Commute Tuesday\nhttps://pla.bike/posts/20181211/\n#cycling #CHScycling #commute\nMVIMG_20181211_054020.jpg"
end
+ test "a create activity with a summary containing emoji" do
+ {:ok, activity} =
+ CommonAPI.post(insert(:user), %{
+ "spoiler_text" => ":woollysocks: meow",
+ "status" => "."
+ })
+
+ result = ActivityView.render("activity.json", activity: activity)
+
+ expected =
+ "<img height=\"32px\" width=\"32px\" alt=\"woollysocks\" title=\"woollysocks\" src=\"http://localhost:4001/finmoji/128px/woollysocks-128.png\" /> meow"
+
+ assert result["summary"] == expected
+ end
+
+ test "a create activity with a summary containing invalid HTML" do
+ {:ok, activity} =
+ CommonAPI.post(insert(:user), %{
+ "spoiler_text" => "<span style=\"color: magenta; font-size: 32px;\">meow</span>",
+ "status" => "."
+ })
+
+ result = ActivityView.render("activity.json", activity: activity)
+
+ expected = "meow"
+
+ assert result["summary"] == expected
+ end
+
test "a create activity with a note" do
user = insert(:user)
other_user = insert(:user, %{nickname: "shp"})
@@ -73,14 +102,14 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
"repeat_num" => 0,
"repeated" => false,
"statusnet_conversation_id" => convo_id,
+ "summary" => "",
"statusnet_html" =>
"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"],
"user" => UserView.render("show.json", %{user: user}),
- "visibility" => "direct",
- "summary" => nil
+ "visibility" => "direct"
}
assert result == expected