mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: cloud workspace api (#4469)
* feat: workspace api * feat: added cloud apis for add and delete workspace * feat: add and delete workspace event handlers * chore: rust fmt * chore: save user workspace * test: add test * test: add test * chore: add to gitignore * feat: update api add name to workspace * chore: cargo clippy and rename to create * chore: add envrc and direnv to gitignore * chore: change name to create workspace instead of add workspace * chore: update client api rev * feat: add create workspace impl * chore: restore gitignore to original * test: fix create workspace event test * fix: change delete workspace input * fix: compile * fix: create workspace test * feat: add error code for request payload too large * chore: remove cargo backup files * feat: add is async option for upload file handler * chore: update client api version --------- Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
@ -2,3 +2,4 @@ mod anon_user_test;
|
||||
mod auth_test;
|
||||
mod import_af_data_folder_test;
|
||||
mod member_test;
|
||||
mod workspace_test;
|
||||
|
@ -0,0 +1,52 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use event_integration::user_event::user_localhost_af_cloud;
|
||||
use event_integration::EventIntegrationTest;
|
||||
use flowy_user::entities::RepeatedUserWorkspacePB;
|
||||
use flowy_user::protobuf::UserNotification;
|
||||
|
||||
use crate::util::receive_with_timeout;
|
||||
|
||||
#[tokio::test]
|
||||
async fn af_cloud_create_workspace_test() {
|
||||
user_localhost_af_cloud().await;
|
||||
let test = EventIntegrationTest::new().await;
|
||||
let user_profile_pb = test.af_cloud_sign_up().await;
|
||||
|
||||
let workspaces = test.get_all_workspaces().await.items;
|
||||
assert_eq!(workspaces.len(), 1);
|
||||
|
||||
test.create_workspace("my second workspace").await;
|
||||
let _workspaces = test.get_all_workspaces().await.items;
|
||||
|
||||
let a = user_profile_pb.id.to_string();
|
||||
let rx = test
|
||||
.notification_sender
|
||||
.subscribe::<RepeatedUserWorkspacePB>(&a, UserNotification::DidUpdateUserWorkspaces as i32);
|
||||
let workspaces = receive_with_timeout(rx, Duration::from_secs(30))
|
||||
.await
|
||||
.unwrap()
|
||||
.items;
|
||||
|
||||
assert_eq!(workspaces.len(), 2);
|
||||
assert_eq!(workspaces[1].name, "my second workspace".to_string());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn af_cloud_open_workspace_test() {
|
||||
user_localhost_af_cloud().await;
|
||||
let test = EventIntegrationTest::new().await;
|
||||
let _ = test.af_cloud_sign_up().await;
|
||||
|
||||
let workspace = test.create_workspace("my second workspace").await;
|
||||
test.open_workspace(&workspace.workspace_id).await;
|
||||
|
||||
test.create_document("my first document").await;
|
||||
test.create_document("my second document").await;
|
||||
|
||||
let views = test.get_all_workspace_views().await;
|
||||
assert_eq!(views.len(), 3);
|
||||
// the first view is the default get started view
|
||||
assert_eq!(views[1].name, "my first document".to_string());
|
||||
assert_eq!(views[2].name, "my second document".to_string());
|
||||
}
|
@ -1,13 +1,8 @@
|
||||
use nanoid::nanoid;
|
||||
|
||||
use crate::user::local_test::helper::*;
|
||||
use event_integration::{event_builder::EventBuilder, EventIntegrationTest};
|
||||
use flowy_user::entities::{AuthenticatorPB, UpdateUserProfilePayloadPB, UserProfilePB};
|
||||
use flowy_user::{errors::ErrorCode, event_map::UserEvent::*};
|
||||
|
||||
use crate::user::local_test::helper::*;
|
||||
|
||||
// use serial_test::*;
|
||||
|
||||
use nanoid::nanoid;
|
||||
#[tokio::test]
|
||||
async fn user_profile_get_failed() {
|
||||
let sdk = EventIntegrationTest::new().await;
|
||||
|
@ -388,9 +388,8 @@ async fn migrate_anon_data_on_cloud_signup() {
|
||||
json!("Row document")
|
||||
);
|
||||
}
|
||||
|
||||
assert!(cloud_service
|
||||
.get_collab_doc_state_db(&database_id, CollabType::Database, &workspace_id)
|
||||
.get_database_object_doc_state(&database_id, CollabType::Database, &workspace_id)
|
||||
.await
|
||||
.is_ok());
|
||||
}
|
||||
|
Reference in New Issue
Block a user