@@ -198,6 +198,20 @@ def loop_times(times)
198198 expect ( response [ 'user' ] [ 'id' ] ) . to eq ( @random_user [ :id ] )
199199 end
200200
201+ it 'deactivates multiple users' do
202+ response = @client . deactivate_users ( [ @random_users [ 0 ] [ :id ] , @random_users [ 1 ] [ :id ] ] )
203+ expect ( response ) . to include 'task_id'
204+ expect ( response [ 'task_id' ] ) . not_to be_empty
205+ end
206+
207+ it 'raises an error if user_ids is not an array' do
208+ expect { @client . deactivate_users ( 'not an array' ) } . to raise_error ( TypeError )
209+ end
210+
211+ it 'raises an error if user_ids is empty' do
212+ expect { @client . deactivate_users ( [ ] ) } . to raise_error ( ArgumentError )
213+ end
214+
201215 it 'reactivates a user' do
202216 @client . deactivate_user ( @random_user [ :id ] )
203217 response = @client . reactivate_user ( @random_user [ :id ] )
@@ -811,6 +825,51 @@ def loop_times(times)
811825 list_resp = @client . list_imports ( { limit : 1 } )
812826 expect ( list_resp [ 'import_tasks' ] . length ) . to eq 1
813827 end
828+
829+ it 'can query drafts' do
830+ # Create multiple drafts in different channels
831+ draft1 = { 'text' => 'Draft in channel 1' }
832+ @channel . create_draft ( draft1 , @random_user [ :id ] )
833+
834+ # Create another channel with a draft
835+ channel2 = @client . channel ( 'messaging' , data : { 'members' => @random_users . map { |u | u [ :id ] } } )
836+ channel2 . create ( @random_user [ :id ] )
837+
838+ draft2 = { 'text' => 'Draft in channel 2' }
839+ channel2 . create_draft ( draft2 , @random_user [ :id ] )
840+
841+ # Sort by created_at
842+ sort = [ { 'field' => 'created_at' , 'direction' => 1 } ]
843+ response = @client . query_drafts ( @random_user [ :id ] , sort : sort )
844+ expect ( response [ 'drafts' ] ) . not_to be_empty
845+ expect ( response [ 'drafts' ] . length ) . to eq ( 2 )
846+ expect ( response [ 'drafts' ] [ 0 ] [ 'channel' ] [ 'id' ] ) . to eq ( @channel . id )
847+ expect ( response [ 'drafts' ] [ 1 ] [ 'channel' ] [ 'id' ] ) . to eq ( channel2 . id )
848+
849+ # Query for a specific channel
850+ response = @client . query_drafts ( @random_user [ :id ] , filter : { 'channel_cid' => @channel . cid } )
851+ expect ( response [ 'drafts' ] ) . not_to be_empty
852+ expect ( response [ 'drafts' ] . length ) . to eq ( 1 )
853+ expect ( response [ 'drafts' ] [ 0 ] [ 'channel' ] [ 'id' ] ) . to eq ( @channel . id )
854+
855+ # Query all drafts for the user
856+ response = @client . query_drafts ( @random_user [ :id ] )
857+ expect ( response [ 'drafts' ] ) . not_to be_empty
858+ expect ( response [ 'drafts' ] . length ) . to eq ( 2 )
859+
860+ # Paginate
861+ response = @client . query_drafts ( @random_user [ :id ] , sort : sort , limit : 1 )
862+ expect ( response [ 'drafts' ] ) . not_to be_empty
863+ expect ( response [ 'drafts' ] . length ) . to eq ( 1 )
864+ expect ( response [ 'drafts' ] [ 0 ] [ 'channel' ] [ 'id' ] ) . to eq ( @channel . id )
865+
866+ # Cleanup
867+ begin
868+ channel2 . delete
869+ rescue StandardError
870+ # Ignore errors if channel is already deleted
871+ end
872+ end
814873 end
815874
816875 describe 'permissions' do
0 commit comments