Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: potential test timeout

nathan31458e817a2a
diff --git a/frontend/rust-lib/flowy-grid/src/services/cell/cell_operation.rs b/frontend/rust-lib/flowy-grid/src/services/cell/cell_operation.rs
index 42b0ebc669..0811918685 100644
--- a/frontend/rust-lib/flowy-grid/src/services/cell/cell_operation.rs
+++ b/frontend/rust-lib/flowy-grid/src/services/cell/cell_operation.rs
@@ -1,6 +1,7 @@
use crate::entities::FieldType;
use crate::services::cell::{CellBytes, TypeCellData};
use crate::services::field::*;
+use std::cmp::Ordering;
use std::fmt::Debug;
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
@@ -13,7 +14,7 @@ pub trait CellFilterable<T> {
}
pub trait CellComparable {
- fn apply_cmp(&self, type_cell_data: &TypeCellData, other_type_cell_data: &TypeCellData) -> FlowyResult<bool>;
+ fn apply_cmp(&self, type_cell_data: &TypeCellData, other_type_cell_data: &TypeCellData) -> FlowyResult<Ordering>;
}
/// Serialize the cell data in Protobuf/String format.
diff --git a/frontend/rust-lib/flowy-grid/tests/grid/filter_test/script.rs b/frontend/rust-lib/flowy-grid/tests/grid/filter_test/script.rs
index 3beaca9fab..30d5187faa 100644
--- a/frontend/rust-lib/flowy-grid/tests/grid/filter_test/script.rs
+++ b/frontend/rust-lib/flowy-grid/tests/grid/filter_test/script.rs
@@ -224,12 +224,20 @@ impl GridFilterTest {
assert_eq!(expected_setting, setting);
}
FilterScript::AssertFilterChanged { visible_row_len, hide_row_len} => {
- let mut receiver = self.editor.subscribe_view_changed(&self.grid_id).await.unwrap();
+ let editor = self.editor.clone();
+ let view_id = self.view_id();
+ let mut receiver =
+ tokio::spawn(async move {
+ editor.subscribe_view_changed(&view_id).await.unwrap()
+ }).await.unwrap();
match tokio::time::timeout(Duration::from_secs(2), receiver.recv()).await {
- Ok(changed) => match changed.unwrap() { GridViewChanged::DidReceiveFilterResult(changed) => {
- assert_eq!(changed.visible_rows.len(), visible_row_len, "visible rows not match");
- assert_eq!(changed.invisible_rows.len(), hide_row_len, "invisible rows not match");
- } },
+ Ok(changed) => {
+ //
+ match changed.unwrap() { GridViewChanged::DidReceiveFilterResult(changed) => {
+ assert_eq!(changed.visible_rows.len(), visible_row_len, "visible rows not match");
+ assert_eq!(changed.invisible_rows.len(), hide_row_len, "invisible rows not match");
+ } }
+ },
Err(e) => {
panic!("Process task timeout: {:?}", e);
}