mastodon api: factor out status card fetching, move status card rendering to statusvi...
[akkoma] / test / web / mastodon_api / mastodon_api_controller_test.exs
index b4870e0b2a198716c97e8c7dc6d911c512075ecb..02a0eb228572912f3eda9a80dbf31d44eeaef1ad 100644 (file)
@@ -1048,12 +1048,12 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
     user = insert(:user)
 
     {:ok, activity_test} = CommonAPI.post(user, %{"status" => "#test"})
-    {:ok, activity_test1} = CommonAPI.post(user, %{"status" => "#test1"})
+    {:ok, activity_test1} = CommonAPI.post(user, %{"status" => "#test #test1"})
     {:ok, activity_none} = CommonAPI.post(user, %{"status" => "#test #none"})
 
     any_test =
       conn
-      |> get("/api/v1/timelines/tag/test", %{"any" => ["none"]})
+      |> get("/api/v1/timelines/tag/test", %{"any" => ["test1"]})
 
     [status_none, status_test1, status_test] = json_response(any_test, 200)
 
@@ -1065,7 +1065,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
       conn
       |> get("/api/v1/timelines/tag/test", %{"all" => ["test1"], "none" => ["none"]})
 
-    assert [status_test1, status_test] == json_response(restricted_test, 200)
+    assert [status_test1] == json_response(restricted_test, 200)
 
     all_test = conn |> get("/api/v1/timelines/tag/test", %{"all" => ["none"]})
 
@@ -1651,5 +1651,32 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
                |> post("/api/v1/statuses/#{activity_two.id}/pin")
                |> json_response(400)
     end
+
+    test "Status rich-media Card", %{conn: conn, user: user} do
+      {:ok, activity} = CommonAPI.post(user, %{"status" => "http://example.com/ogp"})
+
+      response =
+        conn
+        |> get("/api/v1/statuses/#{activity.id}/card")
+        |> json_response(200)
+
+      assert response == %{
+               "image" => "http://ia.media-imdb.com/images/rock.jpg",
+               "provider_name" => "www.imdb.com",
+               "provider_url" => "http://www.imdb.com",
+               "title" => "The Rock",
+               "type" => "link",
+               "url" => "http://www.imdb.com/title/tt0117500/",
+               "description" => nil,
+               "pleroma" => %{
+                 "opengraph" => %{
+                   "image" => "http://ia.media-imdb.com/images/rock.jpg",
+                   "title" => "The Rock",
+                   "type" => "video.movie",
+                   "url" => "http://www.imdb.com/title/tt0117500/"
+                 }
+               }
+             }
+    end
   end
 end