voelin-gpui: a search with no match says "Nobody matches."; connecting is loading
The members panel said "Connect to see who is here." for every empty list
that was not loading, so a search that matched nobody on a connected server
told the user to connect. Emptiness has NoMatch now ("Nobody matches."), for
a non-empty search over a server that has people and leaves none of them; it
is the panel's own (TreeModel::people_emptiness): the tree is not searched,
so the shared Emptiness::of never says it and the tree pane is not told when
the search comes to match nobody (a test counts its renders across the
change). A server whose voice is connecting is Loading, as one that is
observed is, in both panes: its channels and people are on the way.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f28c02a18c
commit
c044f7279a
5 files changed
+147
-11
No files matched your search
@@ -1461,6 +1461,75 @@ mod tests {
|
||||
assert_eq!(shell.app.read_with(cx, |app, _| app.vm.member_filter.clone()), "");
|
||||
}
|
||||
|
||||
/// A search that matches nobody on a server that has people says so, where
|
||||
/// "Connect to see who is here." would be false; the tree is not told (it
|
||||
/// is not searched), and closing the search shows everyone again.
|
||||
#[gpui::test]
|
||||
fn a_search_with_no_match_says_nobody_matches(cx: &mut TestAppContext) {
|
||||
let (shell, cx) = open(cx, Backend::in_memory().unwrap(), Switches::default());
|
||||
sample_server(&shell, cx);
|
||||
let emptiness = |shell: &Shell, cx: &mut VisualTestContext| {
|
||||
shell.view.read_with(cx, |view, cx| {
|
||||
(
|
||||
view.members_pane().read(cx).emptiness(),
|
||||
view.channel_tree().read(cx).emptiness(),
|
||||
view.tree_model().read(cx).people_emptiness(),
|
||||
)
|
||||
})
|
||||
};
|
||||
assert_eq!(emptiness(&shell, cx).0, Emptiness::Connect, "full: only said when empty");
|
||||
assert!(at(cx, "members-empty").is_none());
|
||||
|
||||
click(cx, "members-search");
|
||||
// The first key typed draws the tree once whatever it is (the field's
|
||||
// focus: not the search's doing); what follows must not.
|
||||
cx.simulate_input("z");
|
||||
frame(cx);
|
||||
assert_eq!(members_shape(&shell, cx), ["Streaming — 1: Zeph", "Guest — 1: Blaze"]);
|
||||
let tree_drawn = shell.counters.panes.tree.get();
|
||||
cx.simulate_input("zz");
|
||||
frame(cx);
|
||||
assert!(members_shape(&shell, cx).is_empty(), "nobody is called zzz");
|
||||
let (panel, tree, model) = emptiness(&shell, cx);
|
||||
assert_eq!((panel, model), (Emptiness::NoMatch, Emptiness::NoMatch));
|
||||
assert_eq!(tree, Emptiness::Connect, "the tree is not searched and says nothing new");
|
||||
assert!(at(cx, "members-empty").is_some(), "the panel says so");
|
||||
assert_eq!(shell.counters.panes.tree.get(), tree_drawn, "and the tree was not drawn");
|
||||
|
||||
// Closing the search shows everyone again, with no word for emptiness.
|
||||
click(cx, "members-search");
|
||||
assert_eq!(members_shape(&shell, cx).len(), 9);
|
||||
assert!(at(cx, "members-empty").is_none());
|
||||
assert_eq!(emptiness(&shell, cx).0, Emptiness::Connect);
|
||||
}
|
||||
|
||||
/// A server whose voice is connecting has its people and channels on the
|
||||
/// way: both panes say they are loading, not that one has to connect.
|
||||
#[gpui::test]
|
||||
fn a_server_being_connected_says_it_is_loading(cx: &mut TestAppContext) {
|
||||
let (shell, cx) = open(cx, Backend::in_memory().unwrap(), Switches::default());
|
||||
sample_server(&shell, cx);
|
||||
let third = sample::DEMO + 2;
|
||||
shell.app.update(cx, |app, cx| app.select_server(third, cx));
|
||||
frame(cx);
|
||||
let words = |shell: &Shell, cx: &mut VisualTestContext| {
|
||||
shell.view.read_with(cx, |view, cx| {
|
||||
(view.members_pane().read(cx).emptiness(), view.channel_tree().read(cx).emptiness())
|
||||
})
|
||||
};
|
||||
assert_eq!(words(&shell, cx), (Emptiness::Connect, Emptiness::Connect), "not connected");
|
||||
let voice = |voice| Event::State {
|
||||
session: third as u64,
|
||||
state: SessionState { voice, ..Default::default() },
|
||||
};
|
||||
shell.events.send(voice(VoiceState::Connecting)).unwrap();
|
||||
frame(cx);
|
||||
assert_eq!(words(&shell, cx), (Emptiness::Loading, Emptiness::Loading), "connecting");
|
||||
shell.events.send(voice(VoiceState::Disconnected)).unwrap();
|
||||
frame(cx);
|
||||
assert_eq!(words(&shell, cx), (Emptiness::Connect, Emptiness::Connect), "gave up");
|
||||
}
|
||||
|
||||
/// Someone who starts or stops talking redraws the members panel and the
|
||||
/// tree and no other pane: not the rail, the top bar nor the main area. The
|
||||
/// row says so while they talk.
|
||||
|
||||
Reference in new issue
Block a user