@@ -962,70 +962,45 @@ def loop_times(times)
962962 end
963963
964964 describe '#query_threads' do
965- it 'queries threads with filter' do
965+ before ( :each ) do
966966 # Create a channel and send a message to create a thread
967- channel = @client . channel ( 'messaging' , channel_id : SecureRandom . uuid , data : { test : true } )
968- channel . create ( @random_user [ :id ] )
967+ @thread_channel = @client . channel ( 'messaging' , channel_id : SecureRandom . uuid , data : { test : true } )
968+ @thread_channel . create ( @random_user [ :id ] )
969969
970970 # Send a message to create a thread
971- message = channel . send_message ( { text : 'Thread parent message' } , @random_user [ :id ] )
971+ @thread_message = @thread_channel . send_message ( { text : 'Thread parent message' } , @random_user [ :id ] )
972972
973973 # Send a reply to create a thread
974- channel . send_message ( { text : 'Thread reply' , parent_id : message [ 'message' ] [ 'id' ] } , @random_user [ :id ] )
974+ @thread_channel . send_message ( { text : 'Thread reply' , parent_id : @thread_message [ 'message' ] [ 'id' ] } , @random_user [ :id ] )
975+ end
975976
976- # Query threads with filter
977+ after ( :each ) do
978+ @thread_channel . delete
979+ end
980+
981+ it 'queries threads with filter' do
977982 filter = {
978983 'created_by_user_id' => { '$eq' => @random_user [ :id ] }
979984 }
980985
981986 response = @client . query_threads ( filter , user_id : @random_user [ :id ] )
982987
983- # Verify the response
984988 expect ( response ) . to include 'threads'
985989 expect ( response [ 'threads' ] . length ) . to be >= 1
986-
987- # Clean up
988- channel . delete
989990 end
990991
991992 it 'queries threads with sort' do
992- # Create a channel and send a message to create a thread
993- channel = @client . channel ( 'messaging' , channel_id : SecureRandom . uuid , data : { test : true } )
994- channel . create ( @random_user [ :id ] )
995-
996- # Send a message to create a thread
997- message = channel . send_message ( { text : 'Thread parent message' } , @random_user [ :id ] )
998-
999- # Send a reply to create a thread
1000- channel . send_message ( { text : 'Thread reply' , parent_id : message [ 'message' ] [ 'id' ] } , @random_user [ :id ] )
1001-
1002- # Query threads with sort
1003993 sort = {
1004994 'created_at' => -1
1005995 }
1006996
1007997 response = @client . query_threads ( { } , sort : sort , user_id : @random_user [ :id ] )
1008998
1009- # Verify the response
1010999 expect ( response ) . to include 'threads'
10111000 expect ( response [ 'threads' ] . length ) . to be >= 1
1012-
1013- # Clean up
1014- channel . delete
10151001 end
10161002
10171003 it 'queries threads with both filter and sort' do
1018- # Create a channel and send a message to create a thread
1019- channel = @client . channel ( 'messaging' , channel_id : SecureRandom . uuid , data : { test : true } )
1020- channel . create ( @random_user [ :id ] )
1021-
1022- # Send a message to create a thread
1023- message = channel . send_message ( { text : 'Thread parent message' } , @random_user [ :id ] )
1024-
1025- # Send a reply to create a thread
1026- channel . send_message ( { text : 'Thread reply' , parent_id : message [ 'message' ] [ 'id' ] } , @random_user [ :id ] )
1027-
1028- # Query threads with both filter and sort
10291004 filter = {
10301005 'created_by_user_id' => { '$eq' => @random_user [ :id ] }
10311006 }
@@ -1036,12 +1011,8 @@ def loop_times(times)
10361011
10371012 response = @client . query_threads ( filter , sort : sort , user_id : @random_user [ :id ] )
10381013
1039- # Verify the response
10401014 expect ( response ) . to include 'threads'
10411015 expect ( response [ 'threads' ] . length ) . to be >= 1
1042-
1043- # Clean up
1044- channel . delete
10451016 end
10461017 end
10471018end
0 commit comments