Test for case-insensitive mastodon hashtag timelines.
[akkoma] / test / web / mastodon_api / mastodon_api_controller_test.exs
index e9deae64d9d89bc65aabd3dd390ac78654d0d377..3f9324fccc76f4fad1bf74d257b974feca714c29 100644 (file)
@@ -198,6 +198,21 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
     assert activity.data["object"]["inReplyToStatusId"] == replied_to.id
   end
 
+  test "posting a status with an invalid in_reply_to_id", %{conn: conn} do
+    user = insert(:user)
+
+    conn =
+      conn
+      |> assign(:user, user)
+      |> post("/api/v1/statuses", %{"status" => "xD", "in_reply_to_id" => ""})
+
+    assert %{"content" => "xD", "id" => id} = json_response(conn, 200)
+
+    activity = Repo.get(Activity, id)
+
+    assert activity
+  end
+
   test "verify_credentials", %{conn: conn} do
     user = insert(:user)
 
@@ -280,6 +295,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
       assert response = json_response(conn, 200)
       assert response["phrase"] == filter.phrase
       assert response["context"] == filter.context
+      assert response["id"] != nil
+      assert response["id"] != ""
     end
 
     test "fetching a list of filters", %{conn: conn} do
@@ -927,11 +944,20 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
       {:ok, [_activity]} =
         OStatus.fetch_activity_from_url("https://shitposter.club/notice/2827873")
 
-      conn =
+      nconn =
         conn
         |> get("/api/v1/timelines/tag/2hu")
 
-      assert [%{"id" => id}] = json_response(conn, 200)
+      assert [%{"id" => id}] = json_response(nconn, 200)
+
+      assert id == to_string(activity.id)
+
+      # works for different capitalization too
+      nconn =
+        conn
+        |> get("/api/v1/timelines/tag/2HU")
+
+      assert [%{"id" => id}] = json_response(nconn, 200)
 
       assert id == to_string(activity.id)
     end)