@@ -1389,20 +1389,52 @@ async fn test_pinned_after_new_msgs() -> Result<()> {
1389
1389
1390
1390
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1391
1391
async fn test_set_chat_name ( ) {
1392
- let t = TestContext :: new ( ) . await ;
1393
- let chat_id = create_group_chat ( & t, ProtectionStatus :: Unprotected , "foo" )
1392
+ let mut tcm = TestContextManager :: new ( ) ;
1393
+ let alice = & tcm. alice ( ) . await ;
1394
+
1395
+ let chat_id = create_group_chat ( alice, ProtectionStatus :: Unprotected , "foo" )
1394
1396
. await
1395
1397
. unwrap ( ) ;
1396
1398
assert_eq ! (
1397
- Chat :: load_from_db( & t , chat_id) . await . unwrap( ) . get_name( ) ,
1399
+ Chat :: load_from_db( alice , chat_id) . await . unwrap( ) . get_name( ) ,
1398
1400
"foo"
1399
1401
) ;
1400
1402
1401
- set_chat_name ( & t , chat_id, "bar" ) . await . unwrap ( ) ;
1403
+ set_chat_name ( alice , chat_id, "bar" ) . await . unwrap ( ) ;
1402
1404
assert_eq ! (
1403
- Chat :: load_from_db( & t , chat_id) . await . unwrap( ) . get_name( ) ,
1405
+ Chat :: load_from_db( alice , chat_id) . await . unwrap( ) . get_name( ) ,
1404
1406
"bar"
1405
1407
) ;
1408
+
1409
+ let bob = & tcm. bob ( ) . await ;
1410
+ let bob_contact_id = alice. add_or_lookup_contact_id ( bob) . await ;
1411
+ add_contact_to_chat ( alice, chat_id, bob_contact_id)
1412
+ . await
1413
+ . unwrap ( ) ;
1414
+
1415
+ let sent_msg = alice. send_text ( chat_id, "Hi" ) . await ;
1416
+ let received_msg = bob. recv_msg ( & sent_msg) . await ;
1417
+ let bob_chat_id = received_msg. chat_id ;
1418
+
1419
+ for new_name in [
1420
+ "Baz" ,
1421
+ "xyzzy" ,
1422
+ "Quux" ,
1423
+ "another name" ,
1424
+ "something different" ,
1425
+ ] {
1426
+ set_chat_name ( alice, chat_id, new_name) . await . unwrap ( ) ;
1427
+ let sent_msg = alice. pop_sent_msg ( ) . await ;
1428
+ let received_msg = bob. recv_msg ( & sent_msg) . await ;
1429
+ assert_eq ! ( received_msg. chat_id, bob_chat_id) ;
1430
+ assert_eq ! (
1431
+ Chat :: load_from_db( bob, bob_chat_id)
1432
+ . await
1433
+ . unwrap( )
1434
+ . get_name( ) ,
1435
+ new_name
1436
+ ) ;
1437
+ }
1406
1438
}
1407
1439
1408
1440
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
0 commit comments