Fix comments tests

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-08-18 15:06:56 +02:00
parent cff98cc6ab
commit ea9748190c
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -148,8 +148,8 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do
end end
@delete_comment """ @delete_comment """
mutation DeleteComment($commentId: ID!, $actorId: ID!) { mutation DeleteComment($commentId: ID!) {
deleteComment(commentId: $commentId, actorId: $actorId) { deleteComment(commentId: $commentId) {
id, id,
deletedAt deletedAt
} }
@ -163,31 +163,35 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do
conn conn
|> AbsintheHelpers.graphql_query( |> AbsintheHelpers.graphql_query(
query: @delete_comment, query: @delete_comment,
variables: %{commentId: comment.id, actorId: actor.id} variables: %{commentId: comment.id}
) )
assert hd(res["errors"])["message"] == assert hd(res["errors"])["message"] ==
"You are not allowed to delete a comment if not connected" "You are not allowed to delete a comment if not connected"
# Change the current actor for user
actor2 = insert(:actor, user: user) actor2 = insert(:actor, user: user)
Mobilizon.Users.update_user_default_actor(user.id, actor2.id)
res = res =
conn conn
|> auth_conn(user) |> auth_conn(user)
|> AbsintheHelpers.graphql_query( |> AbsintheHelpers.graphql_query(
query: @delete_comment, query: @delete_comment,
variables: %{commentId: comment.id, actorId: actor2.id} variables: %{commentId: comment.id}
) )
assert hd(res["errors"])["message"] == assert hd(res["errors"])["message"] ==
"You cannot delete this comment" "You cannot delete this comment"
Mobilizon.Users.update_user_default_actor(user.id, actor.id)
res = res =
conn conn
|> auth_conn(user) |> auth_conn(user)
|> AbsintheHelpers.graphql_query( |> AbsintheHelpers.graphql_query(
query: @delete_comment, query: @delete_comment,
variables: %{commentId: comment.id, actorId: actor.id} variables: %{commentId: comment.id}
) )
assert res["errors"] == nil assert res["errors"] == nil
@ -212,7 +216,7 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do
|> auth_conn(user_moderator) |> auth_conn(user_moderator)
|> AbsintheHelpers.graphql_query( |> AbsintheHelpers.graphql_query(
query: @delete_comment, query: @delete_comment,
variables: %{commentId: comment.id, actorId: actor_moderator.id} variables: %{commentId: comment.id}
) )
assert res["data"]["deleteComment"]["id"] == to_string(comment.id) assert res["data"]["deleteComment"]["id"] == to_string(comment.id)