mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
All the following tests
Co-Authored-By: Max <max@zed.dev>
This commit is contained in:
parent
204ef451d0
commit
c7568a7d37
@ -6,6 +6,7 @@ use gpui::{
|
|||||||
point, BackgroundExecutor, Context, SharedString, TestAppContext, View, VisualContext,
|
point, BackgroundExecutor, Context, SharedString, TestAppContext, View, VisualContext,
|
||||||
VisualTestContext, WindowContext,
|
VisualTestContext, WindowContext,
|
||||||
};
|
};
|
||||||
|
use language::Capability;
|
||||||
use live_kit_client::MacOSDisplay;
|
use live_kit_client::MacOSDisplay;
|
||||||
use project::project_settings::ProjectSettings;
|
use project::project_settings::ProjectSettings;
|
||||||
use rpc::proto::PeerId;
|
use rpc::proto::PeerId;
|
||||||
@ -280,7 +281,7 @@ async fn test_basic_following(
|
|||||||
.get_open_buffer(&(worktree_id, "2.txt").into(), cx)
|
.get_open_buffer(&(worktree_id, "2.txt").into(), cx)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
let mut result = MultiBuffer::new(0);
|
let mut result = MultiBuffer::new(0, Capability::ReadWrite);
|
||||||
result.push_excerpts(
|
result.push_excerpts(
|
||||||
buffer_a1,
|
buffer_a1,
|
||||||
[ExcerptRange {
|
[ExcerptRange {
|
||||||
@ -1563,144 +1564,132 @@ async fn test_following_across_workspaces(cx_a: &mut TestAppContext, cx_b: &mut
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[gpui::test]
|
#[gpui::test]
|
||||||
// async fn test_following_into_excluded_file(
|
async fn test_following_into_excluded_file(
|
||||||
// executor: BackgroundExecutor,
|
mut cx_a: &mut TestAppContext,
|
||||||
// mut cx_a: &mut TestAppContext,
|
mut cx_b: &mut TestAppContext,
|
||||||
// mut cx_b: &mut TestAppContext,
|
) {
|
||||||
// ) {
|
let executor = cx_a.executor();
|
||||||
// let mut server = TestServer::start(executor.clone()).await;
|
let mut server = TestServer::start(executor.clone()).await;
|
||||||
// let client_a = server.create_client(cx_a, "user_a").await;
|
let client_a = server.create_client(cx_a, "user_a").await;
|
||||||
// let client_b = server.create_client(cx_b, "user_b").await;
|
let client_b = server.create_client(cx_b, "user_b").await;
|
||||||
// for cx in [&mut cx_a, &mut cx_b] {
|
for cx in [&mut cx_a, &mut cx_b] {
|
||||||
// cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
// cx.update_global::<SettingsStore, _>(|store, cx| {
|
cx.update_global::<SettingsStore, _>(|store, cx| {
|
||||||
// store.update_user_settings::<ProjectSettings>(cx, |project_settings| {
|
store.update_user_settings::<ProjectSettings>(cx, |project_settings| {
|
||||||
// project_settings.file_scan_exclusions = Some(vec!["**/.git".to_string()]);
|
project_settings.file_scan_exclusions = Some(vec!["**/.git".to_string()]);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
// server
|
server
|
||||||
// .create_room(&mut [(&client_a, cx_a), (&client_b, cx_b)])
|
.create_room(&mut [(&client_a, cx_a), (&client_b, cx_b)])
|
||||||
// .await;
|
.await;
|
||||||
// let active_call_a = cx_a.read(ActiveCall::global);
|
let active_call_a = cx_a.read(ActiveCall::global);
|
||||||
// let active_call_b = cx_b.read(ActiveCall::global);
|
let active_call_b = cx_b.read(ActiveCall::global);
|
||||||
|
let peer_id_a = client_a.peer_id().unwrap();
|
||||||
|
|
||||||
// cx_a.update(editor::init);
|
cx_a.update(editor::init);
|
||||||
// cx_b.update(editor::init);
|
cx_b.update(editor::init);
|
||||||
|
|
||||||
// client_a
|
client_a
|
||||||
// .fs()
|
.fs()
|
||||||
// .insert_tree(
|
.insert_tree(
|
||||||
// "/a",
|
"/a",
|
||||||
// json!({
|
json!({
|
||||||
// ".git": {
|
".git": {
|
||||||
// "COMMIT_EDITMSG": "write your commit message here",
|
"COMMIT_EDITMSG": "write your commit message here",
|
||||||
// },
|
},
|
||||||
// "1.txt": "one\none\none",
|
"1.txt": "one\none\none",
|
||||||
// "2.txt": "two\ntwo\ntwo",
|
"2.txt": "two\ntwo\ntwo",
|
||||||
// "3.txt": "three\nthree\nthree",
|
"3.txt": "three\nthree\nthree",
|
||||||
// }),
|
}),
|
||||||
// )
|
)
|
||||||
// .await;
|
.await;
|
||||||
// let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await;
|
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await;
|
||||||
// active_call_a
|
active_call_a
|
||||||
// .update(cx_a, |call, cx| call.set_location(Some(&project_a), cx))
|
.update(cx_a, |call, cx| call.set_location(Some(&project_a), cx))
|
||||||
// .await
|
.await
|
||||||
// .unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// let project_id = active_call_a
|
let project_id = active_call_a
|
||||||
// .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||||
// .await
|
.await
|
||||||
// .unwrap();
|
.unwrap();
|
||||||
// let project_b = client_b.build_remote_project(project_id, cx_b).await;
|
let project_b = client_b.build_remote_project(project_id, cx_b).await;
|
||||||
// active_call_b
|
active_call_b
|
||||||
// .update(cx_b, |call, cx| call.set_location(Some(&project_b), cx))
|
.update(cx_b, |call, cx| call.set_location(Some(&project_b), cx))
|
||||||
// .await
|
.await
|
||||||
// .unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// let window_a = client_a.build_workspace(&project_a, cx_a);
|
let (workspace_a, cx_a) = client_a.build_workspace(&project_a, cx_a);
|
||||||
// let workspace_a = window_a.root(cx_a).unwrap();
|
let (workspace_b, cx_b) = client_b.build_workspace(&project_b, cx_b);
|
||||||
// let peer_id_a = client_a.peer_id().unwrap();
|
|
||||||
// let window_b = client_b.build_workspace(&project_b, cx_b);
|
|
||||||
// let workspace_b = window_b.root(cx_b).unwrap();
|
|
||||||
|
|
||||||
// todo!("could be wrong")
|
// Client A opens editors for a regular file and an excluded file.
|
||||||
// let mut cx_a = VisualTestContext::from_window(*window_a, cx_a);
|
let editor_for_regular = workspace_a
|
||||||
// let cx_a = &mut cx_a;
|
.update(cx_a, |workspace, cx| {
|
||||||
// let mut cx_b = VisualTestContext::from_window(*window_b, cx_b);
|
workspace.open_path((worktree_id, "1.txt"), None, true, cx)
|
||||||
// let cx_b = &mut cx_b;
|
})
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.downcast::<Editor>()
|
||||||
|
.unwrap();
|
||||||
|
let editor_for_excluded_a = workspace_a
|
||||||
|
.update(cx_a, |workspace, cx| {
|
||||||
|
workspace.open_path((worktree_id, ".git/COMMIT_EDITMSG"), None, true, cx)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.downcast::<Editor>()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// // Client A opens editors for a regular file and an excluded file.
|
// Client A updates their selections in those editors
|
||||||
// let editor_for_regular = workspace_a
|
editor_for_regular.update(cx_a, |editor, cx| {
|
||||||
// .update(cx_a, |workspace, cx| {
|
editor.handle_input("a", cx);
|
||||||
// workspace.open_path((worktree_id, "1.txt"), None, true, cx)
|
editor.handle_input("b", cx);
|
||||||
// })
|
editor.handle_input("c", cx);
|
||||||
// .await
|
editor.select_left(&Default::default(), cx);
|
||||||
// .unwrap()
|
assert_eq!(editor.selections.ranges(cx), vec![3..2]);
|
||||||
// .downcast::<Editor>()
|
});
|
||||||
// .unwrap();
|
editor_for_excluded_a.update(cx_a, |editor, cx| {
|
||||||
// let editor_for_excluded_a = workspace_a
|
editor.select_all(&Default::default(), cx);
|
||||||
// .update(cx_a, |workspace, cx| {
|
editor.handle_input("new commit message", cx);
|
||||||
// workspace.open_path((worktree_id, ".git/COMMIT_EDITMSG"), None, true, cx)
|
editor.select_left(&Default::default(), cx);
|
||||||
// })
|
assert_eq!(editor.selections.ranges(cx), vec![18..17]);
|
||||||
// .await
|
});
|
||||||
// .unwrap()
|
|
||||||
// .downcast::<Editor>()
|
|
||||||
// .unwrap();
|
|
||||||
|
|
||||||
// // Client A updates their selections in those editors
|
// When client B starts following client A, currently visible file is replicated
|
||||||
// editor_for_regular.update(cx_a, |editor, cx| {
|
workspace_b.update(cx_b, |workspace, cx| workspace.follow(peer_id_a, cx));
|
||||||
// editor.handle_input("a", cx);
|
executor.run_until_parked();
|
||||||
// editor.handle_input("b", cx);
|
|
||||||
// editor.handle_input("c", cx);
|
|
||||||
// editor.select_left(&Default::default(), cx);
|
|
||||||
// assert_eq!(editor.selections.ranges(cx), vec![3..2]);
|
|
||||||
// });
|
|
||||||
// editor_for_excluded_a.update(cx_a, |editor, cx| {
|
|
||||||
// editor.select_all(&Default::default(), cx);
|
|
||||||
// editor.handle_input("new commit message", cx);
|
|
||||||
// editor.select_left(&Default::default(), cx);
|
|
||||||
// assert_eq!(editor.selections.ranges(cx), vec![18..17]);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // When client B starts following client A, currently visible file is replicated
|
let editor_for_excluded_b = workspace_b.update(cx_b, |workspace, cx| {
|
||||||
// workspace_b
|
workspace
|
||||||
// .update(cx_b, |workspace, cx| {
|
.active_item(cx)
|
||||||
// workspace.follow(peer_id_a, cx).unwrap()
|
.unwrap()
|
||||||
// })
|
.downcast::<Editor>()
|
||||||
// .await
|
.unwrap()
|
||||||
// .unwrap();
|
});
|
||||||
|
assert_eq!(
|
||||||
|
cx_b.read(|cx| editor_for_excluded_b.project_path(cx)),
|
||||||
|
Some((worktree_id, ".git/COMMIT_EDITMSG").into())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
editor_for_excluded_b.update(cx_b, |editor, cx| editor.selections.ranges(cx)),
|
||||||
|
vec![18..17]
|
||||||
|
);
|
||||||
|
|
||||||
// let editor_for_excluded_b = workspace_b.update(cx_b, |workspace, cx| {
|
// Changes from B to the excluded file are replicated in A's editor
|
||||||
// workspace
|
editor_for_excluded_b.update(cx_b, |editor, cx| {
|
||||||
// .active_item(cx)
|
editor.handle_input("\nCo-Authored-By: B <b@b.b>", cx);
|
||||||
// .unwrap()
|
});
|
||||||
// .downcast::<Editor>()
|
executor.run_until_parked();
|
||||||
// .unwrap()
|
editor_for_excluded_a.update(cx_a, |editor, cx| {
|
||||||
// });
|
assert_eq!(
|
||||||
// assert_eq!(
|
editor.text(cx),
|
||||||
// cx_b.read(|cx| editor_for_excluded_b.project_path(cx)),
|
"new commit messag\nCo-Authored-By: B <b@b.b>"
|
||||||
// Some((worktree_id, ".git/COMMIT_EDITMSG").into())
|
);
|
||||||
// );
|
});
|
||||||
// assert_eq!(
|
}
|
||||||
// editor_for_excluded_b.update(cx_b, |editor, cx| editor.selections.ranges(cx)),
|
|
||||||
// vec![18..17]
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // Changes from B to the excluded file are replicated in A's editor
|
|
||||||
// editor_for_excluded_b.update(cx_b, |editor, cx| {
|
|
||||||
// editor.handle_input("\nCo-Authored-By: B <b@b.b>", cx);
|
|
||||||
// });
|
|
||||||
// executor.run_until_parked();
|
|
||||||
// editor_for_excluded_a.update(cx_a, |editor, cx| {
|
|
||||||
// assert_eq!(
|
|
||||||
// editor.text(cx),
|
|
||||||
// "new commit messag\nCo-Authored-By: B <b@b.b>"
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
fn visible_push_notifications(
|
fn visible_push_notifications(
|
||||||
cx: &mut TestAppContext,
|
cx: &mut TestAppContext,
|
||||||
|
Loading…
Reference in New Issue
Block a user