From 538e8887e5197a8e3f4dfb848f94d5124d40e2cb Mon Sep 17 00:00:00 2001 From: Paul8711 <154304377+paul8711-code@users.noreply.github.com> Date: Wed, 24 Jun 2026 17:12:34 +0200 Subject: [PATCH 1/3] test: add integration test for accepting invite to empty room Signed-off-by: Paul8711 <154304377+paul8711-code@users.noreply.github.com> --- .../src/tests/room.rs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/testing/matrix-sdk-integration-testing/src/tests/room.rs b/testing/matrix-sdk-integration-testing/src/tests/room.rs index c506709029c..11417520aba 100644 --- a/testing/matrix-sdk-integration-testing/src/tests/room.rs +++ b/testing/matrix-sdk-integration-testing/src/tests/room.rs @@ -36,6 +36,52 @@ use tracing::{debug, error, warn}; use crate::helpers::{TestClientBuilder, wait_for_room}; +#[tokio::test] +async fn test_empty_room_accept_invite() -> Result<()> { + let bob = TestClientBuilder::new("bob").use_sqlite().build().await?; + + let b = bob.clone(); + spawn(async move { + let bob = b; + loop { + if let Err(e) = bob.sync(Default::default()).await { + error!("bob sync error: {e}"); + } + } + }); + + let alice = TestClientBuilder::new("alice").use_sqlite().build().await?; + + let a = alice.clone(); + spawn(async move { + let alice = a; + loop { + if let Err(e) = alice.sync(Default::default()).await { + error!("alice sync error: {e}"); + } + } + }); + + let room_id = alice + .create_room(assign!(CreateRoomRequest::new(), { + invite: vec![bob.user_id().unwrap().to_owned()], + is_direct: false, + })) + .await? + .room_id() + .to_owned(); + + if let Some(room) = alice.get_room(&room_id) { + room.leave().await?; + } + + if let Some(room) = bob.get_room(&room_id) { + room.join().await?; + } + + Ok(()) +} + #[tokio::test] async fn test_event_with_context() -> Result<()> { let bob = TestClientBuilder::new("bob").use_sqlite().build().await?; From b56fa2201ac6a9d16ce7ced272498af643adb2ba Mon Sep 17 00:00:00 2001 From: Paul8711 <154304377+paul8711-code@users.noreply.github.com> Date: Fri, 26 Jun 2026 09:43:20 +0200 Subject: [PATCH 2/3] fix: ensure bob received alice's invite --- .../src/tests/room.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/testing/matrix-sdk-integration-testing/src/tests/room.rs b/testing/matrix-sdk-integration-testing/src/tests/room.rs index 11417520aba..b973f3db927 100644 --- a/testing/matrix-sdk-integration-testing/src/tests/room.rs +++ b/testing/matrix-sdk-integration-testing/src/tests/room.rs @@ -75,9 +75,18 @@ async fn test_empty_room_accept_invite() -> Result<()> { room.leave().await?; } - if let Some(room) = bob.get_room(&room_id) { - room.join().await?; + let mut bob_accepted = false; + for i in 1..=5 { + if let Some(room) = bob.get_room(&room_id) + && matches!(room.state(), RoomState::Invited) + { + room.join().await?; + bob_accepted = true; + break; + } + sleep(Duration::from_millis(500 * i)).await; } + anyhow::ensure!(bob_accepted, "bob couldn't find the invite after ~8 seconds"); Ok(()) } From 81995bdb835b6e5bd66c34b43d7ba9083ad6dee7 Mon Sep 17 00:00:00 2001 From: Paul8711 <154304377+paul8711-code@users.noreply.github.com> Date: Mon, 29 Jun 2026 15:44:22 +0200 Subject: [PATCH 3/3] refactor: simplify alice leaving logic --- testing/matrix-sdk-integration-testing/src/tests/room.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/testing/matrix-sdk-integration-testing/src/tests/room.rs b/testing/matrix-sdk-integration-testing/src/tests/room.rs index b973f3db927..ea7577811c9 100644 --- a/testing/matrix-sdk-integration-testing/src/tests/room.rs +++ b/testing/matrix-sdk-integration-testing/src/tests/room.rs @@ -71,9 +71,8 @@ async fn test_empty_room_accept_invite() -> Result<()> { .room_id() .to_owned(); - if let Some(room) = alice.get_room(&room_id) { - room.leave().await?; - } + let room = alice.get_room(&room_id).expect("Alice should see the room"); + room.leave().await?; let mut bob_accepted = false; for i in 1..=5 {