@@ -3,12 +3,7 @@ defmodule GroupherServer.Test.Query.AbuseReports.PostReport do
33
44 use GroupherServer.TestTools
55
6- import Helper.Utils , only: [ get_config: 2 ]
7-
86 alias GroupherServer.CMS
9- alias GroupherServer.Repo
10-
11- alias CMS.Post
127
138 setup do
149 { :ok , post } = db_insert ( :post )
@@ -31,6 +26,11 @@ defmodule GroupherServer.Test.Query.AbuseReports.PostReport do
3126 entries {
3227 id
3328 dealWith
29+ article {
30+ id
31+ thread
32+ title
33+ }
3434 operateUser {
3535 id
3636 login
@@ -42,6 +42,13 @@ defmodule GroupherServer.Test.Query.AbuseReports.PostReport do
4242 login
4343 }
4444 }
45+ reportCases {
46+ reason
47+ attr
48+ user {
49+ login
50+ }
51+ }
4552 }
4653 totalPages
4754 totalCount
@@ -50,29 +57,53 @@ defmodule GroupherServer.Test.Query.AbuseReports.PostReport do
5057 }
5158 }
5259 """
53- @ tag :wip
60+ @ tag :wip2
5461 test "should get pagination info" , ~m( guest_conn community post_attrs user user2) a do
5562 { :ok , post } = CMS . create_content ( community , :post , post_attrs , user )
63+ { :ok , post2 } = CMS . create_content ( community , :post , post_attrs , user )
64+
5665 { :ok , _report } = CMS . report_article ( :post , post . id , "reason" , "attr_info" , user )
57- { :ok , _report } = CMS . report_article ( :post , post . id , "reason" , "attr_info" , user2 )
66+ { :ok , _report } = CMS . report_article ( :post , post2 . id , "reason" , "attr_info" , user2 )
5867
5968 variables = % { filter: % { content_type: "POST" , page: 1 , size: 10 } }
6069 results = guest_conn |> query_result ( @ query , variables , "pagedAbuseReports" )
6170
6271 assert results |> is_valid_pagination?
72+ assert results [ "totalCount" ] == 2
6373 end
6474
6575 @ tag :wip2
76+ test "support search with id" , ~m( guest_conn user user2) a do
77+ { :ok , post } = db_insert ( :post )
78+ { :ok , post2 } = db_insert ( :post )
79+
80+ { :ok , _report } = CMS . report_article ( :post , post . id , "reason" , "attr_info" , user )
81+ { :ok , _report } = CMS . report_article ( :post , post2 . id , "reason" , "attr_info" , user2 )
82+
83+ variables = % { filter: % { content_type: "POST" , content_id: post . id , page: 1 , size: 10 } }
84+ results = guest_conn |> query_result ( @ query , variables , "pagedAbuseReports" )
85+
86+ report = results [ "entries" ] |> List . first ( )
87+
88+ assert get_in ( report , [ "article" , "thread" ] ) == "POST"
89+ assert get_in ( report , [ "article" , "id" ] ) == to_string ( post . id )
90+
91+ assert results |> is_valid_pagination?
92+ assert results [ "totalCount" ] == 1
93+ end
94+
95+ @ tag :wip3
6696 test "support article_comment" , ~m( guest_conn post user) a do
6797 { :ok , comment } = CMS . create_article_comment ( :post , post . id , "comment" , user )
6898 { :ok , _ } = CMS . report_article_comment ( comment . id , "reason" , "attr" , user )
6999
70100 variables = % { filter: % { content_type: "ARTICLE_COMMENT" , page: 1 , size: 10 } }
71101 results = guest_conn |> query_result ( @ query , variables , "pagedAbuseReports" )
72102
73- IO . inspect ( results , label: "results- -" )
74-
75103 report = results [ "entries" ] |> List . first ( )
104+ report_case = get_in ( report , [ "reportCases" ] )
105+ assert is_list ( report_case )
106+
76107 assert get_in ( report , [ "articleComment" , "bodyHtml" ] ) == "comment"
77108 assert get_in ( report , [ "articleComment" , "id" ] ) == to_string ( comment . id )
78109 assert not is_nil ( get_in ( report , [ "articleComment" , "author" , "login" ] ) )
0 commit comments