Pleroma.Constants: Fix typo.
[akkoma] / test / web / common_api / common_api_test.exs
index 5fda91438a7c514119132ee3122f2f6936b19530..011fcfca95b9f432175bd20314240574629d8e72 100644 (file)
@@ -213,10 +213,8 @@ defmodule Pleroma.Web.CommonAPITest do
         |> NaiveDateTime.truncate(:second)
         |> NaiveDateTime.add(1_000_000, :second)
 
-      expires_at_iso8601 = expires_at |> NaiveDateTime.to_iso8601()
-
       assert {:ok, activity} =
-               CommonAPI.post(user, %{"status" => "chai", "expires_at" => expires_at_iso8601})
+               CommonAPI.post(user, %{"status" => "chai", "expires_in" => 1_000_000})
 
       assert expiration = Pleroma.ActivityExpiration.get_by_activity_id(activity.id)
       assert expiration.scheduled_at == expires_at
@@ -224,6 +222,20 @@ defmodule Pleroma.Web.CommonAPITest do
   end
 
   describe "reactions" do
+    test "reacting to a status with an emoji" do
+      user = insert(:user)
+      other_user = insert(:user)
+
+      {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+
+      {:ok, reaction, _} = CommonAPI.react_with_emoji(activity.id, user, "👍")
+
+      assert reaction.data["actor"] == user.ap_id
+      assert reaction.data["content"] == "👍"
+
+      # TODO: test error case.
+    end
+
     test "repeating a status" do
       user = insert(:user)
       other_user = insert(:user)
@@ -512,4 +524,43 @@ defmodule Pleroma.Web.CommonAPITest do
       assert {:error, "Already voted"} == CommonAPI.vote(other_user, object, [1])
     end
   end
+
+  describe "listen/2" do
+    test "returns a valid activity" do
+      user = insert(:user)
+
+      {:ok, activity} =
+        CommonAPI.listen(user, %{
+          "title" => "lain radio episode 1",
+          "album" => "lain radio",
+          "artist" => "lain",
+          "length" => 180_000
+        })
+
+      object = Object.normalize(activity)
+
+      assert object.data["title"] == "lain radio episode 1"
+
+      assert Visibility.get_visibility(activity) == "public"
+    end
+
+    test "respects visibility=private" do
+      user = insert(:user)
+
+      {:ok, activity} =
+        CommonAPI.listen(user, %{
+          "title" => "lain radio episode 1",
+          "album" => "lain radio",
+          "artist" => "lain",
+          "length" => 180_000,
+          "visibility" => "private"
+        })
+
+      object = Object.normalize(activity)
+
+      assert object.data["title"] == "lain radio episode 1"
+
+      assert Visibility.get_visibility(activity) == "private"
+    end
+  end
 end