From a9aeea0ffc6e1f72013ca96890b9ea66461d8405 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Tue, 23 Feb 2021 16:56:22 +0100 Subject: [PATCH] add failing test trying to unblock mailinglist --- src/dc_receive_imf.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 3d6232d07..963d7e62a 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -2859,6 +2859,43 @@ mod tests { assert_eq!(msgs.len(), 0); } + #[async_std::test] + async fn test_mailing_list_decide_block_then_unblock() { + let deaddrop = ChatId::new(DC_CHAT_ID_DEADDROP); + let t = TestContext::new_alice().await; + t.set_config(Config::ShowEmails, Some("2")).await.unwrap(); + + dc_receive_imf(&t, DC_MAILINGLIST, "INBOX", 1000, false) + .await + .unwrap(); + let blocked = Contact::get_all_blocked(&t).await.unwrap(); + assert_eq!(blocked.len(), 0); + + // Answer "Block" on the contact request, + // this should add one blocked contact and deaddrop should be empty again + let msg = get_chat_msg(&t, deaddrop, 0, 1).await; + message::decide_on_contact_request(&t, msg.get_id(), Block).await; + let blocked = Contact::get_all_blocked(&t).await.unwrap(); + assert_eq!(blocked.len(), 1); + let msgs = chat::get_chat_msgs(&t, deaddrop, 0, None).await; + assert_eq!(msgs.len(), 0); + + // Unblock contact and check if the next message arrives in real chat + Contact::unblock(&t, *blocked.first().unwrap()).await; + let blocked = Contact::get_all_blocked(&t).await.unwrap(); + assert_eq!(blocked.len(), 0); + + dc_receive_imf(&t.ctx, DC_MAILINGLIST2, "INBOX", 1001, false) + .await + .unwrap(); + let msg = t.get_last_msg().await; + assert_ne!(msg.chat_id, deaddrop); + let msgs = chat::get_chat_msgs(&t, msg.chat_id, 0, None).await; + assert_eq!(msgs.len(), 2); + let msgs = chat::get_chat_msgs(&t, deaddrop, 0, None).await; + assert_eq!(msgs.len(), 0); + } + #[async_std::test] async fn test_mailing_list_decide_not_now() { let deaddrop = ChatId::new(DC_CHAT_ID_DEADDROP);