@@ -6,11 +6,12 @@ defmodule GroupherServer.Test.Query.Accounts.Mailbox do
66 setup do
77 { :ok , user } = db_insert ( :user )
88 { :ok , user2 } = db_insert ( :user )
9+ { :ok , user3 } = db_insert ( :user )
910
1011 user_conn = simu_conn ( :user , user )
1112 guest_conn = simu_conn ( :guest )
1213
13- { :ok , ~m( user_conn guest_conn user user2) a }
14+ { :ok , ~m( user_conn guest_conn user user2 user3 ) a }
1415 end
1516
1617 describe "[mark_read/all]" do
@@ -52,14 +53,40 @@ defmodule GroupherServer.Test.Query.Accounts.Mailbox do
5253 assert notify . read
5354 end
5455
55- test "can mark read all mentions" do
56- #
57- true
56+ @ query """
57+ mutation($type: MailboxType) {
58+ markReadAll(type: $type) {
59+ done
60+ }
61+ }
62+ """
63+ @ tag :wip
64+ test "can mark read all mentions" , ~m( user_conn user user2 user3) a do
65+ { :ok , _ } = mock_mention_for ( user , user2 )
66+ { :ok , _ } = mock_mention_for ( user , user3 )
67+
68+ { :ok , mentions } = Delivery . fetch ( :mention , user , % { page: 1 , size: 10 } )
69+ assert mentions . total_count == 2
70+
71+ variables = % { type: "MENTION" }
72+ result = user_conn |> mutation_result ( @ query , variables , "markReadAll" )
73+
74+ { :ok , mentions } = Delivery . fetch ( :mention , user , % { page: 1 , size: 10 , read: true } )
75+ assert mentions . total_count == 2
5876 end
5977
60- test "can mark read all notifications" do
61- #
62- true
78+ @ tag :wip
79+ test "can mark read all notifications" , ~m( user_conn user user2) a do
80+ { :ok , _ } = mock_notification_for ( user , user2 )
81+
82+ { :ok , notifications } = Delivery . fetch ( :notification , user , % { page: 1 , size: 10 } )
83+ assert notifications . total_count == 1
84+
85+ variables = % { type: "NOTIFICATION" }
86+ result = user_conn |> mutation_result ( @ query , variables , "markReadAll" )
87+
88+ { :ok , notifications } = Delivery . fetch ( :notification , user , % { page: 1 , size: 10 , read: true } )
89+ assert notifications . total_count == 1
6390 end
6491 end
6592
0 commit comments