Skip to content

Commit

Permalink
fixup! test(room): Add integration tests for publishing and removing …
Browse files Browse the repository at this point in the history
…room aliases
  • Loading branch information
jmartinesp committed Jan 10, 2025
1 parent 2dc1912 commit c372fcb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions testing/matrix-sdk-integration-testing/src/tests/room_privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::time::Duration;

use assert_matches2::assert_matches;
use assign::assign;
use matrix_sdk::{
Expand All @@ -29,10 +31,13 @@ use matrix_sdk::{
RoomHistoryVisibilityEventContent,
},
},
serde::Raw,
RoomAliasId,
},
};
use matrix_sdk_base::ruma::events::room::canonical_alias::SyncRoomCanonicalAliasEvent;
use rand::random;
use tokio::sync::mpsc::unbounded_channel;

use crate::helpers::TestClientBuilder;

Expand Down Expand Up @@ -109,8 +114,14 @@ async fn test_publishing_room_alias() -> anyhow::Result<()> {
.update_canonical_alias(Some(room_alias.clone()), vec![alt_alias.clone()])
.await?;

// Give some time for the sync to run
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
// Wait until we receive the canonical alias event through sync
let (tx, mut rx) = unbounded_channel();
let handle = room.add_event_handler(move |_: Raw<SyncRoomCanonicalAliasEvent>| {
let _ = tx.send(());
async {}
});
let _ = tokio::time::timeout(Duration::from_secs(2), rx.recv()).await?;
client.remove_event_handler(handle);

// And we can check it actually changed the aliases
let canonical_alias = room.canonical_alias();
Expand Down

0 comments on commit c372fcb

Please sign in to comment.