@@ -269,4 +269,62 @@ defmodule GroupherServer.Test.Mutation.Comments.BlogComment do
269
269
assert guest_conn |> mutation_get_error? ( @ query , variables , ecode ( :account_login ) )
270
270
end
271
271
end
272
+
273
+ describe "[article comment pin/unPin]" do
274
+ @ query """
275
+ mutation($id: ID!){
276
+ pinComment(id: $id) {
277
+ id
278
+ isPinned
279
+ }
280
+ }
281
+ """
282
+ @ tag :wip
283
+ test "can pin a blog's comment" , ~m( owner_conn blog user) a do
284
+ { :ok , comment } = CMS . create_comment ( :blog , blog . id , mock_comment ( ) , user )
285
+
286
+ variables = % { id: comment . id }
287
+ result = owner_conn |> mutation_result ( @ query , variables , "pinComment" )
288
+
289
+ assert result [ "id" ] == to_string ( comment . id )
290
+ assert result [ "isPinned" ]
291
+ end
292
+
293
+ @ tag :wip
294
+ test "unauth user fails." , ~m( guest_conn blog user) a do
295
+ { :ok , comment } = CMS . create_comment ( :blog , blog . id , mock_comment ( ) , user )
296
+ variables = % { id: comment . id }
297
+
298
+ assert guest_conn |> mutation_get_error? ( @ query , variables , ecode ( :account_login ) )
299
+ end
300
+
301
+ @ query """
302
+ mutation($id: ID!){
303
+ undoPinComment(id: $id) {
304
+ id
305
+ isPinned
306
+ }
307
+ }
308
+ """
309
+ @ tag :wip
310
+ test "can undo pin a blog's comment" , ~m( owner_conn blog user) a do
311
+ { :ok , comment } = CMS . create_comment ( :blog , blog . id , mock_comment ( ) , user )
312
+ { :ok , _ } = CMS . pin_comment ( comment . id )
313
+
314
+ variables = % { id: comment . id }
315
+ result = owner_conn |> mutation_result ( @ query , variables , "undoPinComment" )
316
+
317
+ assert result [ "id" ] == to_string ( comment . id )
318
+ assert not result [ "isPinned" ]
319
+ end
320
+
321
+ @ tag :wip
322
+ test "unauth user undo fails." , ~m( guest_conn blog user) a do
323
+ { :ok , comment } = CMS . create_comment ( :blog , blog . id , mock_comment ( ) , user )
324
+ { :ok , _ } = CMS . pin_comment ( comment . id )
325
+ variables = % { id: comment . id }
326
+
327
+ assert guest_conn |> mutation_get_error? ( @ query , variables , ecode ( :account_login ) )
328
+ end
329
+ end
272
330
end
0 commit comments