Fix incorrect test description
[akkoma] / test / pleroma / web / mastodon_api / controllers / subscription_controller_test.exs
index d36bb1ae8f75beb1202d820eab5c97afcc1f1760..955cd9912fb2cecf8283273a8ec99037c651868d 100644 (file)
@@ -46,7 +46,7 @@ defmodule Pleroma.Web.MastodonAPI.SubscriptionControllerTest do
   end
 
   describe "creates push subscription" do
-    test "returns error when push disabled ", %{conn: conn} do
+    test "does not return unsupported types", %{conn: conn} do
       assert_error_when_disable_push do
         conn
         |> post("/api/v1/push/subscription", %{subscription: @sub})
@@ -54,12 +54,39 @@ defmodule Pleroma.Web.MastodonAPI.SubscriptionControllerTest do
       end
     end
 
+    test "ignores unsupported types", %{conn: conn} do
+      result =
+        conn
+        |> post("/api/v1/push/subscription", %{
+          "data" => %{
+            "alerts" => %{
+              "fake_unsupported_type" => true
+            }
+          },
+          "subscription" => @sub
+        })
+        |> json_response_and_validate_schema(200)
+
+      refute %{
+               "alerts" => %{
+                 "fake_unsupported_type" => true
+               }
+             } == result
+    end
+
     test "successful creation", %{conn: conn} do
       result =
         conn
         |> post("/api/v1/push/subscription", %{
           "data" => %{
-            "alerts" => %{"mention" => true, "test" => true, "pleroma:chat_mention" => true}
+            "alerts" => %{
+              "mention" => true,
+              "favourite" => true,
+              "follow" => true,
+              "reblog" => true,
+              "pleroma:chat_mention" => true,
+              "pleroma:emoji_reaction" => true
+            }
           },
           "subscription" => @sub
         })
@@ -68,7 +95,14 @@ defmodule Pleroma.Web.MastodonAPI.SubscriptionControllerTest do
       [subscription] = Pleroma.Repo.all(Subscription)
 
       assert %{
-               "alerts" => %{"mention" => true, "pleroma:chat_mention" => true},
+               "alerts" => %{
+                 "mention" => true,
+                 "favourite" => true,
+                 "follow" => true,
+                 "reblog" => true,
+                 "pleroma:chat_mention" => true,
+                 "pleroma:emoji_reaction" => true
+               },
                "endpoint" => subscription.endpoint,
                "id" => to_string(subscription.id),
                "server_key" => @server_key
@@ -124,7 +158,16 @@ defmodule Pleroma.Web.MastodonAPI.SubscriptionControllerTest do
         insert(:push_subscription,
           user: user,
           token: token,
-          data: %{"alerts" => %{"mention" => true}}
+          data: %{
+            "alerts" => %{
+              "mention" => true,
+              "favourite" => true,
+              "follow" => true,
+              "reblog" => true,
+              "pleroma:chat_mention" => true,
+              "pleroma:emoji_reaction" => true
+            }
+          }
         )
 
       %{conn: conn, user: user, token: token, subscription: subscription}
@@ -133,7 +176,16 @@ defmodule Pleroma.Web.MastodonAPI.SubscriptionControllerTest do
     test "returns error when push disabled ", %{conn: conn} do
       assert_error_when_disable_push do
         conn
-        |> put("/api/v1/push/subscription", %{data: %{"alerts" => %{"mention" => false}}})
+        |> put("/api/v1/push/subscription", %{
+          data: %{
+            "mention" => false,
+            "favourite" => false,
+            "follow" => false,
+            "reblog" => false,
+            "pleroma:chat_mention" => false,
+            "pleroma:emoji_reaction" => false
+          }
+        })
         |> json_response_and_validate_schema(403)
       end
     end
@@ -142,12 +194,28 @@ defmodule Pleroma.Web.MastodonAPI.SubscriptionControllerTest do
       res =
         conn
         |> put("/api/v1/push/subscription", %{
-          data: %{"alerts" => %{"mention" => false, "follow" => true}}
+          data: %{
+            "alerts" => %{
+              "mention" => false,
+              "favourite" => false,
+              "follow" => false,
+              "reblog" => false,
+              "pleroma:chat_mention" => false,
+              "pleroma:emoji_reaction" => false
+            }
+          }
         })
         |> json_response_and_validate_schema(200)
 
       expect = %{
-        "alerts" => %{"follow" => true, "mention" => false},
+        "alerts" => %{
+          "mention" => false,
+          "favourite" => false,
+          "follow" => false,
+          "reblog" => false,
+          "pleroma:chat_mention" => false,
+          "pleroma:emoji_reaction" => false
+        },
         "endpoint" => "https://example.com/example/1234",
         "id" => to_string(subscription.id),
         "server_key" => @server_key