1use crate::{
2 db::{tests::TestDb, NewUserParams, UserId},
3 executor::Executor,
4 rpc::{Server, CLEANUP_TIMEOUT, RECONNECT_TIMEOUT},
5 AppState, Config,
6};
7use anyhow::anyhow;
8use call::ActiveCall;
9use channel::{ChannelBuffer, ChannelStore};
10use client::{
11 self, proto::PeerId, Client, Connection, Credentials, EstablishConnectionError, UserStore,
12};
13use collab_ui::channel_view::ChannelView;
14use collections::{HashMap, HashSet};
15use fs::FakeFs;
16use futures::{channel::oneshot, StreamExt as _};
17use gpui::{BackgroundExecutor, Context, Model, Task, TestAppContext, View, VisualTestContext};
18use language::LanguageRegistry;
19use node_runtime::FakeNodeRuntime;
20
21use notifications::NotificationStore;
22use parking_lot::Mutex;
23use project::{Project, WorktreeId};
24use rpc::{
25 proto::{self, ChannelRole},
26 RECEIVE_TIMEOUT,
27};
28use serde_json::json;
29use settings::SettingsStore;
30use std::{
31 cell::{Ref, RefCell, RefMut},
32 env,
33 ops::{Deref, DerefMut},
34 path::Path,
35 sync::{
36 atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst},
37 Arc,
38 },
39};
40use util::http::FakeHttpClient;
41use workspace::{Workspace, WorkspaceStore};
42
43pub struct TestServer {
44 pub app_state: Arc<AppState>,
45 pub test_live_kit_server: Arc<live_kit_client::TestServer>,
46 server: Arc<Server>,
47 next_github_user_id: i32,
48 connection_killers: Arc<Mutex<HashMap<PeerId, Arc<AtomicBool>>>>,
49 forbid_connections: Arc<AtomicBool>,
50 _test_db: TestDb,
51}
52
53pub struct TestClient {
54 pub username: String,
55 pub app_state: Arc<workspace::AppState>,
56 channel_store: Model<ChannelStore>,
57 notification_store: Model<NotificationStore>,
58 state: RefCell<TestClientState>,
59}
60
61#[derive(Default)]
62struct TestClientState {
63 local_projects: Vec<Model<Project>>,
64 remote_projects: Vec<Model<Project>>,
65 buffers: HashMap<Model<Project>, HashSet<Model<language::Buffer>>>,
66 channel_buffers: HashSet<Model<ChannelBuffer>>,
67}
68
69pub struct ContactsSummary {
70 pub current: Vec<String>,
71 pub outgoing_requests: Vec<String>,
72 pub incoming_requests: Vec<String>,
73}
74
75impl TestServer {
76 pub async fn start(deterministic: BackgroundExecutor) -> Self {
77 static NEXT_LIVE_KIT_SERVER_ID: AtomicUsize = AtomicUsize::new(0);
78
79 let use_postgres = env::var("USE_POSTGRES").ok();
80 let use_postgres = use_postgres.as_deref();
81 let test_db = if use_postgres == Some("true") || use_postgres == Some("1") {
82 TestDb::postgres(deterministic.clone())
83 } else {
84 TestDb::sqlite(deterministic.clone())
85 };
86 let live_kit_server_id = NEXT_LIVE_KIT_SERVER_ID.fetch_add(1, SeqCst);
87 let live_kit_server = live_kit_client::TestServer::create(
88 format!("http://livekit.{}.test", live_kit_server_id),
89 format!("devkey-{}", live_kit_server_id),
90 format!("secret-{}", live_kit_server_id),
91 deterministic.clone(),
92 )
93 .unwrap();
94 let app_state = Self::build_app_state(&test_db, &live_kit_server).await;
95 let epoch = app_state
96 .db
97 .create_server(&app_state.config.zed_environment)
98 .await
99 .unwrap();
100 let server = Server::new(
101 epoch,
102 app_state.clone(),
103 Executor::Deterministic(deterministic.clone()),
104 );
105 server.start().await.unwrap();
106 // Advance clock to ensure the server's cleanup task is finished.
107 deterministic.advance_clock(CLEANUP_TIMEOUT);
108 Self {
109 app_state,
110 server,
111 connection_killers: Default::default(),
112 forbid_connections: Default::default(),
113 next_github_user_id: 0,
114 _test_db: test_db,
115 test_live_kit_server: live_kit_server,
116 }
117 }
118
119 pub async fn start2(
120 cx_a: &mut TestAppContext,
121 cx_b: &mut TestAppContext,
122 ) -> (TestServer, TestClient, TestClient, u64) {
123 let mut server = Self::start(cx_a.executor()).await;
124 let client_a = server.create_client(cx_a, "user_a").await;
125 let client_b = server.create_client(cx_b, "user_b").await;
126 let channel_id = server
127 .make_channel(
128 "test-channel",
129 None,
130 (&client_a, cx_a),
131 &mut [(&client_b, cx_b)],
132 )
133 .await;
134 cx_a.run_until_parked();
135
136 (server, client_a, client_b, channel_id)
137 }
138
139 pub async fn start1<'a>(cx: &'a mut TestAppContext) -> TestClient {
140 let mut server = Self::start(cx.executor().clone()).await;
141 server.create_client(cx, "user_a").await
142 }
143
144 pub async fn reset(&self) {
145 self.app_state.db.reset();
146 let epoch = self
147 .app_state
148 .db
149 .create_server(&self.app_state.config.zed_environment)
150 .await
151 .unwrap();
152 self.server.reset(epoch);
153 }
154
155 pub async fn create_client(&mut self, cx: &mut TestAppContext, name: &str) -> TestClient {
156 cx.update(|cx| {
157 if cx.has_global::<SettingsStore>() {
158 panic!("Same cx used to create two test clients")
159 }
160 let settings = SettingsStore::test(cx);
161 cx.set_global(settings);
162 release_channel::init("0.0.0", cx);
163 client::init_settings(cx);
164 });
165
166 let http = FakeHttpClient::with_404_response();
167 let user_id = if let Ok(Some(user)) = self.app_state.db.get_user_by_github_login(name).await
168 {
169 user.id
170 } else {
171 let github_user_id = self.next_github_user_id;
172 self.next_github_user_id += 1;
173 self.app_state
174 .db
175 .create_user(
176 &format!("{name}@example.com"),
177 false,
178 NewUserParams {
179 github_login: name.into(),
180 github_user_id,
181 },
182 )
183 .await
184 .expect("creating user failed")
185 .user_id
186 };
187 let client_name = name.to_string();
188 let mut client = cx.update(|cx| Client::new(http.clone(), cx));
189 let server = self.server.clone();
190 let db = self.app_state.db.clone();
191 let connection_killers = self.connection_killers.clone();
192 let forbid_connections = self.forbid_connections.clone();
193
194 Arc::get_mut(&mut client)
195 .unwrap()
196 .set_id(user_id.to_proto())
197 .override_authenticate(move |cx| {
198 cx.spawn(|_| async move {
199 let access_token = "the-token".to_string();
200 Ok(Credentials {
201 user_id: user_id.to_proto(),
202 access_token,
203 })
204 })
205 })
206 .override_establish_connection(move |credentials, cx| {
207 assert_eq!(credentials.user_id, user_id.0 as u64);
208 assert_eq!(credentials.access_token, "the-token");
209
210 let server = server.clone();
211 let db = db.clone();
212 let connection_killers = connection_killers.clone();
213 let forbid_connections = forbid_connections.clone();
214 let client_name = client_name.clone();
215 cx.spawn(move |cx| async move {
216 if forbid_connections.load(SeqCst) {
217 Err(EstablishConnectionError::other(anyhow!(
218 "server is forbidding connections"
219 )))
220 } else {
221 let (client_conn, server_conn, killed) =
222 Connection::in_memory(cx.background_executor().clone());
223 let (connection_id_tx, connection_id_rx) = oneshot::channel();
224 let user = db
225 .get_user_by_id(user_id)
226 .await
227 .expect("retrieving user failed")
228 .unwrap();
229 cx.background_executor()
230 .spawn(server.handle_connection(
231 server_conn,
232 client_name,
233 user,
234 None,
235 Some(connection_id_tx),
236 Executor::Deterministic(cx.background_executor().clone()),
237 ))
238 .detach();
239 let connection_id = connection_id_rx.await.unwrap();
240 connection_killers
241 .lock()
242 .insert(connection_id.into(), killed);
243 Ok(client_conn)
244 }
245 })
246 });
247
248 let fs = FakeFs::new(cx.executor());
249 let user_store = cx.new_model(|cx| UserStore::new(client.clone(), cx));
250 let workspace_store = cx.new_model(|cx| WorkspaceStore::new(client.clone(), cx));
251 let mut language_registry = LanguageRegistry::test();
252 language_registry.set_executor(cx.executor());
253 let app_state = Arc::new(workspace::AppState {
254 client: client.clone(),
255 user_store: user_store.clone(),
256 workspace_store,
257 languages: Arc::new(language_registry),
258 fs: fs.clone(),
259 build_window_options: |_, _, _| Default::default(),
260 node_runtime: FakeNodeRuntime::new(),
261 });
262
263 cx.update(|cx| {
264 theme::init(theme::LoadThemes::JustBase, cx);
265 Project::init(&client, cx);
266 client::init(&client, cx);
267 language::init(cx);
268 editor::init(cx);
269 workspace::init(app_state.clone(), cx);
270 call::init(client.clone(), user_store.clone(), cx);
271 channel::init(&client, user_store.clone(), cx);
272 notifications::init(client.clone(), user_store, cx);
273 collab_ui::init(&app_state, cx);
274 file_finder::init(cx);
275 menu::init();
276 settings::KeymapFile::load_asset("keymaps/default.json", cx).unwrap();
277 });
278
279 client
280 .authenticate_and_connect(false, &cx.to_async())
281 .await
282 .unwrap();
283
284 let client = TestClient {
285 app_state,
286 username: name.to_string(),
287 channel_store: cx.read(ChannelStore::global).clone(),
288 notification_store: cx.read(NotificationStore::global).clone(),
289 state: Default::default(),
290 };
291 client.wait_for_current_user(cx).await;
292 client
293 }
294
295 pub fn disconnect_client(&self, peer_id: PeerId) {
296 self.connection_killers
297 .lock()
298 .remove(&peer_id)
299 .unwrap()
300 .store(true, SeqCst);
301 }
302
303 pub fn simulate_long_connection_interruption(
304 &self,
305 peer_id: PeerId,
306 deterministic: BackgroundExecutor,
307 ) {
308 self.forbid_connections();
309 self.disconnect_client(peer_id);
310 deterministic.advance_clock(RECEIVE_TIMEOUT + RECONNECT_TIMEOUT);
311 self.allow_connections();
312 deterministic.advance_clock(RECEIVE_TIMEOUT + RECONNECT_TIMEOUT);
313 deterministic.run_until_parked();
314 }
315
316 pub fn forbid_connections(&self) {
317 self.forbid_connections.store(true, SeqCst);
318 }
319
320 pub fn allow_connections(&self) {
321 self.forbid_connections.store(false, SeqCst);
322 }
323
324 pub async fn make_contacts(&self, clients: &mut [(&TestClient, &mut TestAppContext)]) {
325 for ix in 1..clients.len() {
326 let (left, right) = clients.split_at_mut(ix);
327 let (client_a, cx_a) = left.last_mut().unwrap();
328 for (client_b, cx_b) in right {
329 client_a
330 .app_state
331 .user_store
332 .update(*cx_a, |store, cx| {
333 store.request_contact(client_b.user_id().unwrap(), cx)
334 })
335 .await
336 .unwrap();
337 cx_a.executor().run_until_parked();
338 client_b
339 .app_state
340 .user_store
341 .update(*cx_b, |store, cx| {
342 store.respond_to_contact_request(client_a.user_id().unwrap(), true, cx)
343 })
344 .await
345 .unwrap();
346 }
347 }
348 }
349
350 pub async fn make_channel(
351 &self,
352 channel: &str,
353 parent: Option<u64>,
354 admin: (&TestClient, &mut TestAppContext),
355 members: &mut [(&TestClient, &mut TestAppContext)],
356 ) -> u64 {
357 let (_, admin_cx) = admin;
358 let channel_id = admin_cx
359 .read(ChannelStore::global)
360 .update(admin_cx, |channel_store, cx| {
361 channel_store.create_channel(channel, parent, cx)
362 })
363 .await
364 .unwrap();
365
366 for (member_client, member_cx) in members {
367 admin_cx
368 .read(ChannelStore::global)
369 .update(admin_cx, |channel_store, cx| {
370 channel_store.invite_member(
371 channel_id,
372 member_client.user_id().unwrap(),
373 ChannelRole::Member,
374 cx,
375 )
376 })
377 .await
378 .unwrap();
379
380 admin_cx.executor().run_until_parked();
381
382 member_cx
383 .read(ChannelStore::global)
384 .update(*member_cx, |channels, cx| {
385 channels.respond_to_channel_invite(channel_id, true, cx)
386 })
387 .await
388 .unwrap();
389 }
390
391 channel_id
392 }
393
394 pub async fn make_public_channel(
395 &self,
396 channel: &str,
397 client: &TestClient,
398 cx: &mut TestAppContext,
399 ) -> u64 {
400 let channel_id = self
401 .make_channel(channel, None, (client, cx), &mut [])
402 .await;
403
404 client
405 .channel_store()
406 .update(cx, |channel_store, cx| {
407 channel_store.set_channel_visibility(
408 channel_id,
409 proto::ChannelVisibility::Public,
410 cx,
411 )
412 })
413 .await
414 .unwrap();
415
416 channel_id
417 }
418
419 pub async fn make_channel_tree(
420 &self,
421 channels: &[(&str, Option<&str>)],
422 creator: (&TestClient, &mut TestAppContext),
423 ) -> Vec<u64> {
424 let mut observed_channels = HashMap::default();
425 let mut result = Vec::new();
426 for (channel, parent) in channels {
427 let id;
428 if let Some(parent) = parent {
429 if let Some(parent_id) = observed_channels.get(parent) {
430 id = self
431 .make_channel(channel, Some(*parent_id), (creator.0, creator.1), &mut [])
432 .await;
433 } else {
434 panic!(
435 "Edge {}->{} referenced before {} was created",
436 parent, channel, parent
437 )
438 }
439 } else {
440 id = self
441 .make_channel(channel, None, (creator.0, creator.1), &mut [])
442 .await;
443 }
444
445 observed_channels.insert(channel, id);
446 result.push(id);
447 }
448
449 result
450 }
451
452 pub async fn create_room(&self, clients: &mut [(&TestClient, &mut TestAppContext)]) {
453 self.make_contacts(clients).await;
454
455 let (left, right) = clients.split_at_mut(1);
456 let (_client_a, cx_a) = &mut left[0];
457 let active_call_a = cx_a.read(ActiveCall::global);
458
459 for (client_b, cx_b) in right {
460 let user_id_b = client_b.current_user_id(*cx_b).to_proto();
461 active_call_a
462 .update(*cx_a, |call, cx| call.invite(user_id_b, None, cx))
463 .await
464 .unwrap();
465
466 cx_b.executor().run_until_parked();
467 let active_call_b = cx_b.read(ActiveCall::global);
468 active_call_b
469 .update(*cx_b, |call, cx| call.accept_incoming(cx))
470 .await
471 .unwrap();
472 }
473 }
474
475 pub async fn build_app_state(
476 test_db: &TestDb,
477 fake_server: &live_kit_client::TestServer,
478 ) -> Arc<AppState> {
479 Arc::new(AppState {
480 db: test_db.db().clone(),
481 live_kit_client: Some(Arc::new(fake_server.create_api_client())),
482 config: Config {
483 http_port: 0,
484 database_url: "".into(),
485 database_max_connections: 0,
486 api_token: "".into(),
487 invite_link_prefix: "".into(),
488 live_kit_server: None,
489 live_kit_key: None,
490 live_kit_secret: None,
491 rust_log: None,
492 log_json: None,
493 zed_environment: "test".into(),
494 },
495 })
496 }
497}
498
499impl Deref for TestServer {
500 type Target = Server;
501
502 fn deref(&self) -> &Self::Target {
503 &self.server
504 }
505}
506
507impl Drop for TestServer {
508 fn drop(&mut self) {
509 self.server.teardown();
510 self.test_live_kit_server.teardown().unwrap();
511 }
512}
513
514impl Deref for TestClient {
515 type Target = Arc<Client>;
516
517 fn deref(&self) -> &Self::Target {
518 &self.app_state.client
519 }
520}
521
522impl TestClient {
523 pub fn fs(&self) -> &FakeFs {
524 self.app_state.fs.as_fake()
525 }
526
527 pub fn channel_store(&self) -> &Model<ChannelStore> {
528 &self.channel_store
529 }
530
531 pub fn notification_store(&self) -> &Model<NotificationStore> {
532 &self.notification_store
533 }
534
535 pub fn user_store(&self) -> &Model<UserStore> {
536 &self.app_state.user_store
537 }
538
539 pub fn language_registry(&self) -> &Arc<LanguageRegistry> {
540 &self.app_state.languages
541 }
542
543 pub fn client(&self) -> &Arc<Client> {
544 &self.app_state.client
545 }
546
547 pub fn current_user_id(&self, cx: &TestAppContext) -> UserId {
548 UserId::from_proto(
549 self.app_state
550 .user_store
551 .read_with(cx, |user_store, _| user_store.current_user().unwrap().id),
552 )
553 }
554
555 pub async fn wait_for_current_user(&self, cx: &TestAppContext) {
556 let mut authed_user = self
557 .app_state
558 .user_store
559 .read_with(cx, |user_store, _| user_store.watch_current_user());
560 while authed_user.next().await.unwrap().is_none() {}
561 }
562
563 pub async fn clear_contacts(&self, cx: &mut TestAppContext) {
564 self.app_state
565 .user_store
566 .update(cx, |store, _| store.clear_contacts())
567 .await;
568 }
569
570 pub fn local_projects<'a>(&'a self) -> impl Deref<Target = Vec<Model<Project>>> + 'a {
571 Ref::map(self.state.borrow(), |state| &state.local_projects)
572 }
573
574 pub fn remote_projects<'a>(&'a self) -> impl Deref<Target = Vec<Model<Project>>> + 'a {
575 Ref::map(self.state.borrow(), |state| &state.remote_projects)
576 }
577
578 pub fn local_projects_mut<'a>(&'a self) -> impl DerefMut<Target = Vec<Model<Project>>> + 'a {
579 RefMut::map(self.state.borrow_mut(), |state| &mut state.local_projects)
580 }
581
582 pub fn remote_projects_mut<'a>(&'a self) -> impl DerefMut<Target = Vec<Model<Project>>> + 'a {
583 RefMut::map(self.state.borrow_mut(), |state| &mut state.remote_projects)
584 }
585
586 pub fn buffers_for_project<'a>(
587 &'a self,
588 project: &Model<Project>,
589 ) -> impl DerefMut<Target = HashSet<Model<language::Buffer>>> + 'a {
590 RefMut::map(self.state.borrow_mut(), |state| {
591 state.buffers.entry(project.clone()).or_default()
592 })
593 }
594
595 pub fn buffers<'a>(
596 &'a self,
597 ) -> impl DerefMut<Target = HashMap<Model<Project>, HashSet<Model<language::Buffer>>>> + 'a
598 {
599 RefMut::map(self.state.borrow_mut(), |state| &mut state.buffers)
600 }
601
602 pub fn channel_buffers<'a>(
603 &'a self,
604 ) -> impl DerefMut<Target = HashSet<Model<ChannelBuffer>>> + 'a {
605 RefMut::map(self.state.borrow_mut(), |state| &mut state.channel_buffers)
606 }
607
608 pub fn summarize_contacts(&self, cx: &TestAppContext) -> ContactsSummary {
609 self.app_state
610 .user_store
611 .read_with(cx, |store, _| ContactsSummary {
612 current: store
613 .contacts()
614 .iter()
615 .map(|contact| contact.user.github_login.clone())
616 .collect(),
617 outgoing_requests: store
618 .outgoing_contact_requests()
619 .iter()
620 .map(|user| user.github_login.clone())
621 .collect(),
622 incoming_requests: store
623 .incoming_contact_requests()
624 .iter()
625 .map(|user| user.github_login.clone())
626 .collect(),
627 })
628 }
629
630 pub async fn build_local_project(
631 &self,
632 root_path: impl AsRef<Path>,
633 cx: &mut TestAppContext,
634 ) -> (Model<Project>, WorktreeId) {
635 let project = self.build_empty_local_project(cx);
636 let (worktree, _) = project
637 .update(cx, |p, cx| {
638 p.find_or_create_local_worktree(root_path, true, cx)
639 })
640 .await
641 .unwrap();
642 worktree
643 .read_with(cx, |tree, _| tree.as_local().unwrap().scan_complete())
644 .await;
645 (project, worktree.read_with(cx, |tree, _| tree.id()))
646 }
647
648 pub async fn build_test_project(&self, cx: &mut TestAppContext) -> Model<Project> {
649 self.fs()
650 .insert_tree(
651 "/a",
652 json!({
653 "1.txt": "one\none\none",
654 "2.js": "function two() { return 2; }",
655 "3.rs": "mod test",
656 }),
657 )
658 .await;
659 self.build_local_project("/a", cx).await.0
660 }
661
662 pub async fn host_workspace(
663 &self,
664 workspace: &View<Workspace>,
665 channel_id: u64,
666 cx: &mut VisualTestContext,
667 ) {
668 cx.update(|cx| {
669 let active_call = ActiveCall::global(cx);
670 active_call.update(cx, |call, cx| call.join_channel(channel_id, cx))
671 })
672 .await
673 .unwrap();
674 cx.update(|cx| {
675 let active_call = ActiveCall::global(cx);
676 let project = workspace.read(cx).project().clone();
677 active_call.update(cx, |call, cx| call.share_project(project, cx))
678 })
679 .await
680 .unwrap();
681 cx.executor().run_until_parked();
682 }
683
684 pub async fn join_workspace<'a>(
685 &'a self,
686 channel_id: u64,
687 cx: &'a mut TestAppContext,
688 ) -> (View<Workspace>, &'a mut VisualTestContext) {
689 cx.update(|cx| workspace::join_channel(channel_id, self.app_state.clone(), None, cx))
690 .await
691 .unwrap();
692 cx.run_until_parked();
693
694 self.active_workspace(cx)
695 }
696
697 pub fn build_empty_local_project(&self, cx: &mut TestAppContext) -> Model<Project> {
698 cx.update(|cx| {
699 Project::local(
700 self.client().clone(),
701 self.app_state.node_runtime.clone(),
702 self.app_state.user_store.clone(),
703 self.app_state.languages.clone(),
704 self.app_state.fs.clone(),
705 cx,
706 )
707 })
708 }
709
710 pub async fn build_remote_project(
711 &self,
712 host_project_id: u64,
713 guest_cx: &mut TestAppContext,
714 ) -> Model<Project> {
715 let active_call = guest_cx.read(ActiveCall::global);
716 let room = active_call.read_with(guest_cx, |call, _| call.room().unwrap().clone());
717 room.update(guest_cx, |room, cx| {
718 room.join_project(
719 host_project_id,
720 self.app_state.languages.clone(),
721 self.app_state.fs.clone(),
722 cx,
723 )
724 })
725 .await
726 .unwrap()
727 }
728
729 pub fn build_workspace<'a>(
730 &'a self,
731 project: &Model<Project>,
732 cx: &'a mut TestAppContext,
733 ) -> (View<Workspace>, &'a mut VisualTestContext) {
734 cx.add_window_view(|cx| {
735 cx.activate_window();
736 Workspace::new(0, project.clone(), self.app_state.clone(), cx)
737 })
738 }
739
740 pub async fn build_test_workspace<'a>(
741 &'a self,
742 cx: &'a mut TestAppContext,
743 ) -> (View<Workspace>, &'a mut VisualTestContext) {
744 let project = self.build_test_project(cx).await;
745 cx.add_window_view(|cx| {
746 cx.activate_window();
747 Workspace::new(0, project.clone(), self.app_state.clone(), cx)
748 })
749 }
750
751 pub fn active_workspace<'a>(
752 &'a self,
753 cx: &'a mut TestAppContext,
754 ) -> (View<Workspace>, &'a mut VisualTestContext) {
755 let window = cx.update(|cx| cx.active_window().unwrap().downcast::<Workspace>().unwrap());
756
757 let view = window.root_view(cx).unwrap();
758 let cx = VisualTestContext::from_window(*window.deref(), cx).as_mut();
759 // it might be nice to try and cleanup these at the end of each test.
760 (view, cx)
761 }
762}
763
764pub fn open_channel_notes(
765 channel_id: u64,
766 cx: &mut VisualTestContext,
767) -> Task<anyhow::Result<View<ChannelView>>> {
768 let window = cx.update(|cx| cx.active_window().unwrap().downcast::<Workspace>().unwrap());
769 let view = window.root_view(cx).unwrap();
770
771 cx.update(|cx| ChannelView::open(channel_id, None, view.clone(), cx))
772}
773
774impl Drop for TestClient {
775 fn drop(&mut self) {
776 self.app_state.client.teardown();
777 }
778}