2023-04-04 06:08:50 +00:00
|
|
|
use crate::entities::{CreateViewParams, ViewLayoutPB};
|
2023-04-04 00:41:16 +00:00
|
|
|
use crate::manager::Folder2Manager;
|
2023-06-01 12:23:27 +00:00
|
|
|
use crate::view_operation::gen_view_id;
|
2023-04-04 00:41:16 +00:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
#[cfg(feature = "test_helper")]
|
|
|
|
impl Folder2Manager {
|
|
|
|
pub async fn create_test_grid_view(
|
|
|
|
&self,
|
|
|
|
app_id: &str,
|
|
|
|
name: &str,
|
|
|
|
ext: HashMap<String, String>,
|
|
|
|
) -> String {
|
|
|
|
self
|
2023-04-04 06:08:50 +00:00
|
|
|
.create_test_view(app_id, name, ViewLayoutPB::Grid, ext)
|
2023-04-04 00:41:16 +00:00
|
|
|
.await
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn create_test_board_view(
|
|
|
|
&self,
|
|
|
|
app_id: &str,
|
|
|
|
name: &str,
|
|
|
|
ext: HashMap<String, String>,
|
|
|
|
) -> String {
|
|
|
|
self
|
2023-04-04 06:08:50 +00:00
|
|
|
.create_test_view(app_id, name, ViewLayoutPB::Board, ext)
|
2023-04-04 00:41:16 +00:00
|
|
|
.await
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn create_test_view(
|
|
|
|
&self,
|
|
|
|
app_id: &str,
|
|
|
|
name: &str,
|
2023-04-04 06:08:50 +00:00
|
|
|
layout: ViewLayoutPB,
|
2023-04-04 00:41:16 +00:00
|
|
|
ext: HashMap<String, String>,
|
|
|
|
) -> String {
|
|
|
|
let view_id = gen_view_id();
|
|
|
|
let params = CreateViewParams {
|
2023-05-31 06:08:54 +00:00
|
|
|
parent_view_id: app_id.to_string(),
|
2023-04-04 00:41:16 +00:00
|
|
|
name: name.to_string(),
|
|
|
|
desc: "".to_string(),
|
|
|
|
layout,
|
|
|
|
view_id: view_id.clone(),
|
|
|
|
initial_data: vec![],
|
2023-05-31 06:08:54 +00:00
|
|
|
meta: ext,
|
2023-06-03 05:40:12 +00:00
|
|
|
set_as_current: true,
|
2023-04-04 00:41:16 +00:00
|
|
|
};
|
|
|
|
self.create_view_with_params(params).await.unwrap();
|
|
|
|
view_id
|
|
|
|
}
|
|
|
|
}
|