mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
test: added view check after creating workspace
This commit is contained in:
parent
06d5d57637
commit
26ce7c179e
@ -4,12 +4,14 @@ use std::sync::Arc;
|
||||
|
||||
use bytes::Bytes;
|
||||
|
||||
use flowy_folder::entities::{RepeatedViewPB, WorkspacePB};
|
||||
use nanoid::nanoid;
|
||||
use protobuf::ProtobufError;
|
||||
use tokio::sync::broadcast::{channel, Sender};
|
||||
use tracing::error;
|
||||
use uuid::Uuid;
|
||||
|
||||
use flowy_folder::event_map::FolderEvent;
|
||||
use flowy_notification::entities::SubscribeObject;
|
||||
use flowy_notification::NotificationSender;
|
||||
use flowy_server::af_cloud::define::{USER_DEVICE_ID, USER_EMAIL, USER_SIGN_IN_URL, USER_UUID};
|
||||
@ -23,7 +25,6 @@ use flowy_user::entities::{
|
||||
};
|
||||
use flowy_user::errors::{FlowyError, FlowyResult};
|
||||
use flowy_user::event_map::UserEvent;
|
||||
use flowy_user::event_map::UserEvent::*;
|
||||
use lib_dispatch::prelude::{af_spawn, AFPluginDispatcher, AFPluginRequest, ToBytes};
|
||||
|
||||
use crate::event_builder::EventBuilder;
|
||||
@ -32,7 +33,7 @@ use crate::EventIntegrationTest;
|
||||
impl EventIntegrationTest {
|
||||
pub async fn enable_encryption(&self) -> String {
|
||||
let config = EventBuilder::new(self.clone())
|
||||
.event(GetCloudConfig)
|
||||
.event(UserEvent::GetCloudConfig)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<CloudSettingPB>();
|
||||
@ -41,7 +42,7 @@ impl EventIntegrationTest {
|
||||
enable_encrypt: Some(true),
|
||||
};
|
||||
let error = EventBuilder::new(self.clone())
|
||||
.event(SetCloudConfig)
|
||||
.event(UserEvent::SetCloudConfig)
|
||||
.payload(update)
|
||||
.async_send()
|
||||
.await
|
||||
@ -69,7 +70,7 @@ impl EventIntegrationTest {
|
||||
.into_bytes()
|
||||
.unwrap();
|
||||
|
||||
let request = AFPluginRequest::new(SignUp).payload(payload);
|
||||
let request = AFPluginRequest::new(UserEvent::SignUp).payload(payload);
|
||||
let user_profile = AFPluginDispatcher::async_send(&self.appflowy_core.dispatcher(), request)
|
||||
.await
|
||||
.parse::<UserProfilePB, FlowyError>()
|
||||
@ -96,7 +97,7 @@ impl EventIntegrationTest {
|
||||
};
|
||||
|
||||
EventBuilder::new(self.clone())
|
||||
.event(OauthSignIn)
|
||||
.event(UserEvent::OauthSignIn)
|
||||
.payload(payload)
|
||||
.async_send()
|
||||
.await
|
||||
@ -105,7 +106,7 @@ impl EventIntegrationTest {
|
||||
|
||||
pub async fn sign_out(&self) {
|
||||
EventBuilder::new(self.clone())
|
||||
.event(SignOut)
|
||||
.event(UserEvent::SignOut)
|
||||
.async_send()
|
||||
.await;
|
||||
}
|
||||
@ -120,7 +121,7 @@ impl EventIntegrationTest {
|
||||
|
||||
pub async fn get_user_profile(&self) -> Result<UserProfilePB, FlowyError> {
|
||||
EventBuilder::new(self.clone())
|
||||
.event(GetUserProfile)
|
||||
.event(UserEvent::GetUserProfile)
|
||||
.async_send()
|
||||
.await
|
||||
.try_parse::<UserProfilePB>()
|
||||
@ -128,7 +129,7 @@ impl EventIntegrationTest {
|
||||
|
||||
pub async fn update_user_profile(&self, params: UpdateUserProfilePayloadPB) {
|
||||
EventBuilder::new(self.clone())
|
||||
.event(UpdateUserProfile)
|
||||
.event(UserEvent::UpdateUserProfile)
|
||||
.payload(params)
|
||||
.async_send()
|
||||
.await;
|
||||
@ -140,7 +141,7 @@ impl EventIntegrationTest {
|
||||
authenticator: AuthenticatorPB::AppFlowyCloud,
|
||||
};
|
||||
let sign_in_url = EventBuilder::new(self.clone())
|
||||
.event(GenerateSignInURL)
|
||||
.event(UserEvent::GenerateSignInURL)
|
||||
.payload(payload)
|
||||
.async_send()
|
||||
.await
|
||||
@ -156,7 +157,7 @@ impl EventIntegrationTest {
|
||||
};
|
||||
|
||||
let user_profile = EventBuilder::new(self.clone())
|
||||
.event(OauthSignIn)
|
||||
.event(UserEvent::OauthSignIn)
|
||||
.payload(payload)
|
||||
.async_send()
|
||||
.await
|
||||
@ -183,7 +184,7 @@ impl EventIntegrationTest {
|
||||
};
|
||||
|
||||
let user_profile = EventBuilder::new(self.clone())
|
||||
.event(OauthSignIn)
|
||||
.event(UserEvent::OauthSignIn)
|
||||
.payload(payload)
|
||||
.async_send()
|
||||
.await
|
||||
@ -218,7 +219,7 @@ impl EventIntegrationTest {
|
||||
name: name.to_string(),
|
||||
};
|
||||
EventBuilder::new(self.clone())
|
||||
.event(CreateWorkspace)
|
||||
.event(UserEvent::CreateWorkspace)
|
||||
.payload(payload)
|
||||
.async_send()
|
||||
.await
|
||||
@ -235,7 +236,7 @@ impl EventIntegrationTest {
|
||||
new_name: new_name.to_owned(),
|
||||
};
|
||||
match EventBuilder::new(self.clone())
|
||||
.event(RenameWorkspace)
|
||||
.event(UserEvent::RenameWorkspace)
|
||||
.payload(payload)
|
||||
.async_send()
|
||||
.await
|
||||
@ -246,9 +247,25 @@ impl EventIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn folder_read_current_workspace(&self) -> WorkspacePB {
|
||||
EventBuilder::new(self.clone())
|
||||
.event(FolderEvent::ReadCurrentWorkspace)
|
||||
.async_send()
|
||||
.await
|
||||
.parse()
|
||||
}
|
||||
|
||||
pub async fn folder_read_workspace_views(&self) -> RepeatedViewPB {
|
||||
EventBuilder::new(self.clone())
|
||||
.event(FolderEvent::ReadWorkspaceViews)
|
||||
.async_send()
|
||||
.await
|
||||
.parse()
|
||||
}
|
||||
|
||||
pub async fn get_all_workspaces(&self) -> RepeatedUserWorkspacePB {
|
||||
EventBuilder::new(self.clone())
|
||||
.event(GetAllWorkspace)
|
||||
.event(UserEvent::GetAllWorkspace)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<RepeatedUserWorkspacePB>()
|
||||
@ -259,7 +276,7 @@ impl EventIntegrationTest {
|
||||
workspace_id: workspace_id.to_string(),
|
||||
};
|
||||
EventBuilder::new(self.clone())
|
||||
.event(DeleteWorkspace)
|
||||
.event(UserEvent::DeleteWorkspace)
|
||||
.payload(payload)
|
||||
.async_send()
|
||||
.await;
|
||||
@ -270,7 +287,7 @@ impl EventIntegrationTest {
|
||||
workspace_id: workspace_id.to_string(),
|
||||
};
|
||||
EventBuilder::new(self.clone())
|
||||
.event(OpenWorkspace)
|
||||
.event(UserEvent::OpenWorkspace)
|
||||
.payload(payload)
|
||||
.async_send()
|
||||
.await;
|
||||
|
@ -18,7 +18,7 @@ async fn af_cloud_workspace_name_change() {
|
||||
.rename_workspace(workspace_id, "new_workspace_name")
|
||||
.await
|
||||
.expect("failed to rename workspace");
|
||||
let workspaces = get_synced_workspaces(test, user_profile_pb.id).await;
|
||||
let workspaces = get_synced_workspaces(&test, user_profile_pb.id).await;
|
||||
assert_eq!(workspaces[0].name, "new_workspace_name".to_string());
|
||||
}
|
||||
|
||||
@ -29,14 +29,34 @@ async fn af_cloud_create_workspace_test() {
|
||||
let user_profile_pb = test.af_cloud_sign_up().await;
|
||||
|
||||
let workspaces = test.get_all_workspaces().await.items;
|
||||
let first_workspace_id = workspaces[0].workspace_id.as_str();
|
||||
assert_eq!(workspaces.len(), 1);
|
||||
|
||||
let created_workspace = test.create_workspace("my second workspace").await;
|
||||
assert_eq!(created_workspace.name, "my second workspace");
|
||||
|
||||
let workspaces = get_synced_workspaces(test, user_profile_pb.id).await;
|
||||
let workspaces = get_synced_workspaces(&test, user_profile_pb.id).await;
|
||||
assert_eq!(workspaces.len(), 2);
|
||||
assert_eq!(workspaces[1].name, "my second workspace".to_string());
|
||||
|
||||
{
|
||||
// before opening new workspace
|
||||
let folder_ws = test.folder_read_current_workspace().await;
|
||||
assert_eq!(&folder_ws.id, first_workspace_id);
|
||||
let views = test.folder_read_workspace_views().await;
|
||||
assert_eq!(views.items[0].parent_view_id.as_str(), first_workspace_id);
|
||||
}
|
||||
{
|
||||
// after opening new workspace
|
||||
test.open_workspace(&created_workspace.workspace_id).await;
|
||||
let folder_ws = test.folder_read_current_workspace().await;
|
||||
assert_eq!(folder_ws.id, created_workspace.workspace_id);
|
||||
let views = test.folder_read_workspace_views().await;
|
||||
assert_eq!(
|
||||
views.items[0].parent_view_id.as_str(),
|
||||
created_workspace.workspace_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -58,7 +78,7 @@ async fn af_cloud_open_workspace_test() {
|
||||
assert_eq!(views[2].name, "my second document".to_string());
|
||||
}
|
||||
|
||||
async fn get_synced_workspaces(test: EventIntegrationTest, user_id: i64) -> Vec<UserWorkspacePB> {
|
||||
async fn get_synced_workspaces(test: &EventIntegrationTest, user_id: i64) -> Vec<UserWorkspacePB> {
|
||||
let _workspaces = test.get_all_workspaces().await.items;
|
||||
let sub_id = user_id.to_string();
|
||||
let rx = test
|
||||
|
Loading…
Reference in New Issue
Block a user