@@ -1503,6 +1503,39 @@ async fn test_shall_attach_selfavatar() -> Result<()> {
1503
1503
Ok ( ( ) )
1504
1504
}
1505
1505
1506
+ /// Tests that profile data is attached to group leave messages. There are some pros and cons of
1507
+ /// doing this, but at least we don't want to complicate the code with this special case.
1508
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1509
+ async fn test_profile_data_on_group_leave ( ) -> Result < ( ) > {
1510
+ let mut tcm = TestContextManager :: new ( ) ;
1511
+ let t = & tcm. alice ( ) . await ;
1512
+ let chat_id = create_group_chat ( t, ProtectionStatus :: Unprotected , "foo" ) . await ?;
1513
+
1514
+ let ( contact_id, _) = Contact :: add_or_lookup (
1515
+ t,
1516
+ "" ,
1517
+ & ContactAddress :: new ( "foo@bar.org" ) ?,
1518
+ Origin :: IncomingUnknownTo ,
1519
+ )
1520
+ . await ?;
1521
+ add_contact_to_chat ( t, chat_id, contact_id) . await ?;
1522
+
1523
+ send_text_msg ( t, chat_id, "populate" . to_string ( ) ) . await ?;
1524
+ t. pop_sent_msg ( ) . await ;
1525
+
1526
+ let file = t. dir . path ( ) . join ( "avatar.png" ) ;
1527
+ let bytes = include_bytes ! ( "../../test-data/image/avatar64x64.png" ) ;
1528
+ tokio:: fs:: write ( & file, bytes) . await ?;
1529
+ t. set_config ( Config :: Selfavatar , Some ( file. to_str ( ) . unwrap ( ) ) )
1530
+ . await ?;
1531
+ assert ! ( shall_attach_selfavatar( t, chat_id) . await ?) ;
1532
+
1533
+ remove_contact_from_chat ( t, chat_id, ContactId :: SELF ) . await ?;
1534
+ let sent_msg = t. pop_sent_msg ( ) . await ;
1535
+ assert ! ( sent_msg. payload( ) . contains( "Chat-User-Avatar" ) ) ;
1536
+ Ok ( ( ) )
1537
+ }
1538
+
1506
1539
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1507
1540
async fn test_set_mute_duration ( ) {
1508
1541
let t = TestContext :: new ( ) . await ;
0 commit comments