Resilience Test: Add notification check for killing likes.

This commit is contained in:
lain 2021-01-06 12:49:18 +01:00
parent a24b2bc38a
commit 07bf36142b
1 changed files with 18 additions and 2 deletions

View File

@ -8,13 +8,13 @@ defmodule Pleroma.ResilienceTest do
import Pleroma.Factory import Pleroma.Factory
alias Pleroma.Activity alias Pleroma.Activity
alias Pleroma.Web.CommonAPI
alias Pleroma.Repo alias Pleroma.Repo
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.MastodonAPI.StatusView alias Pleroma.Web.MastodonAPI.StatusView
setup do setup do
# user = insert(:user) # user = insert(:user)
%{user: user, conn: conn} = oauth_access(["write:statuses"]) %{user: user, conn: conn} = oauth_access(["write", "read"])
other_user = insert(:user) other_user = insert(:user)
{:ok, post_one} = CommonAPI.post(user, %{status: "Here is a post"}) {:ok, post_one} = CommonAPI.post(user, %{status: "Here is a post"})
@ -54,8 +54,17 @@ test "after destruction of like activities, things still work", %{
assert liking_user["id"] == other_user.id assert liking_user["id"] == other_user.id
# We have one notification
[notification] =
conn
|> get("/api/v1/notifications")
|> json_response(200)
assert notification["type"] == "favourite"
# Destroying the like # Destroying the like
Repo.delete(like) Repo.delete(like)
post = Repo.get(Activity, post.id)
# Rendering the liked status # Rendering the liked status
rendered_for_user = StatusView.render("show.json", %{activity: post, for: user}) rendered_for_user = StatusView.render("show.json", %{activity: post, for: user})
@ -73,6 +82,13 @@ test "after destruction of like activities, things still work", %{
assert liking_user["id"] == other_user.id assert liking_user["id"] == other_user.id
# Notification is removed
assert [] ==
conn
|> get("/api/v1/notifications")
|> json_response(200)
# Favoriting again doesn't hurt # Favoriting again doesn't hurt
{:ok, _like_two} = CommonAPI.favorite(other_user, post.id) {:ok, _like_two} = CommonAPI.favorite(other_user, post.id)