@@ -171,12 +171,12 @@ def loop_times(times)
171171 response = @client . update_user_partial ( {
172172 id : user_id ,
173173 set : {
174- team : 'blue' ,
174+ teams : [ 'blue' ] ,
175175 teams_role : { 'blue' => 'admin' }
176176 }
177177 } )
178178
179- expect ( response [ 'users' ] [ user_id ] [ 'team ' ] ) . to eq ( 'blue' )
179+ expect ( response [ 'users' ] [ user_id ] [ 'teams ' ] ) . to eq ( [ 'blue' ] )
180180 expect ( response [ 'users' ] [ user_id ] [ 'teams_role' ] [ 'blue' ] ) . to eq ( 'admin' )
181181 end
182182
@@ -960,4 +960,64 @@ def loop_times(times)
960960 end
961961 end
962962 end
963+
964+ describe '#query_threads' do
965+ before ( :all ) do
966+ # Create a dedicated random user for this block
967+ @thread_test_user = { id : SecureRandom . uuid }
968+ @client . upsert_users ( [ @thread_test_user ] )
969+
970+ # Create a channel and send a message to create a thread
971+ @thread_channel = @client . channel ( 'messaging' , channel_id : SecureRandom . uuid , data : { test : true } )
972+ @thread_channel . create ( @thread_test_user [ :id ] )
973+
974+ # Send a message to create a thread
975+ @thread_message = @thread_channel . send_message ( { text : 'Thread parent message' } , @thread_test_user [ :id ] )
976+
977+ # Send a reply to create a thread
978+ @thread_channel . send_message ( { text : 'Thread reply' , parent_id : @thread_message [ 'message' ] [ 'id' ] } , @thread_test_user [ :id ] )
979+ end
980+
981+ after ( :all ) do
982+ @thread_channel . delete
983+ @client . delete_user ( @thread_test_user [ :id ] )
984+ end
985+
986+ it 'queries threads with filter' do
987+ filter = {
988+ 'created_by_user_id' => { '$eq' => @thread_test_user [ :id ] }
989+ }
990+
991+ response = @client . query_threads ( filter , user_id : @thread_test_user [ :id ] )
992+
993+ expect ( response ) . to include 'threads'
994+ expect ( response [ 'threads' ] . length ) . to be >= 1
995+ end
996+
997+ it 'queries threads with sort' do
998+ sort = {
999+ 'created_at' => -1
1000+ }
1001+
1002+ response = @client . query_threads ( { } , sort : sort , user_id : @thread_test_user [ :id ] )
1003+
1004+ expect ( response ) . to include 'threads'
1005+ expect ( response [ 'threads' ] . length ) . to be >= 1
1006+ end
1007+
1008+ it 'queries threads with both filter and sort' do
1009+ filter = {
1010+ 'created_by_user_id' => { '$eq' => @thread_test_user [ :id ] }
1011+ }
1012+
1013+ sort = {
1014+ 'created_at' => -1
1015+ }
1016+
1017+ response = @client . query_threads ( filter , sort : sort , user_id : @thread_test_user [ :id ] )
1018+
1019+ expect ( response ) . to include 'threads'
1020+ expect ( response [ 'threads' ] . length ) . to be >= 1
1021+ end
1022+ end
9631023end
0 commit comments