From 80243615c49580dc0323d454b10aa47d9cd6761a Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Tue, 1 Aug 2023 15:02:49 +0200 Subject: [PATCH] chore(test): make the clear_with_echoes test more deterministic --- .../tests/integration/timeline/queue.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs b/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs index 6b20b2d71..52a2f62c0 100644 --- a/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs +++ b/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs @@ -226,10 +226,17 @@ async fn clear_with_echoes() { let timeline = room.timeline().await; // Send a message without mocking the server response. - timeline.send(RoomMessageEventContent::text_plain("Send failure").into(), None).await; + { + let (_, mut timeline_stream) = timeline.subscribe().await; - // Wait for the first message to fail. - sleep(Duration::from_millis(10)).await; + timeline.send(RoomMessageEventContent::text_plain("Send failure").into(), None).await; + + // Wait for the first message to fail. Don't use time, but listen for the first + // timeline item diff to get back signalling the error. + let _day_divider = timeline_stream.next().await; + let _local_echo = timeline_stream.next().await; + let _local_echo_replaced_with_failure = timeline_stream.next().await; + } // Next message will take "forever" to send. Mock::given(method("PUT"))