2021-12-15 23:01:50 +08:00
|
|
|
pub mod doc_script;
|
2021-12-08 17:33:22 +08:00
|
|
|
pub mod event_builder;
|
|
|
|
pub mod helper;
|
2021-07-16 23:18:12 +08:00
|
|
|
|
2021-09-04 16:12:48 +08:00
|
|
|
use crate::helper::*;
|
2021-12-05 16:39:41 +08:00
|
|
|
use backend_service::configuration::{get_client_server_configuration, ClientServerConfiguration};
|
2022-01-07 17:37:11 +08:00
|
|
|
use flowy_net::services::ws_conn::FlowyRawWebSocket;
|
2021-09-05 13:50:23 +08:00
|
|
|
use flowy_sdk::{FlowySDK, FlowySDKConfig};
|
2021-09-04 16:53:58 +08:00
|
|
|
use flowy_user::entities::UserProfile;
|
2021-12-29 00:34:00 +08:00
|
|
|
use lib_infra::uuid_string;
|
2022-01-07 17:37:11 +08:00
|
|
|
use std::sync::Arc;
|
2021-07-06 14:14:47 +08:00
|
|
|
|
|
|
|
pub mod prelude {
|
2021-12-08 17:33:22 +08:00
|
|
|
pub use crate::{event_builder::*, helper::*, *};
|
2021-11-19 14:38:11 +08:00
|
|
|
pub use lib_dispatch::prelude::*;
|
2021-07-06 14:14:47 +08:00
|
|
|
}
|
|
|
|
|
2021-09-04 15:12:53 +08:00
|
|
|
#[derive(Clone)]
|
2022-01-07 17:37:11 +08:00
|
|
|
pub struct FlowySDKTest {
|
|
|
|
pub inner: FlowySDK,
|
|
|
|
pub ws: Option<Arc<dyn FlowyRawWebSocket>>,
|
|
|
|
}
|
2021-12-08 17:33:22 +08:00
|
|
|
|
|
|
|
impl std::ops::Deref for FlowySDKTest {
|
|
|
|
type Target = FlowySDK;
|
|
|
|
|
2022-01-07 17:37:11 +08:00
|
|
|
fn deref(&self) -> &Self::Target { &self.inner }
|
2021-09-04 15:12:53 +08:00
|
|
|
}
|
|
|
|
|
2022-01-07 17:37:11 +08:00
|
|
|
impl std::default::Default for FlowySDKTest {
|
|
|
|
fn default() -> Self {
|
2021-12-05 16:39:41 +08:00
|
|
|
let server_config = get_client_server_configuration().unwrap();
|
2022-01-07 17:37:11 +08:00
|
|
|
let sdk = Self::new(server_config, None);
|
2021-12-08 17:33:22 +08:00
|
|
|
std::mem::forget(sdk.dispatcher());
|
|
|
|
sdk
|
|
|
|
}
|
2022-01-07 17:37:11 +08:00
|
|
|
}
|
2021-12-08 17:33:22 +08:00
|
|
|
|
2022-01-07 17:37:11 +08:00
|
|
|
impl FlowySDKTest {
|
|
|
|
pub fn new(server_config: ClientServerConfiguration, ws: Option<Arc<dyn FlowyRawWebSocket>>) -> Self {
|
|
|
|
let config = FlowySDKConfig::new(&root_dir(), server_config, &uuid_string(), None).log_filter("debug");
|
2021-12-08 17:33:22 +08:00
|
|
|
let sdk = FlowySDK::new(config);
|
2022-01-07 17:37:11 +08:00
|
|
|
std::mem::forget(sdk.dispatcher());
|
|
|
|
Self { inner: sdk, ws }
|
2021-09-28 15:29:29 +08:00
|
|
|
}
|
2021-09-27 23:23:23 +08:00
|
|
|
|
2021-09-28 15:29:29 +08:00
|
|
|
pub async fn sign_up(&self) -> SignUpContext {
|
2022-01-07 17:37:11 +08:00
|
|
|
let context = async_sign_up(self.inner.dispatcher()).await;
|
2021-09-28 15:29:29 +08:00
|
|
|
context
|
2021-09-04 15:12:53 +08:00
|
|
|
}
|
|
|
|
|
2021-09-28 15:29:29 +08:00
|
|
|
pub async fn init_user(&self) -> UserProfile {
|
2022-01-07 17:37:11 +08:00
|
|
|
let context = async_sign_up(self.inner.dispatcher()).await;
|
|
|
|
init_user_setting(self.inner.dispatcher()).await;
|
2021-09-28 15:29:29 +08:00
|
|
|
context.user_profile
|
|
|
|
}
|
2021-07-06 14:14:47 +08:00
|
|
|
}
|