From 1eaaf9bba32115172eb725d806aac42cb054d3a1 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 18 Aug 2020 15:06:56 +0200 Subject: [PATCH] Fix comments tests Signed-off-by: Thomas Citharel --- test/graphql/resolvers/comment_test.exs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/graphql/resolvers/comment_test.exs b/test/graphql/resolvers/comment_test.exs index 9e5ceabed..b9c0ebd7b 100644 --- a/test/graphql/resolvers/comment_test.exs +++ b/test/graphql/resolvers/comment_test.exs @@ -148,8 +148,8 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do end @delete_comment """ - mutation DeleteComment($commentId: ID!, $actorId: ID!) { - deleteComment(commentId: $commentId, actorId: $actorId) { + mutation DeleteComment($commentId: ID!) { + deleteComment(commentId: $commentId) { id, deletedAt } @@ -163,31 +163,35 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do conn |> AbsintheHelpers.graphql_query( query: @delete_comment, - variables: %{commentId: comment.id, actorId: actor.id} + variables: %{commentId: comment.id} ) assert hd(res["errors"])["message"] == "You are not allowed to delete a comment if not connected" + # Change the current actor for user actor2 = insert(:actor, user: user) + Mobilizon.Users.update_user_default_actor(user.id, actor2.id) res = conn |> auth_conn(user) |> AbsintheHelpers.graphql_query( query: @delete_comment, - variables: %{commentId: comment.id, actorId: actor2.id} + variables: %{commentId: comment.id} ) assert hd(res["errors"])["message"] == "You cannot delete this comment" + Mobilizon.Users.update_user_default_actor(user.id, actor.id) + res = conn |> auth_conn(user) |> AbsintheHelpers.graphql_query( query: @delete_comment, - variables: %{commentId: comment.id, actorId: actor.id} + variables: %{commentId: comment.id} ) assert res["errors"] == nil @@ -212,7 +216,7 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do |> auth_conn(user_moderator) |> AbsintheHelpers.graphql_query( query: @delete_comment, - variables: %{commentId: comment.id, actorId: actor_moderator.id} + variables: %{commentId: comment.id} ) assert res["data"]["deleteComment"]["id"] == to_string(comment.id)