@@ -203,102 +203,6 @@ defmodule GroupherServer.Test.Query.Account.Basic do
203203 end
204204
205205 describe "[account subscrube]" do
206- alias CMS.Community
207-
208- @ query """
209- query($login: String!) {
210- user(login: $login) {
211- id
212- nickname
213- subscribedCommunitiesCount
214- subscribedCommunities {
215- entries {
216- id
217- title
218- raw
219- index
220- }
221- pageSize
222- totalCount
223- }
224- }
225- }
226- """
227- test "guest user can get subscrubed communities list and count" , ~m( guest_conn user) a do
228- variables = % { login: user . login }
229- { :ok , communities } = db_insert_multi ( :community , assert_v ( :page_size ) )
230-
231- Enum . each (
232- communities ,
233- & CMS . subscribe_community ( % Community { id: & 1 . id } , user )
234- )
235-
236- results = guest_conn |> query_result ( @ query , variables , "user" )
237- subscribed_communities = results [ "subscribedCommunities" ] [ "entries" ]
238-
239- subscribed_communities_count = results [ "subscribedCommunitiesCount" ]
240- [ community_1 , community_2 , community_3 , community_x ] = communities |> firstn_and_last ( 3 )
241-
242- assert subscribed_communities |> Enum . any? ( & ( & 1 [ "id" ] == to_string ( community_1 . id ) ) )
243- assert subscribed_communities |> Enum . any? ( & ( & 1 [ "id" ] == to_string ( community_2 . id ) ) )
244- assert subscribed_communities |> Enum . any? ( & ( & 1 [ "id" ] == to_string ( community_3 . id ) ) )
245- assert subscribed_communities |> Enum . any? ( & ( & 1 [ "id" ] == to_string ( community_x . id ) ) )
246- assert subscribed_communities_count == assert_v ( :page_size )
247- end
248-
249- test "guest user can get subscrubed community list by index" , ~m( guest_conn user) a do
250- variables = % { login: user . login }
251- { :ok , communities } = db_insert_multi ( :community , assert_v ( :page_size ) )
252-
253- Enum . each (
254- communities ,
255- & CMS . subscribe_community ( % Community { id: & 1 . id } , user )
256- )
257-
258- [ community_1 , community_2 , community_3 , _community_x ] = communities |> firstn_and_last ( 3 )
259-
260- { :ok , _ } =
261- Accounts . set_customization ( user , % {
262- sidebar_communities_index: % {
263- community_1 . raw => 3 ,
264- community_2 . raw => 2 ,
265- community_3 . raw => 1
266- }
267- } )
268-
269- results = guest_conn |> query_result ( @ query , variables , "user" )
270- subscribed_communities = results [ "subscribedCommunities" ] [ "entries" ]
271-
272- found_community_1 =
273- Enum . find ( subscribed_communities , fn c -> c [ "raw" ] == community_1 . raw end )
274-
275- found_community_2 =
276- Enum . find ( subscribed_communities , fn c -> c [ "raw" ] == community_2 . raw end )
277-
278- found_community_3 =
279- Enum . find ( subscribed_communities , fn c -> c [ "raw" ] == community_3 . raw end )
280-
281- assert found_community_1 [ "index" ] == 3
282- assert found_community_2 [ "index" ] == 2
283- assert found_community_3 [ "index" ] == 1
284- end
285-
286- test "guest user can get subscrubed communities count of 20 at most" , ~m( guest_conn user) a do
287- variables = % { login: user . login }
288- { :ok , communities } = db_insert_multi ( :community , assert_v ( :page_size ) + 1 )
289-
290- Enum . each (
291- communities ,
292- & CMS . subscribe_community ( % Community { id: & 1 . id } , user )
293- )
294-
295- results = guest_conn |> query_result ( @ query , variables , "user" )
296- subscribed_communities = results [ "subscribedCommunities" ]
297-
298- assert subscribed_communities [ "totalCount" ] == assert_v ( :page_size ) + 1
299- assert subscribed_communities [ "pageSize" ] == assert_v ( :page_size )
300- end
301-
302206 @ query """
303207 query($filter: PagedFilter!) {
304208 subscribedCommunities(filter: $filter) {
@@ -313,7 +217,6 @@ defmodule GroupherServer.Test.Query.Account.Basic do
313217 }
314218 }
315219 """
316-
317220 test "guest user can get paged default subscrubed communities" , ~m( guest_conn) a do
318221 { :ok , _ } = db_insert_multi ( :community , 25 )
319222 { :ok , _ } = db_insert ( :community , % { raw: "home" } )
0 commit comments