tests.rs

 1use std::sync::Arc;
 2
 3use call::Room;
 4use client::ChannelId;
 5use gpui::{Entity, TestAppContext};
 6
 7mod channel_buffer_tests;
 8mod channel_guest_tests;
 9mod channel_message_tests;
10mod channel_tests;
11// mod debug_panel_tests;
12mod editor_tests;
13mod following_tests;
14mod git_tests;
15mod integration_tests;
16mod notification_tests;
17mod random_channel_buffer_tests;
18mod random_project_collaboration_tests;
19mod randomized_test_helpers;
20mod remote_editing_collaboration_tests;
21mod test_server;
22
23use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_rust};
24pub use randomized_test_helpers::{
25    RandomizedTest, TestError, UserTestPlan, run_randomized_test, save_randomized_test_plan,
26};
27pub use test_server::{TestClient, TestServer};
28
29#[derive(Debug, Eq, PartialEq)]
30struct RoomParticipants {
31    remote: Vec<String>,
32    pending: Vec<String>,
33}
34
35fn room_participants(room: &Entity<Room>, cx: &mut TestAppContext) -> RoomParticipants {
36    room.read_with(cx, |room, _| {
37        let mut remote = room
38            .remote_participants()
39            .values()
40            .map(|participant| participant.user.github_login.clone())
41            .collect::<Vec<_>>();
42        let mut pending = room
43            .pending_participants()
44            .iter()
45            .map(|user| user.github_login.clone())
46            .collect::<Vec<_>>();
47        remote.sort();
48        pending.sort();
49        RoomParticipants { remote, pending }
50    })
51}
52
53fn channel_id(room: &Entity<Room>, cx: &mut TestAppContext) -> Option<ChannelId> {
54    cx.read(|cx| room.read(cx).channel_id())
55}
56
57fn rust_lang() -> Arc<Language> {
58    Arc::new(Language::new(
59        LanguageConfig {
60            name: "Rust".into(),
61            matcher: LanguageMatcher {
62                path_suffixes: vec!["rs".to_string()],
63                ..Default::default()
64            },
65            ..Default::default()
66        },
67        Some(tree_sitter_rust::LANGUAGE.into()),
68    ))
69}