mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Fix most tests for new chat changes
This commit is contained in:
parent
3bc7024f8b
commit
db8096ccdc
4 changed files with 36 additions and 12 deletions
|
@ -350,7 +350,7 @@ async fn test_channel_buffers_last_operations(db: &Database) {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
pretty_assertions::assert_eq!(
|
||||||
buffer_changes,
|
buffer_changes,
|
||||||
[
|
[
|
||||||
rpc::proto::UnseenChannelBufferChange {
|
rpc::proto::UnseenChannelBufferChange {
|
||||||
|
@ -361,7 +361,11 @@ async fn test_channel_buffers_last_operations(db: &Database) {
|
||||||
rpc::proto::UnseenChannelBufferChange {
|
rpc::proto::UnseenChannelBufferChange {
|
||||||
channel_id: buffers[1].channel_id.to_proto(),
|
channel_id: buffers[1].channel_id.to_proto(),
|
||||||
epoch: 1,
|
epoch: 1,
|
||||||
version: serialize_version(&text_buffers[1].version()),
|
version: serialize_version(&text_buffers[1].version())
|
||||||
|
.into_iter()
|
||||||
|
.filter(|vector| vector.replica_id
|
||||||
|
== buffer_changes[1].version.first().unwrap().replica_id)
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
},
|
},
|
||||||
rpc::proto::UnseenChannelBufferChange {
|
rpc::proto::UnseenChannelBufferChange {
|
||||||
channel_id: buffers[2].channel_id.to_proto(),
|
channel_id: buffers[2].channel_id.to_proto(),
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::{rpc::RECONNECT_TIMEOUT, tests::TestServer};
|
use crate::{rpc::RECONNECT_TIMEOUT, tests::TestServer};
|
||||||
use channel::{ChannelChat, ChannelMessageId};
|
use channel::{ChannelChat, ChannelMessageId};
|
||||||
|
use collab_ui::chat_panel::ChatPanel;
|
||||||
use gpui::{executor::Deterministic, BorrowAppContext, ModelHandle, TestAppContext};
|
use gpui::{executor::Deterministic, BorrowAppContext, ModelHandle, TestAppContext};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use workspace::dock::Panel;
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_basic_channel_messages(
|
async fn test_basic_channel_messages(
|
||||||
|
@ -244,6 +246,15 @@ async fn test_channel_message_changes(
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
let other_channel_id = server
|
||||||
|
.make_channel(
|
||||||
|
"other-channel",
|
||||||
|
None,
|
||||||
|
(&client_a, cx_a),
|
||||||
|
&mut [(&client_b, cx_b)],
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
// Client A sends a message, client B should see that there is a new message.
|
// Client A sends a message, client B should see that there is a new message.
|
||||||
let channel_chat_a = client_a
|
let channel_chat_a = client_a
|
||||||
.channel_store()
|
.channel_store()
|
||||||
|
@ -269,12 +280,22 @@ async fn test_channel_message_changes(
|
||||||
assert!(b_has_messages);
|
assert!(b_has_messages);
|
||||||
|
|
||||||
// Opening the chat should clear the changed flag.
|
// Opening the chat should clear the changed flag.
|
||||||
let channel_chat_b = client_b
|
cx_b.update(|cx| {
|
||||||
.channel_store()
|
collab_ui::init(&client_b.app_state, cx);
|
||||||
.update(cx_b, |store, cx| store.open_channel_chat(channel_id, cx))
|
});
|
||||||
|
let project_b = client_b.build_empty_local_project(cx_b);
|
||||||
|
let workspace_b = client_b.build_workspace(&project_b, cx_b).root(cx_b);
|
||||||
|
let chat_panel_b = workspace_b.update(cx_b, |workspace, cx| ChatPanel::new(workspace, cx));
|
||||||
|
chat_panel_b
|
||||||
|
.update(cx_b, |chat_panel, cx| {
|
||||||
|
chat_panel.set_active(true, cx);
|
||||||
|
chat_panel.select_channel(channel_id, cx)
|
||||||
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
deterministic.run_until_parked();
|
||||||
|
|
||||||
let b_has_messages = cx_b.read_with(|cx| {
|
let b_has_messages = cx_b.read_with(|cx| {
|
||||||
client_b
|
client_b
|
||||||
.channel_store()
|
.channel_store()
|
||||||
|
@ -304,10 +325,7 @@ async fn test_channel_message_changes(
|
||||||
assert!(!b_has_messages);
|
assert!(!b_has_messages);
|
||||||
|
|
||||||
// Closing the chat should re-enable change tracking
|
// Closing the chat should re-enable change tracking
|
||||||
|
todo!();
|
||||||
cx_b.update(|_| {
|
|
||||||
drop(channel_chat_b);
|
|
||||||
});
|
|
||||||
|
|
||||||
deterministic.run_until_parked();
|
deterministic.run_until_parked();
|
||||||
|
|
||||||
|
|
|
@ -181,6 +181,10 @@ impl ChatPanel {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn active_chat(&self) -> Option<ModelHandle<ChannelChat>> {
|
||||||
|
self.active_chat.as_ref().map(|(chat, _)| chat.clone())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn load(
|
pub fn load(
|
||||||
workspace: WeakViewHandle<Workspace>,
|
workspace: WeakViewHandle<Workspace>,
|
||||||
cx: AsyncAppContext,
|
cx: AsyncAppContext,
|
||||||
|
|
|
@ -1964,9 +1964,7 @@ impl CollabPanel {
|
||||||
.left(),
|
.left(),
|
||||||
)
|
)
|
||||||
.with_child({
|
.with_child({
|
||||||
let style = collab_theme
|
let style = collab_theme.channel_name.inactive_state();
|
||||||
.channel_name
|
|
||||||
.in_state(channel.unseen_note_version.is_some());
|
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(
|
.with_child(
|
||||||
Label::new(channel.name.clone(), style.text.clone())
|
Label::new(channel.name.clone(), style.text.clone())
|
||||||
|
|
Loading…
Reference in a new issue