Skip to content

Commit b13cc92

Browse files
slavabobikSlava Bobik
andauthored
test: added tests using the restricted visibility feature (#144)
Co-authored-by: Slava Bobik <[email protected]>
1 parent eaaee3e commit b13cc92

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

spec/channel_spec.rb

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,83 @@ def loop_times(times)
351351
expect(response['channel_member']['color']).to eq 'red'
352352
expect(response['channel_member']).not_to have_key('hat')
353353
end
354+
355+
it 'can send message with restricted visibility' do
356+
# Send a message that's only visible to specific users
357+
msg = @channel.send_message(
358+
{
359+
'text' => 'secret message',
360+
'restricted_visibility' => [@random_users[0][:id], @random_users[1][:id]]
361+
},
362+
@random_user[:id]
363+
)
364+
365+
# Verify the message was sent successfully
366+
expect(msg).to include 'message'
367+
expect(msg['message']['text']).to eq 'secret message'
368+
369+
# Verify the restricted visibility
370+
expect(msg['message']['restricted_visibility']).to match_array([@random_users[0][:id], @random_users[1][:id]])
371+
end
372+
373+
it 'can update message with restricted visibility' do
374+
# First send a regular message
375+
msg = @channel.send_message(
376+
{
377+
'text' => 'original message'
378+
},
379+
@random_user[:id]
380+
)
381+
382+
# Update the message with restricted visibility
383+
updated_msg = @client.update_message(
384+
{
385+
'id' => msg['message']['id'],
386+
'text' => 'updated secret message',
387+
'restricted_visibility' => [@random_users[0][:id], @random_users[1][:id]],
388+
'user' => { 'id' => @random_user[:id] }
389+
}
390+
)
391+
392+
# Verify the message was updated successfully
393+
expect(updated_msg).to include 'message'
394+
expect(updated_msg['message']['text']).to eq 'updated secret message'
395+
396+
# Verify the restricted visibility
397+
expect(updated_msg['message']['restricted_visibility']).to match_array([@random_users[0][:id], @random_users[1][:id]])
398+
end
399+
400+
it 'can update message partially with restricted visibility' do
401+
# First send a regular message
402+
msg = @channel.send_message(
403+
{
404+
'text' => 'original message',
405+
'custom_field' => 'original value'
406+
},
407+
@random_user[:id]
408+
)
409+
410+
# Partially update the message with restricted visibility
411+
updated_msg = @client.update_message_partial(
412+
msg['message']['id'],
413+
{
414+
set: {
415+
text: 'partially updated secret message',
416+
restricted_visibility: [@random_users[0][:id], @random_users[1][:id]]
417+
},
418+
unset: ['custom_field']
419+
},
420+
user_id: @random_user[:id]
421+
)
422+
423+
# Verify the message was updated successfully
424+
expect(updated_msg).to include 'message'
425+
expect(updated_msg['message']['text']).to eq 'partially updated secret message'
426+
427+
# Verify the restricted visibility was set
428+
expect(updated_msg['message']['restricted_visibility']).to match_array([@random_users[0][:id], @random_users[1][:id]])
429+
430+
# Verify the custom field was unset
431+
expect(updated_msg['message']).not_to include 'custom_field'
432+
end
354433
end

0 commit comments

Comments
 (0)