diff --git a/src/test_utils.rs b/src/test_utils.rs index 33ebda85c..96869ca19 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -700,11 +700,20 @@ impl TestContext { } /// Returns the [`Contact`] for the other [`TestContext`], creating it if necessary. - pub async fn add_or_lookup_contact(&self, other: &TestContext) -> Contact { + pub async fn add_or_lookup_email_contact(&self, other: &TestContext) -> Contact { let contact_id = self.add_or_lookup_contact_id(other).await; Contact::get_by_id(&self.ctx, contact_id).await.unwrap() } + /// Returns the [`Contact`] for the other [`TestContext`], creating it if necessary. + pub async fn add_or_lookup_contact(&self, other: &TestContext) -> Contact { + let vcard = make_vcard(other, &[ContactId::SELF]).await.unwrap(); + let contact_ids = import_vcard(self, &vcard).await.unwrap(); + assert_eq!(contact_ids.len(), 1); + let contact_id = contact_ids.first().unwrap(); + Contact::get_by_id(&self.ctx, *contact_id).await.unwrap() + } + /// Returns 1:1 [`Chat`] with another account. Panics if it doesn't exist. /// May return a blocked chat. /// @@ -744,7 +753,7 @@ impl TestContext { /// /// This function can be used to create unencrypted chats. pub async fn create_email_chat(&self, other: &TestContext) -> Chat { - let contact = self.add_or_lookup_contact(other).await; + let contact = self.add_or_lookup_email_contact(other).await; let chat_id = ChatId::create_for_contact(self, contact.id).await.unwrap(); Chat::load_from_db(self, chat_id).await.unwrap()