diff --git a/src/chat.rs b/src/chat.rs index 99f7e9543..0f8f14060 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -4680,6 +4680,37 @@ mod tests { Ok(()) } + /// Test that if a message implicitly adds a member, both messages appear. + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_msg_with_implicit_member_add() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = tcm.alice().await; + let bob = tcm.bob().await; + let alice_bob_contact_id = + Contact::create(&alice, "Bob", &bob.get_config(Config::Addr).await?.unwrap()).await?; + let fiona_addr = "fiona@example.net"; + let alice_fiona_contact_id = Contact::create(&alice, "Fiona", fiona_addr).await?; + let bob_fiona_contact_id = Contact::create(&bob, "Fiona", fiona_addr).await?; + let alice_chat_id = + create_group_chat(&alice, ProtectionStatus::Unprotected, "Group chat").await?; + add_contact_to_chat(&alice, alice_chat_id, alice_bob_contact_id).await?; + let sent_msg = alice.send_text(alice_chat_id, "I created a group").await; + let bob_received_msg = bob.recv_msg(&sent_msg).await; + let bob_chat_id = bob_received_msg.get_chat_id(); + bob_chat_id.accept(&bob).await?; + + add_contact_to_chat(&alice, alice_chat_id, alice_fiona_contact_id).await?; + let sent_msg = alice.pop_sent_msg().await; + bob.recv_msg(&sent_msg).await; + remove_contact_from_chat(&bob, bob_chat_id, bob_fiona_contact_id).await?; + + let sent_msg = alice.send_text(alice_chat_id, "Welcome, Fiona!").await; + bob.recv_msg(&sent_msg).await; + bob.golden_test_chat(bob_chat_id, "chat_test_msg_with_implicit_member_add") + .await; + Ok(()) + } + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_modify_chat_multi_device() -> Result<()> { let a1 = TestContext::new_alice().await; diff --git a/test-data/golden/chat_test_msg_with_implicit_member_add b/test-data/golden/chat_test_msg_with_implicit_member_add new file mode 100644 index 000000000..f45dff499 --- /dev/null +++ b/test-data/golden/chat_test_msg_with_implicit_member_add @@ -0,0 +1,8 @@ +Group#Chat#10: Group chat [3 member(s)] +-------------------------------------------------------------------------------- +Msg#10: (Contact#Contact#11): I created a group [FRESH] +Msg#11: (Contact#Contact#11): Member Fiona (fiona@example.net) added by alice@example.org. [FRESH][INFO] +Msg#12: Me (Contact#Contact#Self): You removed member Fiona (fiona@example.net). [INFO] o +Msg#13: (Contact#Contact#11): Member Fiona (fiona@example.net) added. [FRESH] +Msg#14: (Contact#Contact#11): Welcome, Fiona! [FRESH] +--------------------------------------------------------------------------------