| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 | 
							- use crate::grid::group_test::script::GridGroupTest;
 
- use crate::grid::group_test::script::GroupScript::*;
 
- use flowy_grid::services::field::SelectOptionPB;
 
- #[tokio::test]
 
- async fn group_init_test() {
 
-     let mut test = GridGroupTest::new().await;
 
-     let scripts = vec![
 
-         AssertGroupCount(4),
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 2,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 1,
 
-             row_count: 2,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 2,
 
-             row_count: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 3,
 
-             row_count: 0,
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::test]
 
- async fn group_move_row_test() {
 
-     let mut test = GridGroupTest::new().await;
 
-     let group = test.group_at_index(0).await;
 
-     let scripts = vec![
 
-         // Move the row at 0 in group0 to group1 at 1
 
-         MoveRow {
 
-             from_group_index: 0,
 
-             from_row_index: 0,
 
-             to_group_index: 0,
 
-             to_row_index: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 2,
 
-         },
 
-         AssertRow {
 
-             group_index: 0,
 
-             row_index: 1,
 
-             row: group.rows.get(0).unwrap().clone(),
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::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![
 
-         MoveRow {
 
-             from_group_index: 0,
 
-             from_row_index: 0,
 
-             to_group_index: 1,
 
-             to_row_index: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 1,
 
-             row_count: 3,
 
-         },
 
-         AssertRow {
 
-             group_index: 1,
 
-             row_index: 1,
 
-             row: group.rows.get(0).unwrap().clone(),
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::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![
 
-         MoveRow {
 
-             from_group_index: 0,
 
-             from_row_index: 0,
 
-             to_group_index: 1,
 
-             to_row_index: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 1,
 
-             row_count: 3,
 
-         },
 
-         AssertRow {
 
-             group_index: 1,
 
-             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(),
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::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 },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 3,
 
-         },
 
-         CreateRow { group_index: 1 },
 
-         CreateRow { group_index: 1 },
 
-         AssertGroupRowCount {
 
-             group_index: 1,
 
-             row_count: 4,
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::test]
 
- async fn group_delete_row_test() {
 
-     let mut test = GridGroupTest::new().await;
 
-     let scripts = vec![
 
-         DeleteRow {
 
-             group_index: 0,
 
-             row_index: 0,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 1,
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::test]
 
- async fn group_delete_all_row_test() {
 
-     let mut test = GridGroupTest::new().await;
 
-     let scripts = vec![
 
-         DeleteRow {
 
-             group_index: 0,
 
-             row_index: 0,
 
-         },
 
-         DeleteRow {
 
-             group_index: 0,
 
-             row_index: 0,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 0,
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::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
 
-         UpdateRow {
 
-             from_group_index: 0,
 
-             row_index: 0,
 
-             to_group_index: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 1,
 
-             row_count: 3,
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::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
 
-         UpdateRow {
 
-             from_group_index: 0,
 
-             row_index: 0,
 
-             to_group_index: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 1,
 
-             row_count: 3,
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::test]
 
- async fn group_move_to_default_group_test() {
 
-     let mut test = GridGroupTest::new().await;
 
-     let scripts = vec![
 
-         UpdateRow {
 
-             from_group_index: 0,
 
-             row_index: 0,
 
-             to_group_index: 3,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 1,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 3,
 
-             row_count: 1,
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::test]
 
- async fn group_move_from_default_group_test() {
 
-     let mut test = GridGroupTest::new().await;
 
-     let scripts = vec![UpdateRow {
 
-         from_group_index: 0,
 
-         row_index: 0,
 
-         to_group_index: 3,
 
-     }];
 
-     test.run_scripts(scripts).await;
 
-     let scripts = vec![
 
-         UpdateRow {
 
-             from_group_index: 3,
 
-             row_index: 0,
 
-             to_group_index: 0,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 2,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 3,
 
-             row_count: 0,
 
-         },
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
- #[tokio::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;
 
-     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;
 
- }
 
- #[tokio::test]
 
- async fn group_insert_single_select_option_test() {
 
-     let mut test = GridGroupTest::new().await;
 
-     let new_option_name = "New option";
 
-     let scripts = vec![
 
-         AssertGroupCount(4),
 
-         UpdateSingleSelectOption {
 
-             inserted_options: vec![SelectOptionPB::new(new_option_name)],
 
-         },
 
-         AssertGroupCount(5),
 
-     ];
 
-     test.run_scripts(scripts).await;
 
-     // the group at index 4 is the default_group, so the new insert group will be the
 
-     // index 3.
 
-     let group_3 = test.group_at_index(3).await;
 
-     assert_eq!(group_3.desc, new_option_name);
 
- }
 
- #[tokio::test]
 
- async fn group_group_by_other_field() {
 
-     let mut test = GridGroupTest::new().await;
 
-     let multi_select_field = test.get_multi_select_field().await;
 
-     let scripts = vec![
 
-         GroupByField {
 
-             field_id: multi_select_field.id.clone(),
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 0,
 
-             row_count: 3,
 
-         },
 
-         AssertGroupRowCount {
 
-             group_index: 1,
 
-             row_count: 2,
 
-         },
 
-         AssertGroupCount(4),
 
-     ];
 
-     test.run_scripts(scripts).await;
 
- }
 
 
  |