mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: fix some bugs
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
use crate::grid::grid_editor::GridEditorTest;
|
||||
use flowy_grid::entities::{CreateRowParams, FieldType, GridLayout, GroupPB, MoveGroupParams, MoveRowParams, RowPB};
|
||||
use flowy_grid::entities::{
|
||||
CreateRowParams, FieldType, GridLayout, GroupPB, MoveGroupParams, MoveGroupRowParams, RowPB,
|
||||
};
|
||||
use flowy_grid::services::cell::insert_select_option_cell;
|
||||
use flowy_grid_data_model::revision::RowChangeset;
|
||||
|
||||
@ -75,14 +77,16 @@ impl GridGroupTest {
|
||||
} => {
|
||||
let groups: Vec<GroupPB> = self.editor.load_groups().await.unwrap().items;
|
||||
let from_row = groups.get(from_group_index).unwrap().rows.get(from_row_index).unwrap();
|
||||
let to_row = groups.get(to_group_index).unwrap().rows.get(to_row_index).unwrap();
|
||||
let params = MoveRowParams {
|
||||
let to_group = groups.get(to_group_index).unwrap();
|
||||
let to_row = to_group.rows.get(to_row_index).unwrap();
|
||||
let params = MoveGroupRowParams {
|
||||
view_id: self.inner.grid_id.clone(),
|
||||
from_row_id: from_row.id.clone(),
|
||||
to_row_id: to_row.id.clone(),
|
||||
to_group_id: to_group.group_id.clone(),
|
||||
to_row_id: Some(to_row.id.clone()),
|
||||
};
|
||||
|
||||
self.editor.move_row(params).await.unwrap();
|
||||
self.editor.move_group_row(params).await.unwrap();
|
||||
}
|
||||
GroupScript::AssertRow {
|
||||
group_index,
|
||||
|
@ -2,7 +2,7 @@ use crate::grid::group_test::script::GridGroupTest;
|
||||
use crate::grid::group_test::script::GroupScript::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_init_test() {
|
||||
async fn group_init_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let scripts = vec![
|
||||
AssertGroupCount(3),
|
||||
@ -23,7 +23,7 @@ async fn board_init_test() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_move_row_test() {
|
||||
async fn group_move_row_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let group = test.group_at_index(0).await;
|
||||
let scripts = vec![
|
||||
@ -48,7 +48,7 @@ async fn board_move_row_test() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_move_row_to_other_group_test() {
|
||||
async fn group_move_row_to_other_group_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let group = test.group_at_index(0).await;
|
||||
let scripts = vec![
|
||||
@ -76,7 +76,7 @@ async fn board_move_row_to_other_group_test() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_move_row_to_other_group_and_reorder_test() {
|
||||
async fn group_move_two_row_to_other_group_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let group = test.group_at_index(0).await;
|
||||
let scripts = vec![
|
||||
@ -86,15 +86,41 @@ async fn board_move_row_to_other_group_and_reorder_test() {
|
||||
to_group_index: 1,
|
||||
to_row_index: 1,
|
||||
},
|
||||
MoveRow {
|
||||
from_group_index: 1,
|
||||
from_row_index: 1,
|
||||
to_group_index: 1,
|
||||
to_row_index: 2,
|
||||
AssertGroupRowCount {
|
||||
group_index: 0,
|
||||
row_count: 1,
|
||||
},
|
||||
AssertGroupRowCount {
|
||||
group_index: 1,
|
||||
row_count: 3,
|
||||
},
|
||||
AssertRow {
|
||||
group_index: 1,
|
||||
row_index: 2,
|
||||
row_index: 1,
|
||||
row: group.rows.get(0).unwrap().clone(),
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
|
||||
let group = test.group_at_index(0).await;
|
||||
let scripts = vec![
|
||||
MoveRow {
|
||||
from_group_index: 0,
|
||||
from_row_index: 0,
|
||||
to_group_index: 1,
|
||||
to_row_index: 1,
|
||||
},
|
||||
AssertGroupRowCount {
|
||||
group_index: 0,
|
||||
row_count: 0,
|
||||
},
|
||||
AssertGroupRowCount {
|
||||
group_index: 1,
|
||||
row_count: 4,
|
||||
},
|
||||
AssertRow {
|
||||
group_index: 1,
|
||||
row_index: 1,
|
||||
row: group.rows.get(0).unwrap().clone(),
|
||||
},
|
||||
];
|
||||
@ -102,7 +128,74 @@ async fn board_move_row_to_other_group_and_reorder_test() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_create_row_test() {
|
||||
async fn group_move_row_to_other_group_and_reorder_from_up_to_down_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![
|
||||
MoveRow {
|
||||
from_group_index: 0,
|
||||
from_row_index: 0,
|
||||
to_group_index: 1,
|
||||
to_row_index: 1,
|
||||
},
|
||||
AssertRow {
|
||||
group_index: 1,
|
||||
row_index: 1,
|
||||
row: group_0.rows.get(0).unwrap().clone(),
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
|
||||
let scripts = vec![
|
||||
MoveRow {
|
||||
from_group_index: 1,
|
||||
from_row_index: 0,
|
||||
to_group_index: 1,
|
||||
to_row_index: 2,
|
||||
},
|
||||
AssertRow {
|
||||
group_index: 1,
|
||||
row_index: 2,
|
||||
row: group_1.rows.get(0).unwrap().clone(),
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn group_move_row_to_other_group_and_reorder_from_bottom_to_up_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let scripts = vec![MoveRow {
|
||||
from_group_index: 0,
|
||||
from_row_index: 0,
|
||||
to_group_index: 1,
|
||||
to_row_index: 1,
|
||||
}];
|
||||
test.run_scripts(scripts).await;
|
||||
|
||||
let group = test.group_at_index(1).await;
|
||||
let scripts = vec![
|
||||
AssertGroupRowCount {
|
||||
group_index: 1,
|
||||
row_count: 3,
|
||||
},
|
||||
MoveRow {
|
||||
from_group_index: 1,
|
||||
from_row_index: 2,
|
||||
to_group_index: 1,
|
||||
to_row_index: 0,
|
||||
},
|
||||
AssertRow {
|
||||
group_index: 1,
|
||||
row_index: 0,
|
||||
row: group.rows.get(2).unwrap().clone(),
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn group_create_row_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let scripts = vec![
|
||||
CreateRow { group_index: 0 },
|
||||
@ -121,7 +214,7 @@ async fn board_create_row_test() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_delete_row_test() {
|
||||
async fn group_delete_row_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let scripts = vec![
|
||||
DeleteRow {
|
||||
@ -137,7 +230,7 @@ async fn board_delete_row_test() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_delete_all_row_test() {
|
||||
async fn group_delete_all_row_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let scripts = vec![
|
||||
DeleteRow {
|
||||
@ -157,7 +250,7 @@ async fn board_delete_all_row_test() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_update_row_test() {
|
||||
async fn group_update_row_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let scripts = vec![
|
||||
// Update the row at 0 in group0 by setting the row's group field data
|
||||
@ -179,7 +272,7 @@ async fn board_update_row_test() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_reorder_group_test() {
|
||||
async fn group_reorder_group_test() {
|
||||
let mut test = GridGroupTest::new().await;
|
||||
let scripts = vec![
|
||||
// Update the row at 0 in group0 by setting the row's group field data
|
||||
@ -201,7 +294,7 @@ async fn board_reorder_group_test() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_move_group_test() {
|
||||
async fn group_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;
|
||||
|
Reference in New Issue
Block a user