@@ -2934,6 +2934,9 @@ async fn test_broadcast_channel_protected_listid() -> Result<()> {
2934
2934
Ok ( ( ) )
2935
2935
}
2936
2936
2937
+ /// Test that if Bob leaves a broadcast channel,
2938
+ /// Alice (the channel owner) won't see him as a member anymore,
2939
+ /// but won't be notified about this in any way.
2937
2940
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
2938
2941
async fn test_leave_broadcast ( ) -> Result < ( ) > {
2939
2942
let mut tcm = TestContextManager :: new ( ) ;
@@ -2989,6 +2992,44 @@ async fn test_leave_broadcast() -> Result<()> {
2989
2992
Ok ( ( ) )
2990
2993
}
2991
2994
2995
+ /// Tests that if Bob leaves a broadcast channel with one device,
2996
+ /// the other device shows a correct info message "You left.".
2997
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
2998
+ async fn test_leave_broadcast_multidevice ( ) -> Result < ( ) > {
2999
+ let mut tcm = TestContextManager :: new ( ) ;
3000
+ let alice = & tcm. alice ( ) . await ;
3001
+ let bob0 = & tcm. bob ( ) . await ;
3002
+ let bob1 = & tcm. bob ( ) . await ;
3003
+
3004
+ tcm. section ( "Alice creates broadcast channel with Bob." ) ;
3005
+ let alice_chat_id = create_broadcast ( alice, "foo" . to_string ( ) ) . await ?;
3006
+ let bob_contact = alice. add_or_lookup_contact ( bob0) . await . id ;
3007
+ add_contact_to_chat ( alice, alice_chat_id, bob_contact) . await ?;
3008
+
3009
+ tcm. section ( "Alice sends first message to broadcast." ) ;
3010
+ let sent_msg = alice. send_text ( alice_chat_id, "Hello!" ) . await ;
3011
+ let bob0_hello = bob0. recv_msg ( & sent_msg) . await ;
3012
+ let bob1_hello = bob1. recv_msg ( & sent_msg) . await ;
3013
+
3014
+ tcm. section ( "Bob leaves the broadcast channel with his first device." ) ;
3015
+ let bob_chat_id = bob0_hello. chat_id ;
3016
+ bob_chat_id. accept ( bob0) . await ?;
3017
+ remove_contact_from_chat ( bob0, bob_chat_id, ContactId :: SELF ) . await ?;
3018
+
3019
+ let leave_msg = bob0. pop_sent_msg ( ) . await ;
3020
+ let rcvd = bob1. recv_msg ( & leave_msg) . await ;
3021
+
3022
+ assert_eq ! ( rcvd. chat_id, bob1_hello. chat_id) ;
3023
+ assert ! ( rcvd. is_info( ) ) ;
3024
+ assert_eq ! ( rcvd. get_info_type( ) , SystemMessage :: MemberRemovedFromGroup ) ;
3025
+ assert_eq ! (
3026
+ rcvd. text,
3027
+ stock_str:: msg_group_left_local( bob1, ContactId :: SELF ) . await
3028
+ ) ;
3029
+
3030
+ Ok ( ( ) )
3031
+ }
3032
+
2992
3033
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
2993
3034
async fn test_create_for_contact_with_blocked ( ) -> Result < ( ) > {
2994
3035
let t = TestContext :: new ( ) . await ;
0 commit comments