summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2020-11-17 20:14:38 +0000
committerMark Felder <feld@FreeBSD.org>2020-11-17 20:22:25 +0000
commit30f140e5702d59ecf8123ddb0959a7a3aefcd3f8 (patch)
tree6e575df25ef523690be8d048624e9a2af813c84a
parent499faa82f6e9bc400b059a7fd3e5a910eebe1a58 (diff)
downloadpleroma-30f140e5702d59ecf8123ddb0959a7a3aefcd3f8.tar.gz
pleroma-30f140e5702d59ecf8123ddb0959a7a3aefcd3f8.zip
Ensure all supported push notification subscription alert types are tested
-rw-r--r--test/pleroma/web/mastodon_api/controllers/subscription_controller_test.exs52
1 files changed, 46 insertions, 6 deletions
diff --git a/test/pleroma/web/mastodon_api/controllers/subscription_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/subscription_controller_test.exs
index 6e9369b3f..379260965 100644
--- a/test/pleroma/web/mastodon_api/controllers/subscription_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/subscription_controller_test.exs
@@ -61,9 +61,12 @@ defmodule Pleroma.Web.MastodonAPI.SubscriptionControllerTest do
"data" => %{
"alerts" => %{
"mention" => true,
- "test" => true,
+ "favourite" => true,
+ "follow" => true,
+ "reblog" => true,
"pleroma:chat_mention" => true,
- "pleroma:emoji_reaction" => true
+ "pleroma:emoji_reaction" => true,
+ "test" => true
}
},
"subscription" => @sub
@@ -75,6 +78,9 @@ defmodule Pleroma.Web.MastodonAPI.SubscriptionControllerTest do
assert %{
"alerts" => %{
"mention" => true,
+ "favourite" => true,
+ "follow" => true,
+ "reblog" => true,
"pleroma:chat_mention" => true,
"pleroma:emoji_reaction" => true
},
@@ -133,7 +139,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}
@@ -142,7 +157,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
@@ -151,12 +175,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