fix: save group rev without apply change

This commit is contained in:
appflowy
2022-08-21 22:47:24 +08:00
parent 23efbc00c1
commit 93f5b5d754
16 changed files with 302 additions and 149 deletions

View File

@ -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);
}
}
}

View File

@ -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;
}