@@ -267,72 +267,5 @@ defmodule GroupherServer.Test.Mutation.PostComment do
267267
268268 assert found . likes |> Enum . any? ( & ( & 1 . post_comment_id == comment . id ) )
269269 end
270-
271- @ undo_like_comment_query """
272- mutation($thread: CmsComment!, $id: ID!) {
273- undoLikeComment(thread: $thread, id: $id) {
274- id
275- }
276- }
277- """
278- test "login user can undo a like action to comment" , ~m( user comment) a do
279- variables = % { thread: "POST_COMMENT" , id: comment . id }
280- user_conn = simu_conn ( :user , user )
281- user_conn |> mutation_result ( @ like_comment_query , variables , "likeComment" )
282-
283- { :ok , found } = CMS.PostComment |> ORM . find ( comment . id , preload: :likes )
284- assert found . likes |> Enum . any? ( & ( & 1 . post_comment_id == comment . id ) )
285-
286- user_conn |> mutation_result ( @ undo_like_comment_query , variables , "undoLikeComment" )
287-
288- { :ok , found } = CMS.PostComment |> ORM . find ( comment . id , preload: :likes )
289- assert false == found . likes |> Enum . any? ( & ( & 1 . post_comment_id == comment . id ) )
290- end
291-
292- @ dislike_comment_query """
293- mutation($thread: CmsComment!, $id: ID!) {
294- dislikeComment(thread: $thread, id: $id) {
295- id
296- }
297- }
298- """
299- test "login user can dislike a comment" , ~m( user_conn comment) a do
300- variables = % { thread: "POST_COMMENT" , id: comment . id }
301- user_conn |> mutation_result ( @ dislike_comment_query , variables , "dislikeComment" )
302-
303- { :ok , found } = CMS.PostComment |> ORM . find ( comment . id , preload: :dislikes )
304-
305- assert found . dislikes |> Enum . any? ( & ( & 1 . post_comment_id == comment . id ) )
306- end
307-
308- @ undo_dislike_comment_query """
309- mutation($thread: CmsComment!, $id: ID!) {
310- undoDislikeComment(thread: $thread, id: $id) {
311- id
312- }
313- }
314- """
315- test "login user can undo dislike a comment" , ~m( user comment) a do
316- variables = % { thread: "POST_COMMENT" , id: comment . id }
317- user_conn = simu_conn ( :user , user )
318- user_conn |> mutation_result ( @ dislike_comment_query , variables , "dislikeComment" )
319- { :ok , found } = CMS.PostComment |> ORM . find ( comment . id , preload: :dislikes )
320- assert found . dislikes |> Enum . any? ( & ( & 1 . post_comment_id == comment . id ) )
321-
322- user_conn |> mutation_result ( @ undo_dislike_comment_query , variables , "undoDislikeComment" )
323-
324- { :ok , found } = CMS.PostComment |> ORM . find ( comment . id , preload: :dislikes )
325- assert false == found . dislikes |> Enum . any? ( & ( & 1 . post_comment_id == comment . id ) )
326- end
327-
328- test "unloged user do/undo like/dislike comment fails" , ~m( guest_conn comment) a do
329- variables = % { thread: "POST_COMMENT" , id: comment . id }
330-
331- assert guest_conn |> mutation_get_error? ( @ like_comment_query , variables )
332- assert guest_conn |> mutation_get_error? ( @ dislike_comment_query , variables )
333-
334- assert guest_conn |> mutation_get_error? ( @ undo_like_comment_query , variables )
335- assert guest_conn |> mutation_get_error? ( @ undo_dislike_comment_query , variables )
336- end
337270 end
338271end
0 commit comments