diff --git a/crates/matrix-sdk-ui/tests/integration/room_list_service.rs b/crates/matrix-sdk-ui/tests/integration/room_list_service.rs index a6d0da65b..d5285af64 100644 --- a/crates/matrix-sdk-ui/tests/integration/room_list_service.rs +++ b/crates/matrix-sdk-ui/tests/integration/room_list_service.rs @@ -315,7 +315,10 @@ async fn test_sync_all_states() -> Result<(), Error> { "receipts": { "enabled": true, "rooms": ["*"] - } + }, + "typing": { + "enabled": true, + }, }, }, respond with = { diff --git a/crates/matrix-sdk/src/room/mod.rs b/crates/matrix-sdk/src/room/mod.rs index d2692a2c1..070e7acd7 100644 --- a/crates/matrix-sdk/src/room/mod.rs +++ b/crates/matrix-sdk/src/room/mod.rs @@ -1,12 +1,6 @@ //! High-level room API -use std::{ - borrow::Borrow, - collections::BTreeMap, - ops::Deref, - sync::{mpsc::channel, Arc}, - time::Duration, -}; +use std::{borrow::Borrow, collections::BTreeMap, ops::Deref, time::Duration}; use eyeball::SharedObservable; use futures_core::Stream; diff --git a/crates/matrix-sdk/tests/integration/room/joined.rs b/crates/matrix-sdk/tests/integration/room/joined.rs index 38c565f6c..80e5a0e4a 100644 --- a/crates/matrix-sdk/tests/integration/room/joined.rs +++ b/crates/matrix-sdk/tests/integration/room/joined.rs @@ -652,7 +652,7 @@ async fn report_content() { #[async_test] async fn subscribe_to_typing_notifications() { let (client, server) = logged_in_client().await; - let mut typing_sequences: Arc>>> = Arc::new(Mutex::new(Vec::new())); + let typing_sequences: Arc>>> = Arc::new(Mutex::new(Vec::new())); let asserted_typing_sequences = vec![vec![user_id!("@alice:matrix.org"), user_id!("@bob:example.com")], vec![]]; let room_id = room_id!("!test:example.org"); @@ -673,6 +673,9 @@ async fn subscribe_to_typing_notifications() { while let Ok(typing_users) = subscriber.recv().await { let mut typings = typing_seq.lock().unwrap(); typings.push(typing_users); + if typings.len() == 2 { + break; + } } }); // Then send a typing notification with 2 users typing @@ -692,7 +695,7 @@ async fn subscribe_to_typing_notifications() { let _response = client.sync_once(sync_settings.clone()).await.unwrap(); server.reset().await; - // Then send a typing notification with no users typings + // Then send a typing notification with no user typing ev_builder.add_joined_room(JoinedRoomBuilder::new(room_id).add_ephemeral_event( EphemeralTestEvent::Custom(json!({ "content": { @@ -706,14 +709,6 @@ async fn subscribe_to_typing_notifications() { let _response = client.sync_once(sync_settings.clone()).await.unwrap(); server.reset().await; - // Cancel the task, makes sure the subscription is cancelled too. - handle.abort(); - ev_builder.add_joined_room( - JoinedRoomBuilder::new(room_id).add_ephemeral_event(EphemeralTestEvent::Typing), - ); - mock_sync(&server, ev_builder.build_json_sync_response(), None).await; - let _response = client.sync_once(sync_settings.clone()).await.unwrap(); - server.reset().await; - + handle.await.unwrap(); assert_eq!(typing_sequences.lock().unwrap().to_vec(), asserted_typing_sequences); }