test_helper.rs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. use std::collections::HashMap;
  2. use flowy_folder_deps::cloud::gen_view_id;
  3. use crate::entities::{CreateViewParams, ViewLayoutPB};
  4. use crate::manager::FolderManager;
  5. #[cfg(feature = "test_helper")]
  6. impl FolderManager {
  7. pub async fn create_test_grid_view(
  8. &self,
  9. app_id: &str,
  10. name: &str,
  11. ext: HashMap<String, String>,
  12. ) -> String {
  13. self
  14. .create_test_view(app_id, name, ViewLayoutPB::Grid, ext)
  15. .await
  16. }
  17. pub async fn create_test_board_view(
  18. &self,
  19. app_id: &str,
  20. name: &str,
  21. ext: HashMap<String, String>,
  22. ) -> String {
  23. self
  24. .create_test_view(app_id, name, ViewLayoutPB::Board, ext)
  25. .await
  26. }
  27. async fn create_test_view(
  28. &self,
  29. app_id: &str,
  30. name: &str,
  31. layout: ViewLayoutPB,
  32. ext: HashMap<String, String>,
  33. ) -> String {
  34. let view_id = gen_view_id().to_string();
  35. let params = CreateViewParams {
  36. parent_view_id: app_id.to_string(),
  37. name: name.to_string(),
  38. desc: "".to_string(),
  39. layout,
  40. view_id: view_id.clone(),
  41. initial_data: vec![],
  42. meta: ext,
  43. set_as_current: true,
  44. index: None,
  45. };
  46. self.create_view_with_params(params).await.unwrap();
  47. view_id
  48. }
  49. }