@@ -222,7 +222,6 @@ defmodule GroupherServer.Test.Query.PostComment do
222
222
entries {
223
223
id
224
224
likesCount
225
- dislikesCount
226
225
}
227
226
totalPages
228
227
totalCount
@@ -286,43 +285,6 @@ defmodule GroupherServer.Test.Query.PostComment do
286
285
assert entries |> Enum . at ( 1 ) |> Map . get ( "likesCount" ) == 4
287
286
end
288
287
289
- test "MOST_DISLIKES filter should work" , ~m( guest_conn post user community) a do
290
- body = "test comment"
291
-
292
- comments =
293
- Enum . reduce ( 1 .. 10 , [ ] , fn _ , acc ->
294
- { :ok , value } =
295
- CMS . create_comment ( :post , post . id , % { community: community . raw , body: body } , user )
296
-
297
- acc ++ [ value ]
298
- end )
299
-
300
- [ comment_1 , _comment_2 , comment_3 , _comment_last ] = comments |> firstn_and_last ( 3 )
301
- { :ok , [ user_1 , user_2 , user_3 , user_4 , user_5 ] } = db_insert_multi ( :user , 5 )
302
-
303
- # comment_3 is most likes
304
- { :ok , _ } = CMS . dislike_comment ( :post_comment , comment_3 . id , user_1 )
305
- { :ok , _ } = CMS . dislike_comment ( :post_comment , comment_3 . id , user_2 )
306
- { :ok , _ } = CMS . dislike_comment ( :post_comment , comment_3 . id , user_3 )
307
- { :ok , _ } = CMS . dislike_comment ( :post_comment , comment_3 . id , user_4 )
308
- { :ok , _ } = CMS . dislike_comment ( :post_comment , comment_3 . id , user_5 )
309
-
310
- { :ok , _ } = CMS . dislike_comment ( :post_comment , comment_1 . id , user_1 )
311
- { :ok , _ } = CMS . dislike_comment ( :post_comment , comment_1 . id , user_2 )
312
- { :ok , _ } = CMS . dislike_comment ( :post_comment , comment_1 . id , user_3 )
313
- { :ok , _ } = CMS . dislike_comment ( :post_comment , comment_1 . id , user_4 )
314
-
315
- variables = % { id: post . id , filter: % { page: 1 , size: 10 , sort: "MOST_DISLIKES" } }
316
- results = guest_conn |> query_result ( @ query , variables , "pagedComments" )
317
- entries = results [ "entries" ]
318
-
319
- assert entries |> Enum . at ( 0 ) |> Map . get ( "id" ) == to_string ( comment_3 . id )
320
- assert entries |> Enum . at ( 0 ) |> Map . get ( "dislikesCount" ) == 5
321
-
322
- assert entries |> Enum . at ( 1 ) |> Map . get ( "id" ) == to_string ( comment_1 . id )
323
- assert entries |> Enum . at ( 1 ) |> Map . get ( "dislikesCount" ) == 4
324
- end
325
-
326
288
@ query """
327
289
query($id: ID!, $filter: CommentsFilter!) {
328
290
pagedComments(id: $id, filter: $filter) {
@@ -399,47 +361,6 @@ defmodule GroupherServer.Test.Query.PostComment do
399
361
assert found [ "likes" ] |> Enum . any? ( & ( & 1 [ "id" ] == to_string ( user . id ) ) )
400
362
end
401
363
402
- @ query """
403
- query($id: ID!, $filter: CommentsFilter!) {
404
- pagedComments(id: $id, filter: $filter) {
405
- entries {
406
- id
407
- body
408
- author {
409
- id
410
- nickname
411
- }
412
- dislikesCount
413
- dislikes {
414
- id
415
- nickname
416
- }
417
- }
418
- }
419
- }
420
- """
421
- test "guest user can get dislikes info" , ~m( guest_conn post user community) a do
422
- body = "test comment"
423
-
424
- { :ok , comment } =
425
- CMS . create_comment ( :post , post . id , % { community: community . raw , body: body } , user )
426
-
427
- { :ok , _like } = CMS . dislike_comment ( :post_comment , comment . id , user )
428
-
429
- variables = % { id: post . id , filter: % { page: 1 , size: 10 } }
430
- results = guest_conn |> query_result ( @ query , variables , "pagedComments" )
431
-
432
- found =
433
- results [ "entries" ] |> Enum . filter ( & ( & 1 [ "id" ] == to_string ( comment . id ) ) ) |> List . first ( )
434
-
435
- author = found |> Map . get ( "author" )
436
-
437
- assert author [ "id" ] == to_string ( user . id )
438
- assert found [ "dislikesCount" ] == 1
439
-
440
- assert found [ "dislikes" ] |> Enum . any? ( & ( & 1 [ "id" ] == to_string ( user . id ) ) )
441
- end
442
-
443
364
@ query """
444
365
query($id: ID!, $filter: CommentsFilter!) {
445
366
pagedComments(id: $id, filter: $filter) {