diff --git a/crates/contacts_panel/src/contacts_panel.rs b/crates/contacts_panel/src/contacts_panel.rs index 1384774cc0..3197e46431 100644 --- a/crates/contacts_panel/src/contacts_panel.rs +++ b/crates/contacts_panel/src/contacts_panel.rs @@ -1260,6 +1260,13 @@ mod tests { .detach(); }); + let request = server.receive::().await.unwrap(); + server + .respond( + request.receipt(), + proto::RegisterProjectResponse { project_id: 200 }, + ) + .await; let get_users_request = server.receive::().await.unwrap(); server .respond( @@ -1337,6 +1344,19 @@ mod tests { ..Default::default() }); + assert_eq!( + server + .receive::() + .await + .unwrap() + .payload, + proto::UpdateProject { + project_id: 200, + online: false, + worktrees: vec![] + }, + ); + cx.foreground().run_until_parked(); assert_eq!( cx.read(|cx| render_to_strings(&panel, cx)), @@ -1380,36 +1400,6 @@ mod tests { ] ); - // The server responds, assigning the project a remote id. It still appears - // as loading, because the server hasn't yet sent out the updated contact - // state for the current user. - let request = server.receive::().await.unwrap(); - server - .respond( - request.receipt(), - proto::RegisterProjectResponse { project_id: 200 }, - ) - .await; - cx.foreground().run_until_parked(); - assert_eq!( - cx.read(|cx| render_to_strings(&panel, cx)), - &[ - "v Requests", - " incoming user_one", - " outgoing user_two", - "v Online", - " the_current_user", - " dir3", - " 🔒 private_dir (going online...)", - " user_four", - " dir2", - " user_three", - " dir1", - "v Offline", - " user_five", - ] - ); - // The server receives the project's metadata and updates the contact metadata // for the current user. Now the project appears as online. assert_eq!( @@ -1417,14 +1407,22 @@ mod tests { .receive::() .await .unwrap() - .payload - .worktrees, - &[proto::WorktreeMetadata { - id: worktree_id, - root_name: "private_dir".to_string(), - visible: true, - }], + .payload, + proto::UpdateProject { + project_id: 200, + online: true, + worktrees: vec![proto::WorktreeMetadata { + id: worktree_id, + root_name: "private_dir".to_string(), + visible: true, + }] + }, ); + server + .receive::() + .await + .unwrap(); + server.send(proto::UpdateContacts { contacts: vec![proto::Contact { user_id: current_user_id, @@ -1489,7 +1487,19 @@ mod tests { // The server receives the unregister request and updates the contact // metadata for the current user. The project is now offline. - let request = server.receive::().await.unwrap(); + assert_eq!( + server + .receive::() + .await + .unwrap() + .payload, + proto::UpdateProject { + project_id: 200, + online: false, + worktrees: vec![] + }, + ); + server.send(proto::UpdateContacts { contacts: vec![proto::Contact { user_id: current_user_id, @@ -1523,28 +1533,6 @@ mod tests { ] ); - // The server responds to the unregister request. - server.respond(request.receipt(), proto::Ack {}).await; - cx.foreground().run_until_parked(); - assert_eq!( - cx.read(|cx| render_to_strings(&panel, cx)), - &[ - "v Requests", - " incoming user_one", - " outgoing user_two", - "v Online", - " the_current_user", - " dir3", - " 🔒 private_dir", - " user_four", - " dir2", - " user_three", - " dir1", - "v Offline", - " user_five", - ] - ); - panel.update(cx, |panel, cx| { panel .filter_editor