Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Failing test for unmuting microphone
Conrad Irwin8669b08161a8
diff --git a/crates/call/src/room.rs b/crates/call/src/room.rsindex 6f8f8e17179..0a599e85cf4 100644--- a/crates/call/src/room.rs+++ b/crates/call/src/room.rs@@ -173,7 +173,11 @@ impl Room {cx.spawn(|this, mut cx| async move {connect.await?;- if !cx.update(|cx| Self::mute_on_join(cx))? {+ let is_read_only = this+ .update(&mut cx, |room, _| room.read_only())+ .unwrap_or(true);++ if !cx.update(|cx| Self::mute_on_join(cx))? && !is_read_only {this.update(&mut cx, |this, cx| this.share_microphone(cx))?.await?;}diff --git a/crates/collab/src/tests/channel_guest_tests.rs b/crates/collab/src/tests/channel_guest_tests.rsindex 45e9e5a1d75..8d21db678be 100644--- a/crates/collab/src/tests/channel_guest_tests.rs+++ b/crates/collab/src/tests/channel_guest_tests.rs@@ -3,7 +3,6 @@ use call::ActiveCall;use editor::Editor;use gpui::{BackgroundExecutor, TestAppContext, VisualTestContext};use rpc::proto;-use workspace::Workspace;#[gpui::test]async fn test_channel_guests(@@ -44,6 +43,8 @@ async fn test_channel_guests(let active_call_b = cx_b.read(ActiveCall::global);let project_b =active_call_b.read_with(cx_b, |call, _| call.location().unwrap().upgrade().unwrap());+ let room_b = active_call_b.update(cx_b, |call, _| call.room().unwrap().clone());+assert_eq!(project_b.read_with(cx_b, |project, _| project.remote_id()),Some(project_id),@@ -55,7 +56,8 @@ async fn test_channel_guests(project.create_entry((worktree_id, "b.txt"), false, cx)}).await- .is_err())+ .is_err());+ assert!(room_b.read_with(cx_b, |room, _| !room.is_sharing_mic()));}#[gpui::test]@@ -64,7 +66,6 @@ async fn test_channel_guest_promotion(cx_a: &mut TestAppContext, cx_b: &mut Testlet client_a = server.create_client(cx_a, "user_a").await;let client_b = server.create_client(cx_b, "user_b").await;let active_call_a = cx_a.read(ActiveCall::global);- let active_call_b = cx_b.read(ActiveCall::global);let channel_id = server.make_public_channel("the-channel", &client_a, cx_a)@@ -76,7 +77,7 @@ async fn test_channel_guest_promotion(cx_a: &mut TestAppContext, cx_b: &mut Test.unwrap();// Client A shares a project in the channel- let project_id = active_call_a+ active_call_a.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)).await.unwrap();@@ -88,14 +89,29 @@ async fn test_channel_guest_promotion(cx_a: &mut TestAppContext, cx_b: &mut Test.unwrap();cx_a.run_until_parked();- let project_b =- active_call_b.read_with(cx_b, |call, _| call.location().unwrap().upgrade().unwrap());-- // client B opens 1.txt- let (workspace, cx_b) = client_b.active_workspace(cx_b);+ // client B opens 1.txt as a guest+ let (workspace_b, cx_b) = client_b.active_workspace(cx_b);+ let room_b = cx_b+ .read(ActiveCall::global)+ .update(cx_b, |call, _| call.room().unwrap().clone());cx_b.simulate_keystrokes("cmd-p 1 enter");- let editor_b = cx_b.update(|cx| workspace.read(cx).active_item_as::<Editor>(cx).unwrap());+ let (project_b, editor_b) = workspace_b.update(cx_b, |workspace, cx| {+ (+ workspace.project().clone(),+ workspace.active_item_as::<Editor>(cx).unwrap(),+ )+ });+ assert!(project_b.read_with(cx_b, |project, _| project.is_read_only()));+ assert!(editor_b.update(cx_b, |e, cx| e.read_only(cx)));+ assert!(dbg!(+ room_b+ .update(cx_b, |room, cx| room.share_microphone(cx))+ .await+ )+ .is_err());++ // B is promotedactive_call_a.update(cx_a, |call, cx| {call.room().unwrap().update(cx, |room, cx| {@@ -108,9 +124,13 @@ async fn test_channel_guest_promotion(cx_a: &mut TestAppContext, cx_b: &mut Test}).await.unwrap();-cx_a.run_until_parked();+ // project and buffers are now editableassert!(project_b.read_with(cx_b, |project, _| !project.is_read_only()));- assert!(!editor_b.update(cx_b, |e, cx| e.read_only(cx)));+ assert!(editor_b.update(cx_b, |editor, cx| !editor.read_only(cx)));+ room_b+ .update(cx_b, |room, cx| room.share_microphone(cx))+ .await+ .unwrap()}diff --git a/crates/live_kit_client/src/test.rs b/crates/live_kit_client/src/test.rsindex 1106e66f31e..07a12a4ab6f 100644--- a/crates/live_kit_client/src/test.rs+++ b/crates/live_kit_client/src/test.rs@@ -167,6 +167,10 @@ impl TestServer {let identity = claims.sub.unwrap().to_string();let room_name = claims.video.room.unwrap();+ if claims.video.can_publish == Some(false) {+ return Err(anyhow!("user is not allowed to publish"));+ }+let mut server_rooms = self.rooms.lock();let room = server_rooms.get_mut(&*room_name)@@ -205,6 +209,10 @@ impl TestServer {let identity = claims.sub.unwrap().to_string();let room_name = claims.video.room.unwrap();+ if claims.video.can_publish == Some(false) {+ return Err(anyhow!("user is not allowed to publish"));+ }+let mut server_rooms = self.rooms.lock();let room = server_rooms.get_mut(&*room_name)