diff --git a/crates/collab/src/tests.rs b/crates/collab/src/tests.rs index 811cb910e6bca10fc239f10bdbc49eb8540e069a..6fcb2165c021f2a4d5a1d38e1aca01b071c1f194 100644 --- a/crates/collab/src/tests.rs +++ b/crates/collab/src/tests.rs @@ -40,6 +40,6 @@ fn room_participants(room: &ModelHandle, cx: &mut TestAppContext) -> RoomP }) } -fn channel_id(room: &ModelHandle, cx: &mut TestAppContext) -> u64 { - cx.read(|cx| room.read(cx).channel_id().unwrap()) +fn channel_id(room: &ModelHandle, cx: &mut TestAppContext) -> Option { + cx.read(|cx| room.read(cx).channel_id()) } diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 3bc4f17f85fb643e6fe9e5f126e0b5e0f4826c31..a3546b516d461a378982af2c0db50d0d6dccdd05 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -517,9 +517,43 @@ async fn test_joining_channels_and_calling_multiple_users_simultaneously( let room_a = active_call_a.read_with(cx_a, |call, _| call.room().unwrap().clone()); deterministic.run_until_parked(); - assert_eq!(channel_id(&room_a, cx_a), channel_2); + assert_eq!(channel_id(&room_a, cx_a), Some(channel_2)); - todo!(); + // Leave the room + active_call_a + .update(cx_a, |call, cx| { + let hang_up = call.hang_up(cx); + hang_up + }) + .await + .unwrap(); + + // Initiating invites and then joining a channel should fail gracefully + let b_invite = active_call_a.update(cx_a, |call, cx| { + call.invite(client_b.user_id().unwrap(), None, cx) + }); + let c_invite = active_call_a.update(cx_a, |call, cx| { + call.invite(client_c.user_id().unwrap(), None, cx) + }); + + let join_channel = active_call_a.update(cx_a, |call, cx| call.join_channel(channel_1, cx)); + + b_invite.await.unwrap(); + c_invite.await.unwrap(); + assert!(join_channel.await.is_err()); + + let room_a = active_call_a.read_with(cx_a, |call, _| call.room().unwrap().clone()); + deterministic.run_until_parked(); + + assert_eq!( + room_participants(&room_a, cx_a), + RoomParticipants { + remote: Default::default(), + pending: vec!["user_b".to_string(), "user_c".to_string()] + } + ); + + assert_eq!(channel_id(&room_a, cx_a), None); // Leave the room active_call_a @@ -539,6 +573,7 @@ async fn test_joining_channels_and_calling_multiple_users_simultaneously( let c_invite = active_call_a.update(cx_a, |call, cx| { call.invite(client_c.user_id().unwrap(), None, cx) }); + join_channel.await.unwrap(); b_invite.await.unwrap(); c_invite.await.unwrap(); @@ -554,7 +589,7 @@ async fn test_joining_channels_and_calling_multiple_users_simultaneously( } ); - assert_eq!(channel_id(&room_a, cx_a), channel_1); + assert_eq!(channel_id(&room_a, cx_a), Some(channel_1)); } #[gpui::test(iterations = 10)]