| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | use crate::script::{invalid_workspace_name_test_case, FolderScript::*, FolderTest};
 | 
					
						
							| 
									
										
										
										
											2022-03-12 09:30:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-24 21:49:18 +08:00
										 |  |  | use flowy_folder::entities::workspace::CreateWorkspacePayload;
 | 
					
						
							| 
									
										
										
										
											2022-03-12 21:06:15 +08:00
										 |  |  | use flowy_folder_data_model::entities::view::ViewDataType;
 | 
					
						
							| 
									
										
										
										
											2022-03-19 16:52:28 +08:00
										 |  |  | use flowy_revision::disk::RevisionState;
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | use flowy_test::{event_builder::*, FlowySDKTest};
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn workspace_read_all() {
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     test.run_scripts(vec![ReadAllWorkspaces]).await;
 | 
					
						
							| 
									
										
										
										
											2022-02-16 15:28:00 +08:00
										 |  |  |     assert!(!test.all_workspace.is_empty());
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn workspace_create() {
 | 
					
						
							|  |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let name = "My new workspace".to_owned();
 | 
					
						
							|  |  |  |     let desc = "Daily routines".to_owned();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![CreateWorkspace {
 | 
					
						
							|  |  |  |         name: name.clone(),
 | 
					
						
							|  |  |  |         desc: desc.clone(),
 | 
					
						
							|  |  |  |     }])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let workspace = test.workspace.clone();
 | 
					
						
							|  |  |  |     assert_eq!(workspace.name, name);
 | 
					
						
							|  |  |  |     assert_eq!(workspace.desc, desc);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         ReadWorkspace(Some(workspace.id.clone())),
 | 
					
						
							|  |  |  |         AssertWorkspace(workspace),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn workspace_read() {
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let workspace = test.workspace.clone();
 | 
					
						
							|  |  |  |     let json = serde_json::to_string(&workspace).unwrap();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         ReadWorkspace(Some(workspace.id.clone())),
 | 
					
						
							|  |  |  |         AssertWorkspaceJson(json),
 | 
					
						
							|  |  |  |         AssertWorkspace(workspace),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn workspace_create_with_apps() {
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     test.run_scripts(vec![CreateApp {
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  |         name: "App".to_string(),
 | 
					
						
							|  |  |  |         desc: "App description".to_string(),
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     }])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let app = test.app.clone();
 | 
					
						
							|  |  |  |     let json = serde_json::to_string(&app).unwrap();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![ReadApp(app.id), AssertAppJson(json)]).await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn workspace_create_with_invalid_name() {
 | 
					
						
							|  |  |  |     for (name, code) in invalid_workspace_name_test_case() {
 | 
					
						
							|  |  |  |         let sdk = FlowySDKTest::default();
 | 
					
						
							| 
									
										
										
										
											2022-02-24 21:49:18 +08:00
										 |  |  |         let request = CreateWorkspacePayload {
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  |             name,
 | 
					
						
							|  |  |  |             desc: "".to_owned(),
 | 
					
						
							|  |  |  |         };
 | 
					
						
							|  |  |  |         assert_eq!(
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |             FolderEventBuilder::new(sdk)
 | 
					
						
							| 
									
										
										
										
											2022-01-30 10:33:21 +08:00
										 |  |  |                 .event(flowy_folder::event_map::FolderEvent::CreateWorkspace)
 | 
					
						
							| 
									
										
										
										
											2022-02-24 21:49:18 +08:00
										 |  |  |                 .payload(request)
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  |                 .async_send()
 | 
					
						
							|  |  |  |                 .await
 | 
					
						
							|  |  |  |                 .error()
 | 
					
						
							|  |  |  |                 .code,
 | 
					
						
							|  |  |  |             code.value()
 | 
					
						
							|  |  |  |         )
 | 
					
						
							|  |  |  |     }
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | #[should_panic]
 | 
					
						
							|  |  |  | async fn app_delete() {
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let app = test.app.clone();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![DeleteApp, ReadApp(app.id)]).await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | async fn app_delete_then_restore() {
 | 
					
						
							|  |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let app = test.app.clone();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         DeleteApp,
 | 
					
						
							|  |  |  |         RestoreAppFromTrash,
 | 
					
						
							|  |  |  |         ReadApp(app.id.clone()),
 | 
					
						
							|  |  |  |         AssertApp(app),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  |     .await;
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn app_read() {
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let app = test.app.clone();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![ReadApp(app.id.clone()), AssertApp(app)]).await;
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn app_update() {
 | 
					
						
							|  |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let app = test.app.clone();
 | 
					
						
							|  |  |  |     let new_name = "😁 hell world".to_owned();
 | 
					
						
							|  |  |  |     assert_ne!(app.name, new_name);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         UpdateApp {
 | 
					
						
							|  |  |  |             name: Some(new_name.clone()),
 | 
					
						
							|  |  |  |             desc: None,
 | 
					
						
							|  |  |  |         },
 | 
					
						
							|  |  |  |         ReadApp(app.id),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							|  |  |  |     assert_eq!(test.app.name, new_name);
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn app_create_with_view() {
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let mut app = test.app.clone();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         CreateView {
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  |             name: "View A".to_owned(),
 | 
					
						
							|  |  |  |             desc: "View A description".to_owned(),
 | 
					
						
							| 
									
										
										
										
											2022-03-12 21:06:15 +08:00
										 |  |  |             data_type: ViewDataType::TextBlock,
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |         },
 | 
					
						
							|  |  |  |         CreateView {
 | 
					
						
							| 
									
										
										
										
											2022-03-12 21:06:15 +08:00
										 |  |  |             name: "Grid".to_owned(),
 | 
					
						
							|  |  |  |             desc: "Grid description".to_owned(),
 | 
					
						
							|  |  |  |             data_type: ViewDataType::Grid,
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |         },
 | 
					
						
							|  |  |  |         ReadApp(app.id),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     app = test.app.clone();
 | 
					
						
							|  |  |  |     assert_eq!(app.belongings.len(), 3);
 | 
					
						
							|  |  |  |     assert_eq!(app.belongings[1].name, "View A");
 | 
					
						
							| 
									
										
										
										
											2022-03-12 21:06:15 +08:00
										 |  |  |     assert_eq!(app.belongings[2].name, "Grid")
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn view_update() {
 | 
					
						
							|  |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let view = test.view.clone();
 | 
					
						
							|  |  |  |     let new_name = "😁 123".to_owned();
 | 
					
						
							|  |  |  |     assert_ne!(view.name, new_name);
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         UpdateView {
 | 
					
						
							|  |  |  |             name: Some(new_name.clone()),
 | 
					
						
							|  |  |  |             desc: None,
 | 
					
						
							|  |  |  |         },
 | 
					
						
							|  |  |  |         ReadView(view.id),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							|  |  |  |     assert_eq!(test.view.name, new_name);
 | 
					
						
							|  |  |  | }
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | #[should_panic]
 | 
					
						
							|  |  |  | async fn view_delete() {
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let view = test.view.clone();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![DeleteView, ReadView(view.id)]).await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | async fn view_delete_then_restore() {
 | 
					
						
							|  |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let view = test.view.clone();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         DeleteView,
 | 
					
						
							|  |  |  |         RestoreViewFromTrash,
 | 
					
						
							|  |  |  |         ReadView(view.id.clone()),
 | 
					
						
							|  |  |  |         AssertView(view),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  |     .await;
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn view_delete_all() {
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let app = test.app.clone();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         CreateView {
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  |             name: "View A".to_owned(),
 | 
					
						
							|  |  |  |             desc: "View A description".to_owned(),
 | 
					
						
							| 
									
										
										
										
											2022-03-12 21:06:15 +08:00
										 |  |  |             data_type: ViewDataType::TextBlock,
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |         },
 | 
					
						
							|  |  |  |         CreateView {
 | 
					
						
							| 
									
										
										
										
											2022-03-12 21:06:15 +08:00
										 |  |  |             name: "Grid".to_owned(),
 | 
					
						
							|  |  |  |             desc: "Grid description".to_owned(),
 | 
					
						
							|  |  |  |             data_type: ViewDataType::Grid,
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |         },
 | 
					
						
							|  |  |  |         ReadApp(app.id.clone()),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     assert_eq!(test.app.belongings.len(), 3);
 | 
					
						
							|  |  |  |     let view_ids = test
 | 
					
						
							|  |  |  |         .app
 | 
					
						
							|  |  |  |         .belongings
 | 
					
						
							|  |  |  |         .iter()
 | 
					
						
							|  |  |  |         .map(|view| view.id.clone())
 | 
					
						
							|  |  |  |         .collect::<Vec<String>>();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![DeleteViews(view_ids), ReadApp(app.id), ReadTrash])
 | 
					
						
							|  |  |  |         .await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     assert_eq!(test.app.belongings.len(), 0);
 | 
					
						
							|  |  |  |     assert_eq!(test.trash.len(), 3);
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn view_delete_all_permanent() {
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     let app = test.app.clone();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         CreateView {
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  |             name: "View A".to_owned(),
 | 
					
						
							|  |  |  |             desc: "View A description".to_owned(),
 | 
					
						
							| 
									
										
										
										
											2022-03-12 21:06:15 +08:00
										 |  |  |             data_type: ViewDataType::TextBlock,
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |         },
 | 
					
						
							|  |  |  |         ReadApp(app.id.clone()),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let view_ids = test
 | 
					
						
							|  |  |  |         .app
 | 
					
						
							|  |  |  |         .belongings
 | 
					
						
							|  |  |  |         .iter()
 | 
					
						
							|  |  |  |         .map(|view| view.id.clone())
 | 
					
						
							|  |  |  |         .collect::<Vec<String>>();
 | 
					
						
							|  |  |  |     test.run_scripts(vec![DeleteViews(view_ids), ReadApp(app.id), DeleteAllTrash, ReadTrash])
 | 
					
						
							|  |  |  |         .await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     assert_eq!(test.app.belongings.len(), 0);
 | 
					
						
							|  |  |  |     assert_eq!(test.trash.len(), 0);
 | 
					
						
							|  |  |  | }
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn folder_sync_revision_state() {
 | 
					
						
							|  |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         AssertRevisionState {
 | 
					
						
							|  |  |  |             rev_id: 1,
 | 
					
						
							|  |  |  |             state: RevisionState::Sync,
 | 
					
						
							|  |  |  |         },
 | 
					
						
							|  |  |  |         AssertNextSyncRevId(Some(1)),
 | 
					
						
							|  |  |  |         AssertRevisionState {
 | 
					
						
							|  |  |  |             rev_id: 1,
 | 
					
						
							|  |  |  |             state: RevisionState::Ack,
 | 
					
						
							|  |  |  |         },
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							|  |  |  | }
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn folder_sync_revision_seq() {
 | 
					
						
							|  |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							|  |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         AssertRevisionState {
 | 
					
						
							|  |  |  |             rev_id: 1,
 | 
					
						
							|  |  |  |             state: RevisionState::Sync,
 | 
					
						
							|  |  |  |         },
 | 
					
						
							|  |  |  |         AssertRevisionState {
 | 
					
						
							|  |  |  |             rev_id: 2,
 | 
					
						
							|  |  |  |             state: RevisionState::Sync,
 | 
					
						
							|  |  |  |         },
 | 
					
						
							|  |  |  |         AssertNextSyncRevId(Some(1)),
 | 
					
						
							|  |  |  |         AssertNextSyncRevId(Some(2)),
 | 
					
						
							|  |  |  |         AssertRevisionState {
 | 
					
						
							|  |  |  |             rev_id: 1,
 | 
					
						
							|  |  |  |             state: RevisionState::Ack,
 | 
					
						
							|  |  |  |         },
 | 
					
						
							|  |  |  |         AssertRevisionState {
 | 
					
						
							|  |  |  |             rev_id: 2,
 | 
					
						
							|  |  |  |             state: RevisionState::Ack,
 | 
					
						
							|  |  |  |         },
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | async fn folder_sync_revision_with_new_app() {
 | 
					
						
							|  |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  |     let app_name = "AppFlowy contributors".to_owned();
 | 
					
						
							|  |  |  |     let app_desc = "Welcome to be a AppFlowy contributor".to_owned();
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         AssertNextSyncRevId(Some(1)),
 | 
					
						
							|  |  |  |         AssertNextSyncRevId(Some(2)),
 | 
					
						
							|  |  |  |         CreateApp {
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  |             name: app_name.clone(),
 | 
					
						
							|  |  |  |             desc: app_desc.clone(),
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |         },
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  |         AssertCurrentRevId(3),
 | 
					
						
							|  |  |  |         AssertNextSyncRevId(Some(3)),
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |         AssertNextSyncRevId(None),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     let app = test.app.clone();
 | 
					
						
							|  |  |  |     assert_eq!(app.name, app_name);
 | 
					
						
							|  |  |  |     assert_eq!(app.desc, app_desc);
 | 
					
						
							|  |  |  |     test.run_scripts(vec![ReadApp(app.id.clone()), AssertApp(app)]).await;
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | }
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  | #[tokio::test]
 | 
					
						
							|  |  |  | async fn folder_sync_revision_with_new_view() {
 | 
					
						
							|  |  |  |     let mut test = FolderTest::new().await;
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  |     let view_name = "AppFlowy features".to_owned();
 | 
					
						
							|  |  |  |     let view_desc = "😁".to_owned();
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |     test.run_scripts(vec![
 | 
					
						
							|  |  |  |         AssertNextSyncRevId(Some(1)),
 | 
					
						
							|  |  |  |         AssertNextSyncRevId(Some(2)),
 | 
					
						
							|  |  |  |         CreateView {
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  |             name: view_name.clone(),
 | 
					
						
							|  |  |  |             desc: view_desc.clone(),
 | 
					
						
							| 
									
										
										
										
											2022-03-12 21:06:15 +08:00
										 |  |  |             data_type: ViewDataType::TextBlock,
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |         },
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  |         AssertCurrentRevId(3),
 | 
					
						
							|  |  |  |         AssertNextSyncRevId(Some(3)),
 | 
					
						
							| 
									
										
										
										
											2022-01-22 18:48:43 +08:00
										 |  |  |         AssertNextSyncRevId(None),
 | 
					
						
							|  |  |  |     ])
 | 
					
						
							|  |  |  |     .await;
 | 
					
						
							| 
									
										
										
										
											2022-01-26 23:29:18 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     let view = test.view.clone();
 | 
					
						
							|  |  |  |     assert_eq!(view.name, view_name);
 | 
					
						
							|  |  |  |     assert_eq!(view.desc, view_desc);
 | 
					
						
							|  |  |  |     test.run_scripts(vec![ReadView(view.id.clone()), AssertView(view)])
 | 
					
						
							|  |  |  |         .await;
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:00:11 +08:00
										 |  |  | }
 |