add failing test for mailinglists with footer in an extra mimepart

This commit is contained in:
B. Petersen
2021-02-28 00:30:26 +01:00
committed by bjoern
parent 5535475cc9
commit 40d7f3ff71
2 changed files with 106 additions and 1 deletions

View File

@@ -2024,7 +2024,7 @@ fn dc_create_incoming_rfc724_mid(
mod tests {
use super::*;
use crate::chat::{ChatItem, ChatVisibility};
use crate::chat::{get_chat_msgs, ChatItem, ChatVisibility};
use crate::chatlist::Chatlist;
use crate::constants::{DC_CHAT_ID_DEADDROP, DC_CONTACT_ID_INFO, DC_GCL_NO_SPECIALS};
use crate::message::ContactRequestDecision::*;
@@ -3112,6 +3112,42 @@ mod tests {
assert_eq!(chat.name, "DPD");
}
#[async_std::test]
async fn test_mailing_list_with_mimepart_footer() {
let t = TestContext::new_alice().await;
t.set_config(Config::ShowEmails, Some("2")).await.unwrap();
let deaddrop = ChatId::new(DC_CHAT_ID_DEADDROP);
assert_eq!(get_chat_msgs(&t, deaddrop, 0, None).await.len(), 0);
// the mailing list message contains two top-level texts.
// the second text is a footer that is added by some mailing list software
// if the user-edited text contains html.
// this footer should not become a text-message in delta chat
// (otherwise every second mail might be the same footer)
dc_receive_imf(
&t,
include_bytes!("../test-data/message/mailinglist_with_mimepart_footer.eml"),
"INBOX",
1,
false,
)
.await
.unwrap();
let msg = t.get_last_msg().await;
assert_eq!(
msg.text,
Some("[Intern] important stuff Hi mr ... [text part]".to_string())
);
assert!(msg.has_html());
let chat = Chat::load_from_db(&t, msg.chat_id).await.unwrap();
assert_eq!(get_chat_msgs(&t, deaddrop, 0, None).await.len(), 1);
assert_eq!(get_chat_msgs(&t, msg.chat_id, 0, None).await.len(), 1);
assert_eq!(chat.typ, Chattype::Mailinglist);
assert_eq!(chat.blocked, Blocked::Deaddrop);
assert_eq!(chat.grpid, "intern.lists.abc.de");
assert_eq!(chat.name, "Intern");
}
#[async_std::test]
async fn test_dont_show_tokens_in_contacts_list() {
check_dont_show_in_contacts_list(