mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: save group rev without apply change
This commit is contained in:
@ -4,11 +4,15 @@ use flowy_grid::services::cell::insert_select_option_cell;
|
||||
use flowy_grid_data_model::revision::RowChangeset;
|
||||
|
||||
pub enum GroupScript {
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: usize,
|
||||
row_count: usize,
|
||||
},
|
||||
AssertGroupCount(usize),
|
||||
AssertGroup {
|
||||
group_index: usize,
|
||||
expected_group: GroupPB,
|
||||
},
|
||||
AssertRow {
|
||||
group_index: usize,
|
||||
row_index: usize,
|
||||
@ -56,7 +60,7 @@ impl GridGroupTest {
|
||||
|
||||
pub async fn run_script(&mut self, script: GroupScript) {
|
||||
match script {
|
||||
GroupScript::AssertGroup { group_index, row_count } => {
|
||||
GroupScript::AssertGroupRowCount { group_index, row_count } => {
|
||||
assert_eq!(row_count, self.group_at_index(group_index).await.rows.len());
|
||||
}
|
||||
GroupScript::AssertGroupCount(count) => {
|
||||
@ -142,6 +146,13 @@ impl GridGroupTest {
|
||||
self.editor.move_group(params).await.unwrap();
|
||||
//
|
||||
}
|
||||
GroupScript::AssertGroup {
|
||||
group_index,
|
||||
expected_group: group_pb,
|
||||
} => {
|
||||
let group = self.group_at_index(group_index).await;
|
||||
assert_eq!(group.group_id, group_pb.group_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,15 +6,15 @@ async fn board_init_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let scripts = vec![
|
||||
AssertGroupCount(3),
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 0,
|
||||
row_count: 2,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 1,
|
||||
row_count: 2,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 2,
|
||||
row_count: 1,
|
||||
},
|
||||
@ -34,7 +34,7 @@ async fn board_move_row_test() {
|
||||
to_group_index: 0,
|
||||
to_row_index: 1,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 0,
|
||||
row_count: 2,
|
||||
},
|
||||
@ -58,11 +58,11 @@ async fn board_move_row_to_other_group_test() {
|
||||
to_group_index: 1,
|
||||
to_row_index: 1,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 0,
|
||||
row_count: 1,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 1,
|
||||
row_count: 3,
|
||||
},
|
||||
@ -106,13 +106,13 @@ async fn board_create_row_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let scripts = vec![
|
||||
CreateRow { group_index: 0 },
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 0,
|
||||
row_count: 3,
|
||||
},
|
||||
CreateRow { group_index: 1 },
|
||||
CreateRow { group_index: 1 },
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 1,
|
||||
row_count: 4,
|
||||
},
|
||||
@ -128,7 +128,7 @@ async fn board_delete_row_test() {
|
||||
group_index: 0,
|
||||
row_index: 0,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 0,
|
||||
row_count: 1,
|
||||
},
|
||||
@ -148,7 +148,7 @@ async fn board_delete_all_row_test() {
|
||||
group_index: 0,
|
||||
row_index: 0,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 0,
|
||||
row_count: 0,
|
||||
},
|
||||
@ -166,11 +166,11 @@ async fn board_update_row_test() {
|
||||
row_index: 0,
|
||||
to_group_index: 1,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 0,
|
||||
row_count: 1,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 1,
|
||||
row_count: 3,
|
||||
},
|
||||
@ -188,14 +188,36 @@ async fn board_reorder_group_test() {
|
||||
row_index: 0,
|
||||
to_group_index: 1,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 0,
|
||||
row_count: 1,
|
||||
},
|
||||
AssertGroup {
|
||||
AssertGroupRowCount {
|
||||
group_index: 1,
|
||||
row_count: 3,
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_move_group_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let group_0 = test.group_at_index(0).await;
|
||||
let group_1 = test.group_at_index(1).await;
|
||||
let scripts = vec![
|
||||
MoveGroup {
|
||||
from_group_index: 0,
|
||||
to_group_index: 1,
|
||||
},
|
||||
AssertGroup {
|
||||
group_index: 0,
|
||||
expected_group: group_1,
|
||||
},
|
||||
AssertGroup {
|
||||
group_index: 1,
|
||||
expected_group: group_0,
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
}
|
||||
|
Reference in New Issue
Block a user