Files
zed/crates/collab/tests/integration/collab_panel_tests.rs
Mohamad Khani b72a46db68
Some checks failed
Update All Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Triage Project Sync (#84) / Sync triage project (push) Has been cancelled
release_nightly / notify_on_failure (push) Has been cancelled
release_nightly / check_style (push) Has been cancelled
release_nightly / run_tests_windows (push) Has been cancelled
release_nightly / clippy_windows (push) Has been cancelled
release_nightly / bundle_linux_aarch64 (push) Has been cancelled
release_nightly / bundle_linux_x86_64 (push) Has been cancelled
release_nightly / bundle_mac_aarch64 (push) Has been cancelled
release_nightly / bundle_mac_x86_64 (push) Has been cancelled
release_nightly / bundle_windows_aarch64 (push) Has been cancelled
release_nightly / bundle_windows_x86_64 (push) Has been cancelled
release_nightly / build_nix_linux_x86_64 (push) Has been cancelled
release_nightly / build_nix_mac_aarch64 (push) Has been cancelled
release_nightly / update_nightly_tag (push) Has been cancelled
Hotfix Review Monitor / check-hotfix-reviews (push) Has been cancelled
Stale PR Review Reminder / check-stale-prs (push) Has been cancelled
Update Weekly Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Bump collab-staging Tag / update-collab-staging-tag (push) Has been cancelled
compliance_check / scheduled_compliance_check (push) Has been cancelled
logiguard fork: GPUI xdg-activation keyboard-focus serial fix
Single-commit orphan branch: full zed-industries/zed @ 8c74db0 source tree
with a 3-file patch applied (no upstream history).

Patch (crates/gpui_linux/src/linux/wayland/):
  - serial.rs: add SerialKind::KeyboardEnter
  - client.rs: store wl_keyboard.enter serial; add latest_serial_of()
  - window.rs: activate() uses keyboard-enter serial (Mutter focus gate)

Mutter honors window activation only when the token carries the keyboard-
focus serial from wl_keyboard.enter; GPUI used a stale mouse-press serial.
See docs/tray-window-focus-wayland.md in logiguard.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 02:22:17 +03:30

357 lines
11 KiB
Rust

use crate::TestServer;
use collab_ui::CollabPanel;
use collab_ui::collab_panel::{MoveChannelDown, MoveChannelUp, ToggleSelectedChannelFavorite};
use gpui::TestAppContext;
use menu::{SelectNext, SelectPrevious};
#[gpui::test]
async fn test_reorder_favorite_channels_independently_of_channels(cx: &mut TestAppContext) {
let (server, client) = TestServer::start1(cx).await;
let root = server
.make_channel("root", None, (&client, cx), &mut [])
.await;
let _ = server
.make_channel("channel-a", Some(root), (&client, cx), &mut [])
.await;
let _ = server
.make_channel("channel-b", Some(root), (&client, cx), &mut [])
.await;
let _ = server
.make_channel("channel-c", Some(root), (&client, cx), &mut [])
.await;
let (workspace, cx) = client.build_test_workspace(cx).await;
let panel = workspace.update_in(cx, |workspace, window, cx| {
let panel = CollabPanel::new(workspace, window, cx);
workspace.add_panel(panel.clone(), window, cx);
panel
});
cx.run_until_parked();
// Verify initial state.
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Select channel-b.
panel.update_in(cx, |panel, window, cx| {
panel.select_next(&SelectNext, window, cx);
panel.select_next(&SelectNext, window, cx);
panel.select_next(&SelectNext, window, cx);
panel.select_next(&SelectNext, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b <== selected",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Favorite channel-b.
panel.update_in(cx, |panel, window, cx| {
panel.toggle_selected_channel_favorite(&ToggleSelectedChannelFavorite, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-b",
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b <== selected",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Select channel-c.
panel.update_in(cx, |panel, window, cx| {
panel.select_next(&SelectNext, window, cx);
});
// Favorite channel-c.
panel.update_in(cx, |panel, window, cx| {
panel.toggle_selected_channel_favorite(&ToggleSelectedChannelFavorite, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b",
" #️⃣ channel-c <== selected",
"[Contacts]",
]
);
// Navigate up to favorite channel-b .
panel.update_in(cx, |panel, window, cx| {
panel.select_previous(&SelectPrevious, window, cx);
panel.select_previous(&SelectPrevious, window, cx);
panel.select_previous(&SelectPrevious, window, cx);
panel.select_previous(&SelectPrevious, window, cx);
panel.select_previous(&SelectPrevious, window, cx);
panel.select_previous(&SelectPrevious, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-b <== selected",
" #️⃣ channel-c",
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Move favorite channel-b down.
// The Channels section should remain unchanged
panel.update_in(cx, |panel, window, cx| {
panel.move_channel_down(&MoveChannelDown, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-c",
" #️⃣ channel-b <== selected",
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Move favorite channel-b down again when it's already last (should be no-op).
panel.update_in(cx, |panel, window, cx| {
panel.move_channel_down(&MoveChannelDown, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-c",
" #️⃣ channel-b <== selected",
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Move favorite channel-b back up.
// The Channels section should remain unchanged.
panel.update_in(cx, |panel, window, cx| {
panel.move_channel_up(&MoveChannelUp, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-b <== selected",
" #️⃣ channel-c",
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Move favorite channel-b up again when it's already first (should be no-op).
panel.update_in(cx, |panel, window, cx| {
panel.move_channel_up(&MoveChannelUp, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-b <== selected",
" #️⃣ channel-c",
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Unfavorite channel-b.
// Selection should move to the next favorite (channel-c).
panel.update_in(cx, |panel, window, cx| {
panel.toggle_selected_channel_favorite(&ToggleSelectedChannelFavorite, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-c <== selected",
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Unfavorite channel-c.
// Favorites section should disappear entirely.
// Selection should move to the next available item.
panel.update_in(cx, |panel, window, cx| {
panel.toggle_selected_channel_favorite(&ToggleSelectedChannelFavorite, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Channels]",
" v root <== selected",
" #️⃣ channel-a",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Contacts]",
]
);
}
#[gpui::test]
async fn test_reorder_channels_independently_of_favorites(cx: &mut TestAppContext) {
let (server, client) = TestServer::start1(cx).await;
let root = server
.make_channel("root", None, (&client, cx), &mut [])
.await;
let _ = server
.make_channel("channel-a", Some(root), (&client, cx), &mut [])
.await;
let _ = server
.make_channel("channel-b", Some(root), (&client, cx), &mut [])
.await;
let _ = server
.make_channel("channel-c", Some(root), (&client, cx), &mut [])
.await;
let (workspace, cx) = client.build_test_workspace(cx).await;
let panel = workspace.update_in(cx, |workspace, window, cx| {
let panel = CollabPanel::new(workspace, window, cx);
workspace.add_panel(panel.clone(), window, cx);
panel
});
cx.run_until_parked();
// Select channel-a.
panel.update_in(cx, |panel, window, cx| {
panel.select_next(&SelectNext, window, cx);
panel.select_next(&SelectNext, window, cx);
panel.select_next(&SelectNext, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Channels]",
" v root",
" #️⃣ channel-a <== selected",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Favorite channel-a.
panel.update_in(cx, |panel, window, cx| {
panel.toggle_selected_channel_favorite(&ToggleSelectedChannelFavorite, window, cx);
});
// Select channel-b.
// Favorite channel-b.
panel.update_in(cx, |panel, window, cx| {
panel.select_next(&SelectNext, window, cx);
panel.toggle_selected_channel_favorite(&ToggleSelectedChannelFavorite, window, cx);
});
cx.run_until_parked();
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-a",
" #️⃣ channel-b",
"[Channels]",
" v root",
" #️⃣ channel-a",
" #️⃣ channel-b <== selected",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Select channel-a in the Channels section.
panel.update_in(cx, |panel, window, cx| {
panel.select_previous(&SelectPrevious, window, cx);
});
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-a",
" #️⃣ channel-b",
"[Channels]",
" v root",
" #️⃣ channel-a <== selected",
" #️⃣ channel-b",
" #️⃣ channel-c",
"[Contacts]",
]
);
// Move channel-a down.
// The Favorites section should remain unchanged.
// Selection should remain on channel-a in the Channels section,
// not jump to channel-a in Favorites.
panel.update_in(cx, |panel, window, cx| {
panel.move_channel_down(&MoveChannelDown, window, cx);
});
cx.run_until_parked();
assert_eq!(
panel.read_with(cx, |panel, _| panel.entries_as_strings()),
&[
"[Favorites]",
" #️⃣ channel-a",
" #️⃣ channel-b",
"[Channels]",
" v root",
" #️⃣ channel-b",
" #️⃣ channel-a <== selected",
" #️⃣ channel-c",
"[Contacts]",
]
);
}