@@ -2892,6 +2892,9 @@ async fn test_block_broadcast() -> Result<()> {
2892
2892
Ok ( ( ) )
2893
2893
}
2894
2894
2895
+ /// Test that if Bob leaves a broadcast channel,
2896
+ /// Alice (the channel owner) won't see him as a member anymore,
2897
+ /// but won't be notified about this in any way.
2895
2898
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
2896
2899
async fn test_leave_broadcast ( ) -> Result < ( ) > {
2897
2900
let mut tcm = TestContextManager :: new ( ) ;
@@ -2947,6 +2950,44 @@ async fn test_leave_broadcast() -> Result<()> {
2947
2950
Ok ( ( ) )
2948
2951
}
2949
2952
2953
+ /// Tests that if Bob leaves a broadcast channel with one device,
2954
+ /// the other device shows a correct info message "You left.".
2955
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
2956
+ async fn test_leave_broadcast_multidevice ( ) -> Result < ( ) > {
2957
+ let mut tcm = TestContextManager :: new ( ) ;
2958
+ let alice = & tcm. alice ( ) . await ;
2959
+ let bob0 = & tcm. bob ( ) . await ;
2960
+ let bob1 = & tcm. bob ( ) . await ;
2961
+
2962
+ tcm. section ( "Alice creates broadcast channel with Bob." ) ;
2963
+ let alice_chat_id = create_broadcast ( alice, "foo" . to_string ( ) ) . await ?;
2964
+ let bob_contact = alice. add_or_lookup_contact ( bob0) . await . id ;
2965
+ add_contact_to_chat ( alice, alice_chat_id, bob_contact) . await ?;
2966
+
2967
+ tcm. section ( "Alice sends first message to broadcast." ) ;
2968
+ let sent_msg = alice. send_text ( alice_chat_id, "Hello!" ) . await ;
2969
+ let bob0_hello = bob0. recv_msg ( & sent_msg) . await ;
2970
+ let bob1_hello = bob1. recv_msg ( & sent_msg) . await ;
2971
+
2972
+ tcm. section ( "Bob leaves the broadcast channel with his first device." ) ;
2973
+ let bob_chat_id = bob0_hello. chat_id ;
2974
+ bob_chat_id. accept ( bob0) . await ?;
2975
+ remove_contact_from_chat ( bob0, bob_chat_id, ContactId :: SELF ) . await ?;
2976
+
2977
+ let leave_msg = bob0. pop_sent_msg ( ) . await ;
2978
+ let rcvd = bob1. recv_msg ( & leave_msg) . await ;
2979
+
2980
+ assert_eq ! ( rcvd. chat_id, bob1_hello. chat_id) ;
2981
+ assert ! ( rcvd. is_info( ) ) ;
2982
+ assert_eq ! ( rcvd. get_info_type( ) , SystemMessage :: MemberRemovedFromGroup ) ;
2983
+ assert_eq ! (
2984
+ rcvd. text,
2985
+ stock_str:: msg_group_left_local( bob1, ContactId :: SELF ) . await
2986
+ ) ;
2987
+
2988
+ Ok ( ( ) )
2989
+ }
2990
+
2950
2991
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
2951
2992
async fn test_create_for_contact_with_blocked ( ) -> Result < ( ) > {
2952
2993
let t = TestContext :: new ( ) . await ;
0 commit comments