| 
									
										
										
										
											2023-07-29 09:46:24 +08:00
										 |  |  | use std::ops::Deref;
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-11 20:02:09 +08:00
										 |  |  | use event_integration::event_builder::EventBuilder;
 | 
					
						
							| 
									
										
										
										
											2024-01-07 11:12:05 +08:00
										 |  |  | use flowy_document::entities::{OpenDocumentPayloadPB, RepeatedDocumentSnapshotMetaPB};
 | 
					
						
							|  |  |  | use flowy_document::event_map::DocumentEvent::GetDocumentSnapshotMeta;
 | 
					
						
							| 
									
										
										
										
											2023-12-31 07:29:40 +08:00
										 |  |  | use flowy_folder::entities::ViewPB;
 | 
					
						
							| 
									
										
										
										
											2023-07-29 09:46:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | use crate::util::FlowySupabaseTest;
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | pub struct FlowySupabaseDocumentTest {
 | 
					
						
							|  |  |  |   inner: FlowySupabaseTest,
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | impl FlowySupabaseDocumentTest {
 | 
					
						
							|  |  |  |   pub async fn new() -> Option<Self> {
 | 
					
						
							| 
									
										
										
										
											2023-10-30 12:35:06 +08:00
										 |  |  |     let inner = FlowySupabaseTest::new().await?;
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  |     let uuid = uuid::Uuid::new_v4().to_string();
 | 
					
						
							| 
									
										
										
										
											2023-10-02 17:22:22 +08:00
										 |  |  |     let _ = inner.supabase_sign_up_with_uuid(&uuid, None).await;
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  |     Some(Self { inner })
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pub async fn create_document(&self) -> ViewPB {
 | 
					
						
							|  |  |  |     let current_workspace = self.inner.get_current_workspace().await;
 | 
					
						
							|  |  |  |     self
 | 
					
						
							|  |  |  |       .inner
 | 
					
						
							| 
									
										
										
										
											2023-12-27 11:42:39 +08:00
										 |  |  |       .create_and_open_document(¤t_workspace.id, "my document".to_string(), vec![])
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  |       .await
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-02 17:22:22 +08:00
										 |  |  |   #[allow(dead_code)]
 | 
					
						
							| 
									
										
										
										
											2024-01-07 11:12:05 +08:00
										 |  |  |   pub async fn get_document_snapshots(&self, view_id: &str) -> RepeatedDocumentSnapshotMetaPB {
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  |     EventBuilder::new(self.inner.deref().clone())
 | 
					
						
							| 
									
										
										
										
											2024-01-07 11:12:05 +08:00
										 |  |  |       .event(GetDocumentSnapshotMeta)
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  |       .payload(OpenDocumentPayloadPB {
 | 
					
						
							|  |  |  |         document_id: view_id.to_string(),
 | 
					
						
							|  |  |  |       })
 | 
					
						
							|  |  |  |       .async_send()
 | 
					
						
							|  |  |  |       .await
 | 
					
						
							| 
									
										
										
										
											2024-01-07 11:12:05 +08:00
										 |  |  |       .parse::<RepeatedDocumentSnapshotMetaPB>()
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  |   }
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | impl Deref for FlowySupabaseDocumentTest {
 | 
					
						
							|  |  |  |   type Target = FlowySupabaseTest;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   fn deref(&self) -> &Self::Target {
 | 
					
						
							|  |  |  |     &self.inner
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | }
 |