From 7a32bcc1f482535bb4e2edbfa4b3db0aef1a9634 Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 18 Apr 2024 01:27:15 +0000 Subject: [PATCH] test: fix flaky chatlist_events test test_update_after_ephemeral_messages Previously test did not trigger deletion of ephemeral messages and worked because clear_events() did not remove just emitted events from `send_text_msg`. --- src/events/chatlist_events.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/events/chatlist_events.rs b/src/events/chatlist_events.rs index 8d4e0bfa7..4b612f3ee 100644 --- a/src/events/chatlist_events.rs +++ b/src/events/chatlist_events.rs @@ -511,18 +511,25 @@ mod test_chatlist_events { Ok(()) } - /// ephemeral / disappearing messages + /// Tests that expired disappearing message + /// produces events about chatlist being modified. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_update_after_ephemeral_messages() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; let chat = create_group_chat(&alice, ProtectionStatus::Protected, "My Group").await?; - chat.set_ephemeral_timer(&alice, crate::ephemeral::Timer::Enabled { duration: 1 }) + chat.set_ephemeral_timer(&alice, crate::ephemeral::Timer::Enabled { duration: 60 }) .await?; - let _ = chat::send_text_msg(&alice, chat, "Hello".to_owned()).await?; + alice + .evtracker + .get_matching(|evt| matches!(evt, EventType::ChatEphemeralTimerModified { .. })) + .await; - alice.evtracker.clear_events(); - SystemTime::shift(Duration::from_secs(3)); + let _ = chat::send_text_msg(&alice, chat, "Hello".to_owned()).await?; + wait_for_chatlist_and_specific_item(&alice, chat).await; + + SystemTime::shift(Duration::from_secs(70)); + crate::ephemeral::delete_expired_messages(&alice, crate::tools::time()).await?; wait_for_chatlist_and_specific_item(&alice, chat).await; Ok(())