2021-07-20 07:51:49 +00:00
|
|
|
use crate::helper::*;
|
2021-07-25 00:13:59 +00:00
|
|
|
|
2021-07-29 09:27:59 +00:00
|
|
|
use flowy_workspace::entities::{
|
2021-07-31 02:50:56 +00:00
|
|
|
app::{QueryAppRequest, UpdateAppRequest},
|
2021-07-29 09:27:59 +00:00
|
|
|
view::*,
|
|
|
|
};
|
2021-07-19 13:05:49 +00:00
|
|
|
|
|
|
|
#[test]
|
2021-08-30 14:44:17 +00:00
|
|
|
fn app_create() {
|
2021-08-29 14:00:42 +00:00
|
|
|
let workspace = create_workspace("Workspace", "").1;
|
|
|
|
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
|
2021-07-20 07:51:49 +00:00
|
|
|
dbg!(&app);
|
|
|
|
}
|
2021-07-20 06:03:21 +00:00
|
|
|
|
2021-07-29 09:27:59 +00:00
|
|
|
#[test]
|
|
|
|
#[should_panic]
|
2021-08-30 14:44:17 +00:00
|
|
|
fn app_delete() {
|
2021-08-29 14:00:42 +00:00
|
|
|
let workspace = create_workspace("Workspace", "").1;
|
|
|
|
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
|
2021-07-29 09:27:59 +00:00
|
|
|
delete_app(&app.id);
|
|
|
|
let query = QueryAppRequest::new(&app.id);
|
|
|
|
let _ = read_app(query);
|
|
|
|
}
|
|
|
|
|
2021-07-20 07:51:49 +00:00
|
|
|
#[test]
|
2021-08-30 14:44:17 +00:00
|
|
|
fn app_read() {
|
2021-08-29 14:00:42 +00:00
|
|
|
let workspace = create_workspace("Workspace", "").1;
|
|
|
|
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
|
2021-07-29 09:27:59 +00:00
|
|
|
let query = QueryAppRequest::new(&app.id);
|
|
|
|
let app_from_db = read_app(query);
|
2021-07-20 07:51:49 +00:00
|
|
|
assert_eq!(app_from_db, app);
|
2021-07-20 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-08-30 14:44:17 +00:00
|
|
|
fn app_create_with_view() {
|
2021-08-29 14:00:42 +00:00
|
|
|
let workspace = create_workspace("Workspace", "").1;
|
|
|
|
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
|
2021-07-20 07:51:49 +00:00
|
|
|
let request_a = CreateViewRequest {
|
2021-07-28 05:41:39 +00:00
|
|
|
belong_to_id: app.id.clone(),
|
2021-07-20 07:51:49 +00:00
|
|
|
name: "View A".to_string(),
|
|
|
|
desc: "".to_string(),
|
|
|
|
thumbnail: None,
|
2021-07-22 09:39:44 +00:00
|
|
|
view_type: ViewType::Doc,
|
2021-07-19 13:05:49 +00:00
|
|
|
};
|
|
|
|
|
2021-07-20 07:51:49 +00:00
|
|
|
let request_b = CreateViewRequest {
|
2021-07-28 05:41:39 +00:00
|
|
|
belong_to_id: app.id.clone(),
|
2021-07-20 07:51:49 +00:00
|
|
|
name: "View B".to_string(),
|
|
|
|
desc: "".to_string(),
|
|
|
|
thumbnail: None,
|
2021-07-22 09:39:44 +00:00
|
|
|
view_type: ViewType::Doc,
|
2021-07-20 07:51:49 +00:00
|
|
|
};
|
|
|
|
|
2021-07-29 09:27:59 +00:00
|
|
|
let view_a = create_view_with_request(request_a);
|
|
|
|
let view_b = create_view_with_request(request_b);
|
2021-07-20 07:51:49 +00:00
|
|
|
|
2021-07-29 09:27:59 +00:00
|
|
|
let query = QueryAppRequest::new(&app.id).set_read_views(true);
|
|
|
|
let view_from_db = read_app(query);
|
2021-07-19 13:05:49 +00:00
|
|
|
|
2021-07-29 14:22:35 +00:00
|
|
|
assert_eq!(view_from_db.belongings[0], view_a);
|
|
|
|
assert_eq!(view_from_db.belongings[1], view_b);
|
2021-07-19 13:05:49 +00:00
|
|
|
}
|
|
|
|
|
2021-07-29 09:27:59 +00:00
|
|
|
#[test]
|
2021-08-30 14:44:17 +00:00
|
|
|
fn app_set_trash_flag() {
|
2021-07-29 09:27:59 +00:00
|
|
|
let app_id = create_app_with_trash_flag();
|
|
|
|
let query = QueryAppRequest::new(&app_id).set_is_trash(true);
|
|
|
|
let _ = read_app(query);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[should_panic]
|
2021-08-30 14:44:17 +00:00
|
|
|
fn app_set_trash_flag_2() {
|
2021-07-29 09:27:59 +00:00
|
|
|
let app_id = create_app_with_trash_flag();
|
|
|
|
let query = QueryAppRequest::new(&app_id);
|
|
|
|
let _ = read_app(query);
|
|
|
|
}
|
|
|
|
|
2021-08-30 14:44:17 +00:00
|
|
|
fn create_app_with_trash_flag() -> String {
|
2021-08-29 14:00:42 +00:00
|
|
|
let workspace = create_workspace("Workspace", "").1;
|
|
|
|
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
|
2021-07-29 09:27:59 +00:00
|
|
|
let request = UpdateAppRequest {
|
|
|
|
app_id: app.id.clone(),
|
|
|
|
name: None,
|
|
|
|
desc: None,
|
|
|
|
color_style: None,
|
|
|
|
is_trash: Some(true),
|
|
|
|
};
|
|
|
|
update_app(request);
|
|
|
|
|
|
|
|
app.id
|
|
|
|
}
|