test: test reception of multipart/alternative with text/calendar

In messages with text/plain, text/html and text/calendar parts
within a multipart/alternative, text/calendar part is currently ignored,
text/plain is displayed and HTML is available via HTML API.
This commit is contained in:
link2xt
2025-10-01 05:56:09 +00:00
parent af69756df0
commit a745cf78ee
2 changed files with 56 additions and 0 deletions

View File

@@ -5557,3 +5557,29 @@ async fn test_lookup_key_contact_by_address_self() -> Result<()> {
);
Ok(())
}
/// Tests reception of multipart/alternative
/// with three parts, one of which is a calendar.
///
/// MS Exchange produces multipart/alternative
/// messages with three parts:
/// `text/plain`, `text/html` and `text/calendar`.
///
/// We display `text/plain` part in this case.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_calendar_alternative() -> Result<()> {
let mut tcm = TestContextManager::new();
let t = &tcm.alice().await;
let raw = include_bytes!("../../test-data/message/calendar-alternative.eml");
let msg = receive_imf(t, raw, false).await?.unwrap();
assert_eq!(msg.msg_ids.len(), 1);
let text_msg = Message::load_from_db(t, msg.msg_ids[0]).await?;
assert_eq!(text_msg.text, "Subject was here Hello!");
assert_eq!(text_msg.viewtype, Viewtype::Text);
assert!(text_msg.has_html());
let html = text_msg.get_id().get_html(t).await.unwrap().unwrap();
assert_eq!(html, "<b>Hello!</b>");
Ok(())
}