mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
tests: more cloud test (#4204)
* test: add anon user test * chore: add to runner * test: fix * test: fix * test: add tests * chore: add test * chore: fix warn * chore: fix warn * fix: build * fix: test * chore: rename * chore: fix test * chore: fix test * chore: fix test * chore: disable test
This commit is contained in:
@ -1,9 +1,7 @@
|
||||
use event_integration::user_event::user_localhost_af_cloud;
|
||||
use event_integration::EventIntegrationTest;
|
||||
use flowy_core::DEFAULT_NAME;
|
||||
use flowy_user::entities::AuthTypePB;
|
||||
|
||||
use crate::util::{get_af_cloud_config, unzip_history_user_db};
|
||||
use crate::util::unzip_history_user_db;
|
||||
|
||||
#[tokio::test]
|
||||
async fn reading_039_anon_user_data_test() {
|
||||
@ -36,70 +34,43 @@ async fn reading_039_anon_user_data_test() {
|
||||
|
||||
drop(cleaner);
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn anon_user_to_af_cloud_test() {
|
||||
if get_af_cloud_config().is_none() {
|
||||
return;
|
||||
}
|
||||
let (cleaner, user_db_path) = unzip_history_user_db("./tests/asset", "039_local").unwrap();
|
||||
user_localhost_af_cloud().await;
|
||||
let test =
|
||||
EventIntegrationTest::new_with_user_data_path(user_db_path, DEFAULT_NAME.to_string()).await;
|
||||
let anon_first_level_views = test.get_all_workspace_views().await;
|
||||
let _anon_second_level_views = test
|
||||
.get_views(&anon_first_level_views[0].id)
|
||||
.await
|
||||
.child_views;
|
||||
|
||||
let user = test.af_cloud_sign_up().await;
|
||||
assert_eq!(user.auth_type, AuthTypePB::AFCloud);
|
||||
// let mut sync_state = test
|
||||
// .folder_manager
|
||||
// .get_mutex_folder()
|
||||
// .lock()
|
||||
// .as_ref()
|
||||
// .unwrap()
|
||||
// .subscribe_sync_state();
|
||||
//
|
||||
// // TODO(nathan): will be removed when supporting merge FolderData
|
||||
// // wait until the state is SyncFinished with 10 secs timeout
|
||||
// loop {
|
||||
// select! {
|
||||
// _ = tokio::time::sleep(Duration::from_secs(10)) => {
|
||||
// panic!("Timeout waiting for sync finished");
|
||||
// }
|
||||
// state = sync_state.next() => {
|
||||
// if let Some(state) = &state {
|
||||
// if state == &SyncState::SyncFinished {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// let user_first_level_views = test.get_all_workspace_views().await;
|
||||
// let user_second_level_views = test
|
||||
// .get_views(&user_first_level_views[1].id)
|
||||
// .await
|
||||
// .child_views;
|
||||
//
|
||||
// // first
|
||||
// assert_eq!(anon_first_level_views.len(), 1);
|
||||
// assert_eq!(user_first_level_views.len(), 2);
|
||||
// assert_eq!(
|
||||
// anon_first_level_views[0].name,
|
||||
// // The first one is the get started document
|
||||
// user_first_level_views[1].name
|
||||
// );
|
||||
// assert_ne!(anon_first_level_views[0].id, user_first_level_views[1].id);
|
||||
//
|
||||
// // second
|
||||
// assert_eq!(anon_second_level_views.len(), user_second_level_views.len());
|
||||
// assert_eq!(
|
||||
// anon_second_level_views[0].name,
|
||||
// user_second_level_views[0].name
|
||||
// );
|
||||
// assert_ne!(anon_second_level_views[0].id, user_second_level_views[0].id);
|
||||
drop(cleaner);
|
||||
}
|
||||
// #[tokio::test]
|
||||
// async fn migrate_anon_user_data_to_af_cloud_test() {
|
||||
// let (cleaner, user_db_path) = unzip_history_user_db("./tests/asset", "039_local").unwrap();
|
||||
// user_localhost_af_cloud().await;
|
||||
// let test =
|
||||
// EventIntegrationTest::new_with_user_data_path(user_db_path, DEFAULT_NAME.to_string()).await;
|
||||
// let anon_first_level_views = test.get_all_workspace_views().await;
|
||||
// let anon_second_level_views = test
|
||||
// .get_views(&anon_first_level_views[0].id)
|
||||
// .await
|
||||
// .child_views;
|
||||
//
|
||||
// // The anon user data will be migrated to the AppFlowy cloud after sign up
|
||||
// let user = test.af_cloud_sign_up().await;
|
||||
// assert_eq!(user.authenticator, AuthenticatorPB::AppFlowyCloud);
|
||||
//
|
||||
// let user_first_level_views = test.get_all_workspace_views().await;
|
||||
// let user_second_level_views = test
|
||||
// .get_views(&user_first_level_views[0].id)
|
||||
// .await
|
||||
// .child_views;
|
||||
//
|
||||
// // first
|
||||
// assert_eq!(anon_first_level_views.len(), 1);
|
||||
// assert_eq!(user_first_level_views.len(), 1);
|
||||
// assert_eq!(
|
||||
// anon_first_level_views[0].name,
|
||||
// user_first_level_views[0].name
|
||||
// );
|
||||
// assert_ne!(anon_first_level_views[0].id, user_first_level_views[0].id);
|
||||
//
|
||||
// // second
|
||||
// assert_eq!(anon_second_level_views.len(), user_second_level_views.len());
|
||||
// assert_eq!(
|
||||
// anon_second_level_views[0].name,
|
||||
// user_second_level_views[0].name
|
||||
// );
|
||||
// assert_ne!(anon_second_level_views[0].id, user_second_level_views[0].id);
|
||||
// drop(cleaner);
|
||||
// }
|
||||
|
@ -1,6 +1,6 @@
|
||||
use event_integration::user_event::{login_password, unique_email};
|
||||
use event_integration::{event_builder::EventBuilder, EventIntegrationTest};
|
||||
use flowy_user::entities::{AuthTypePB, SignInPayloadPB, SignUpPayloadPB};
|
||||
use flowy_user::entities::{AuthenticatorPB, SignInPayloadPB, SignUpPayloadPB};
|
||||
use flowy_user::errors::ErrorCode;
|
||||
use flowy_user::event_map::UserEvent::*;
|
||||
|
||||
@ -14,7 +14,7 @@ async fn sign_up_with_invalid_email() {
|
||||
email: email.to_string(),
|
||||
name: valid_name(),
|
||||
password: login_password(),
|
||||
auth_type: AuthTypePB::Local,
|
||||
auth_type: AuthenticatorPB::Local,
|
||||
device_id: "".to_string(),
|
||||
};
|
||||
|
||||
@ -38,7 +38,7 @@ async fn sign_up_with_long_password() {
|
||||
email: unique_email(),
|
||||
name: valid_name(),
|
||||
password: "1234".repeat(100).as_str().to_string(),
|
||||
auth_type: AuthTypePB::Local,
|
||||
auth_type: AuthenticatorPB::Local,
|
||||
device_id: "".to_string(),
|
||||
};
|
||||
|
||||
@ -63,7 +63,7 @@ async fn sign_in_with_invalid_email() {
|
||||
email: email.to_string(),
|
||||
password: login_password(),
|
||||
name: "".to_string(),
|
||||
auth_type: AuthTypePB::Local,
|
||||
auth_type: AuthenticatorPB::Local,
|
||||
device_id: "".to_string(),
|
||||
};
|
||||
|
||||
@ -90,7 +90,7 @@ async fn sign_in_with_invalid_password() {
|
||||
email: unique_email(),
|
||||
password,
|
||||
name: "".to_string(),
|
||||
auth_type: AuthTypePB::Local,
|
||||
auth_type: AuthenticatorPB::Local,
|
||||
device_id: "".to_string(),
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use nanoid::nanoid;
|
||||
|
||||
use event_integration::{event_builder::EventBuilder, EventIntegrationTest};
|
||||
use flowy_user::entities::{AuthTypePB, UpdateUserProfilePayloadPB, UserProfilePB};
|
||||
use flowy_user::entities::{AuthenticatorPB, UpdateUserProfilePayloadPB, UserProfilePB};
|
||||
use flowy_user::{errors::ErrorCode, event_map::UserEvent::*};
|
||||
|
||||
use crate::user::local_test::helper::*;
|
||||
@ -32,7 +32,7 @@ async fn anon_user_profile_get() {
|
||||
assert_eq!(user_profile.openai_key, user.openai_key);
|
||||
assert_eq!(user_profile.stability_ai_key, user.stability_ai_key);
|
||||
assert_eq!(user_profile.workspace_id, user.workspace_id);
|
||||
assert_eq!(user_profile.auth_type, AuthTypePB::Local);
|
||||
assert_eq!(user_profile.authenticator, AuthenticatorPB::Local);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
@ -14,7 +14,9 @@ use event_integration::EventIntegrationTest;
|
||||
use flowy_core::DEFAULT_NAME;
|
||||
use flowy_encrypt::decrypt_text;
|
||||
use flowy_server::supabase::define::{USER_DEVICE_ID, USER_EMAIL, USER_UUID};
|
||||
use flowy_user::entities::{AuthTypePB, OauthSignInPB, UpdateUserProfilePayloadPB, UserProfilePB};
|
||||
use flowy_user::entities::{
|
||||
AuthenticatorPB, OauthSignInPB, UpdateUserProfilePayloadPB, UserProfilePB,
|
||||
};
|
||||
use flowy_user::errors::ErrorCode;
|
||||
use flowy_user::event_map::UserEvent::*;
|
||||
|
||||
@ -33,7 +35,7 @@ async fn third_party_sign_up_test() {
|
||||
map.insert(USER_DEVICE_ID.to_string(), uuid::Uuid::new_v4().to_string());
|
||||
let payload = OauthSignInPB {
|
||||
map,
|
||||
auth_type: AuthTypePB::Supabase,
|
||||
auth_type: AuthenticatorPB::Supabase,
|
||||
};
|
||||
|
||||
let response = EventBuilder::new(test.clone())
|
||||
@ -77,7 +79,7 @@ async fn third_party_sign_up_with_duplicated_uuid() {
|
||||
.event(OauthSignIn)
|
||||
.payload(OauthSignInPB {
|
||||
map: map.clone(),
|
||||
auth_type: AuthTypePB::Supabase,
|
||||
auth_type: AuthenticatorPB::Supabase,
|
||||
})
|
||||
.async_send()
|
||||
.await
|
||||
@ -88,7 +90,7 @@ async fn third_party_sign_up_with_duplicated_uuid() {
|
||||
.event(OauthSignIn)
|
||||
.payload(OauthSignInPB {
|
||||
map: map.clone(),
|
||||
auth_type: AuthTypePB::Supabase,
|
||||
auth_type: AuthenticatorPB::Supabase,
|
||||
})
|
||||
.async_send()
|
||||
.await
|
||||
|
@ -4,7 +4,7 @@ use event_integration::{event_builder::EventBuilder, EventIntegrationTest};
|
||||
use flowy_folder2::entities::WorkspaceSettingPB;
|
||||
use flowy_folder2::event_map::FolderEvent::GetCurrentWorkspaceSetting;
|
||||
use flowy_server::supabase::define::{USER_EMAIL, USER_UUID};
|
||||
use flowy_user::entities::{AuthTypePB, OauthSignInPB, UserProfilePB};
|
||||
use flowy_user::entities::{AuthenticatorPB, OauthSignInPB, UserProfilePB};
|
||||
use flowy_user::event_map::UserEvent::*;
|
||||
|
||||
use crate::util::*;
|
||||
@ -21,7 +21,7 @@ async fn initial_workspace_test() {
|
||||
);
|
||||
let payload = OauthSignInPB {
|
||||
map,
|
||||
auth_type: AuthTypePB::Supabase,
|
||||
auth_type: AuthenticatorPB::Supabase,
|
||||
};
|
||||
|
||||
let _ = EventBuilder::new(test.clone())
|
||||
|
Reference in New Issue
Block a user