Fix most tests for new chat changes

This commit is contained in:
Mikayla 2023-10-03 20:47:54 -07:00
parent 3bc7024f8b
commit db8096ccdc
No known key found for this signature in database
4 changed files with 36 additions and 12 deletions

View file

@ -350,7 +350,7 @@ async fn test_channel_buffers_last_operations(db: &Database) {
.await
.unwrap();
assert_eq!(
pretty_assertions::assert_eq!(
buffer_changes,
[
rpc::proto::UnseenChannelBufferChange {
@ -361,7 +361,11 @@ async fn test_channel_buffers_last_operations(db: &Database) {
rpc::proto::UnseenChannelBufferChange {
channel_id: buffers[1].channel_id.to_proto(),
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 {
channel_id: buffers[2].channel_id.to_proto(),

View file

@ -1,7 +1,9 @@
use crate::{rpc::RECONNECT_TIMEOUT, tests::TestServer};
use channel::{ChannelChat, ChannelMessageId};
use collab_ui::chat_panel::ChatPanel;
use gpui::{executor::Deterministic, BorrowAppContext, ModelHandle, TestAppContext};
use std::sync::Arc;
use workspace::dock::Panel;
#[gpui::test]
async fn test_basic_channel_messages(
@ -244,6 +246,15 @@ async fn test_channel_message_changes(
)
.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.
let channel_chat_a = client_a
.channel_store()
@ -269,12 +280,22 @@ async fn test_channel_message_changes(
assert!(b_has_messages);
// Opening the chat should clear the changed flag.
let channel_chat_b = client_b
.channel_store()
.update(cx_b, |store, cx| store.open_channel_chat(channel_id, cx))
cx_b.update(|cx| {
collab_ui::init(&client_b.app_state, 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
.unwrap();
deterministic.run_until_parked();
let b_has_messages = cx_b.read_with(|cx| {
client_b
.channel_store()
@ -304,10 +325,7 @@ async fn test_channel_message_changes(
assert!(!b_has_messages);
// Closing the chat should re-enable change tracking
cx_b.update(|_| {
drop(channel_chat_b);
});
todo!();
deterministic.run_until_parked();

View file

@ -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(
workspace: WeakViewHandle<Workspace>,
cx: AsyncAppContext,

View file

@ -1964,9 +1964,7 @@ impl CollabPanel {
.left(),
)
.with_child({
let style = collab_theme
.channel_name
.in_state(channel.unseen_note_version.is_some());
let style = collab_theme.channel_name.inactive_state();
Flex::row()
.with_child(
Label::new(channel.name.clone(), style.text.clone())