|
@@ -10,7 +10,7 @@ async fn sort_text_by_ascending_test() {
|
|
|
let scripts = vec![
|
|
|
AssertCellContentOrder {
|
|
|
field_id: text_field.id.clone(),
|
|
|
- orders: vec!["A", "", "C", "DA", "AE", "AE"],
|
|
|
+ orders: vec!["A", "", "C", "DA", "AE", "AE", "CB"],
|
|
|
},
|
|
|
InsertSort {
|
|
|
field: text_field.clone(),
|
|
@@ -18,7 +18,28 @@ async fn sort_text_by_ascending_test() {
|
|
|
},
|
|
|
AssertCellContentOrder {
|
|
|
field_id: text_field.id.clone(),
|
|
|
- orders: vec!["A", "AE", "AE", "C", "DA", ""],
|
|
|
+ orders: vec!["A", "AE", "AE", "C", "CB", "DA", ""],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ test.run_scripts(scripts).await;
|
|
|
+}
|
|
|
+
|
|
|
+#[tokio::test]
|
|
|
+async fn sort_text_by_descending_test() {
|
|
|
+ let mut test = DatabaseSortTest::new().await;
|
|
|
+ let text_field = test.get_first_field(FieldType::RichText);
|
|
|
+ let scripts = vec![
|
|
|
+ AssertCellContentOrder {
|
|
|
+ field_id: text_field.id.clone(),
|
|
|
+ orders: vec!["A", "", "C", "DA", "AE", "AE", "CB"],
|
|
|
+ },
|
|
|
+ InsertSort {
|
|
|
+ field: text_field.clone(),
|
|
|
+ condition: SortCondition::Descending,
|
|
|
+ },
|
|
|
+ AssertCellContentOrder {
|
|
|
+ field_id: text_field.id.clone(),
|
|
|
+ orders: vec!["DA", "CB", "C", "AE", "AE", "A", ""],
|
|
|
},
|
|
|
];
|
|
|
test.run_scripts(scripts).await;
|
|
@@ -29,13 +50,17 @@ async fn sort_change_notification_by_update_text_test() {
|
|
|
let mut test = DatabaseSortTest::new().await;
|
|
|
let text_field = test.get_first_field(FieldType::RichText).clone();
|
|
|
let scripts = vec![
|
|
|
+ AssertCellContentOrder {
|
|
|
+ field_id: text_field.id.clone(),
|
|
|
+ orders: vec!["A", "", "C", "DA", "AE", "AE", "CB"],
|
|
|
+ },
|
|
|
InsertSort {
|
|
|
field: text_field.clone(),
|
|
|
condition: SortCondition::Ascending,
|
|
|
},
|
|
|
AssertCellContentOrder {
|
|
|
field_id: text_field.id.clone(),
|
|
|
- orders: vec!["A", "AE", "AE", "C", "DA", ""],
|
|
|
+ orders: vec!["A", "AE", "AE", "C", "CB", "DA", ""],
|
|
|
},
|
|
|
// Wait the insert task to finish. The cost of time should be less than 200 milliseconds.
|
|
|
Wait { millis: 200 },
|
|
@@ -49,8 +74,8 @@ async fn sort_change_notification_by_update_text_test() {
|
|
|
text: "E".to_string(),
|
|
|
},
|
|
|
AssertSortChanged {
|
|
|
- old_row_orders: vec!["A", "E", "AE", "C", "DA", ""],
|
|
|
- new_row_orders: vec!["A", "AE", "C", "DA", "E", ""],
|
|
|
+ old_row_orders: vec!["A", "E", "AE", "C", "CB", "DA", ""],
|
|
|
+ new_row_orders: vec!["A", "AE", "C", "CB", "DA", "E", ""],
|
|
|
},
|
|
|
];
|
|
|
test.run_scripts(scripts).await;
|
|
@@ -73,28 +98,7 @@ async fn sort_text_by_ascending_and_delete_sort_test() {
|
|
|
},
|
|
|
AssertCellContentOrder {
|
|
|
field_id: text_field.id.clone(),
|
|
|
- orders: vec!["A", "", "C", "DA", "AE"],
|
|
|
- },
|
|
|
- ];
|
|
|
- test.run_scripts(scripts).await;
|
|
|
-}
|
|
|
-
|
|
|
-#[tokio::test]
|
|
|
-async fn sort_text_by_descending_test() {
|
|
|
- let mut test = DatabaseSortTest::new().await;
|
|
|
- let text_field = test.get_first_field(FieldType::RichText);
|
|
|
- let scripts = vec![
|
|
|
- AssertCellContentOrder {
|
|
|
- field_id: text_field.id.clone(),
|
|
|
- orders: vec!["A", "", "C", "DA", "AE", "AE"],
|
|
|
- },
|
|
|
- InsertSort {
|
|
|
- field: text_field.clone(),
|
|
|
- condition: SortCondition::Descending,
|
|
|
- },
|
|
|
- AssertCellContentOrder {
|
|
|
- field_id: text_field.id.clone(),
|
|
|
- orders: vec!["DA", "C", "AE", "AE", "A", ""],
|
|
|
+ orders: vec!["A", "", "C", "DA", "AE", "AE", "CB"],
|
|
|
},
|
|
|
];
|
|
|
test.run_scripts(scripts).await;
|
|
@@ -107,12 +111,16 @@ async fn sort_checkbox_by_ascending_test() {
|
|
|
let scripts = vec![
|
|
|
AssertCellContentOrder {
|
|
|
field_id: checkbox_field.id.clone(),
|
|
|
- orders: vec!["Yes", "Yes", "No", "No", "No"],
|
|
|
+ orders: vec!["Yes", "Yes", "No", "No", "No", "Yes", ""],
|
|
|
},
|
|
|
InsertSort {
|
|
|
field: checkbox_field.clone(),
|
|
|
condition: SortCondition::Ascending,
|
|
|
},
|
|
|
+ AssertCellContentOrder {
|
|
|
+ field_id: checkbox_field.id.clone(),
|
|
|
+ orders: vec!["No", "No", "No", "", "Yes", "Yes", "Yes"],
|
|
|
+ },
|
|
|
];
|
|
|
test.run_scripts(scripts).await;
|
|
|
}
|
|
@@ -124,7 +132,7 @@ async fn sort_checkbox_by_descending_test() {
|
|
|
let scripts = vec![
|
|
|
AssertCellContentOrder {
|
|
|
field_id: checkbox_field.id.clone(),
|
|
|
- orders: vec!["Yes", "Yes", "No", "No", "No", "Yes"],
|
|
|
+ orders: vec!["Yes", "Yes", "No", "No", "No", "Yes", ""],
|
|
|
},
|
|
|
InsertSort {
|
|
|
field: checkbox_field.clone(),
|
|
@@ -132,7 +140,7 @@ async fn sort_checkbox_by_descending_test() {
|
|
|
},
|
|
|
AssertCellContentOrder {
|
|
|
field_id: checkbox_field.id.clone(),
|
|
|
- orders: vec!["Yes", "Yes", "Yes", "No", "No", "No"],
|
|
|
+ orders: vec!["Yes", "Yes", "Yes", "No", "No", "No", ""],
|
|
|
},
|
|
|
];
|
|
|
test.run_scripts(scripts).await;
|
|
@@ -151,6 +159,8 @@ async fn sort_date_by_ascending_test() {
|
|
|
"2022/03/14",
|
|
|
"2022/11/17",
|
|
|
"2022/11/13",
|
|
|
+ "2022/12/25",
|
|
|
+ "",
|
|
|
],
|
|
|
},
|
|
|
InsertSort {
|
|
@@ -165,6 +175,8 @@ async fn sort_date_by_ascending_test() {
|
|
|
"2022/03/14",
|
|
|
"2022/11/13",
|
|
|
"2022/11/17",
|
|
|
+ "2022/12/25",
|
|
|
+ "",
|
|
|
],
|
|
|
},
|
|
|
];
|
|
@@ -185,6 +197,7 @@ async fn sort_date_by_descending_test() {
|
|
|
"2022/11/17",
|
|
|
"2022/11/13",
|
|
|
"2022/12/25",
|
|
|
+ "",
|
|
|
],
|
|
|
},
|
|
|
InsertSort {
|
|
@@ -200,12 +213,34 @@ async fn sort_date_by_descending_test() {
|
|
|
"2022/03/14",
|
|
|
"2022/03/14",
|
|
|
"2022/03/14",
|
|
|
+ "",
|
|
|
],
|
|
|
},
|
|
|
];
|
|
|
test.run_scripts(scripts).await;
|
|
|
}
|
|
|
|
|
|
+#[tokio::test]
|
|
|
+async fn sort_number_by_ascending_test() {
|
|
|
+ let mut test = DatabaseSortTest::new().await;
|
|
|
+ let number_field = test.get_first_field(FieldType::Number);
|
|
|
+ let scripts = vec![
|
|
|
+ AssertCellContentOrder {
|
|
|
+ field_id: number_field.id.clone(),
|
|
|
+ orders: vec!["$1", "$2", "$3", "$14", "", "$5", ""],
|
|
|
+ },
|
|
|
+ InsertSort {
|
|
|
+ field: number_field.clone(),
|
|
|
+ condition: SortCondition::Ascending,
|
|
|
+ },
|
|
|
+ AssertCellContentOrder {
|
|
|
+ field_id: number_field.id.clone(),
|
|
|
+ orders: vec!["$1", "$2", "$3", "$5", "$14", "", ""],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ test.run_scripts(scripts).await;
|
|
|
+}
|
|
|
+
|
|
|
#[tokio::test]
|
|
|
async fn sort_number_by_descending_test() {
|
|
|
let mut test = DatabaseSortTest::new().await;
|
|
@@ -213,7 +248,7 @@ async fn sort_number_by_descending_test() {
|
|
|
let scripts = vec![
|
|
|
AssertCellContentOrder {
|
|
|
field_id: number_field.id.clone(),
|
|
|
- orders: vec!["$1", "$2", "$3", "$14", "", "$5"],
|
|
|
+ orders: vec!["$1", "$2", "$3", "$14", "", "$5", ""],
|
|
|
},
|
|
|
InsertSort {
|
|
|
field: number_field.clone(),
|
|
@@ -221,7 +256,28 @@ async fn sort_number_by_descending_test() {
|
|
|
},
|
|
|
AssertCellContentOrder {
|
|
|
field_id: number_field.id.clone(),
|
|
|
- orders: vec!["$14", "$5", "$3", "$2", "$1", ""],
|
|
|
+ orders: vec!["$14", "$5", "$3", "$2", "$1", "", ""],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ test.run_scripts(scripts).await;
|
|
|
+}
|
|
|
+
|
|
|
+#[tokio::test]
|
|
|
+async fn sort_single_select_by_ascending_test() {
|
|
|
+ let mut test = DatabaseSortTest::new().await;
|
|
|
+ let single_select = test.get_first_field(FieldType::SingleSelect);
|
|
|
+ let scripts = vec![
|
|
|
+ AssertCellContentOrder {
|
|
|
+ field_id: single_select.id.clone(),
|
|
|
+ orders: vec!["", "", "Completed", "Completed", "Planned", "Planned", ""],
|
|
|
+ },
|
|
|
+ InsertSort {
|
|
|
+ field: single_select.clone(),
|
|
|
+ condition: SortCondition::Ascending,
|
|
|
+ },
|
|
|
+ AssertCellContentOrder {
|
|
|
+ field_id: single_select.id.clone(),
|
|
|
+ orders: vec!["Completed", "Completed", "Planned", "Planned", "", "", ""],
|
|
|
},
|
|
|
];
|
|
|
test.run_scripts(scripts).await;
|
|
@@ -234,7 +290,7 @@ async fn sort_single_select_by_descending_test() {
|
|
|
let scripts = vec![
|
|
|
AssertCellContentOrder {
|
|
|
field_id: single_select.id.clone(),
|
|
|
- orders: vec!["", "", "Completed", "Completed", "Planned", "Planned"],
|
|
|
+ orders: vec!["", "", "Completed", "Completed", "Planned", "Planned", ""],
|
|
|
},
|
|
|
InsertSort {
|
|
|
field: single_select.clone(),
|
|
@@ -242,7 +298,7 @@ async fn sort_single_select_by_descending_test() {
|
|
|
},
|
|
|
AssertCellContentOrder {
|
|
|
field_id: single_select.id.clone(),
|
|
|
- orders: vec!["Planned", "Planned", "Completed", "Completed", "", ""],
|
|
|
+ orders: vec!["Planned", "Planned", "Completed", "Completed", "", "", ""],
|
|
|
},
|
|
|
];
|
|
|
test.run_scripts(scripts).await;
|
|
@@ -255,7 +311,15 @@ async fn sort_multi_select_by_ascending_test() {
|
|
|
let scripts = vec![
|
|
|
AssertCellContentOrder {
|
|
|
field_id: multi_select.id.clone(),
|
|
|
- orders: vec!["Google,Facebook", "Google,Twitter", "Facebook", "", "", ""],
|
|
|
+ orders: vec![
|
|
|
+ "Google,Facebook",
|
|
|
+ "Google,Twitter",
|
|
|
+ "Facebook,Google,Twitter",
|
|
|
+ "",
|
|
|
+ "Facebook,Twitter",
|
|
|
+ "Facebook",
|
|
|
+ "",
|
|
|
+ ],
|
|
|
},
|
|
|
InsertSort {
|
|
|
field: multi_select.clone(),
|
|
@@ -263,7 +327,52 @@ async fn sort_multi_select_by_ascending_test() {
|
|
|
},
|
|
|
AssertCellContentOrder {
|
|
|
field_id: multi_select.id.clone(),
|
|
|
- orders: vec!["Facebook", "Google,Facebook", "Google,Twitter", "", "", ""],
|
|
|
+ orders: vec![
|
|
|
+ "Facebook",
|
|
|
+ "Facebook,Twitter",
|
|
|
+ "Google,Facebook",
|
|
|
+ "Google,Twitter",
|
|
|
+ "Facebook,Google,Twitter",
|
|
|
+ "",
|
|
|
+ "",
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ test.run_scripts(scripts).await;
|
|
|
+}
|
|
|
+
|
|
|
+#[tokio::test]
|
|
|
+async fn sort_multi_select_by_descending_test() {
|
|
|
+ let mut test = DatabaseSortTest::new().await;
|
|
|
+ let multi_select = test.get_first_field(FieldType::MultiSelect);
|
|
|
+ let scripts = vec![
|
|
|
+ AssertCellContentOrder {
|
|
|
+ field_id: multi_select.id.clone(),
|
|
|
+ orders: vec![
|
|
|
+ "Google,Facebook",
|
|
|
+ "Google,Twitter",
|
|
|
+ "Facebook,Google,Twitter",
|
|
|
+ "",
|
|
|
+ "Facebook,Twitter",
|
|
|
+ "Facebook",
|
|
|
+ "",
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ InsertSort {
|
|
|
+ field: multi_select.clone(),
|
|
|
+ condition: SortCondition::Descending,
|
|
|
+ },
|
|
|
+ AssertCellContentOrder {
|
|
|
+ field_id: multi_select.id.clone(),
|
|
|
+ orders: vec![
|
|
|
+ "Facebook,Google,Twitter",
|
|
|
+ "Google,Twitter",
|
|
|
+ "Google,Facebook",
|
|
|
+ "Facebook,Twitter",
|
|
|
+ "Facebook",
|
|
|
+ "",
|
|
|
+ "",
|
|
|
+ ],
|
|
|
},
|
|
|
];
|
|
|
test.run_scripts(scripts).await;
|