AppFlowy-Cloud/tests/client/sign_up.rs

58 lines
1.6 KiB
Rust

use gotrue_entity::OAuthProvider;
use shared_entity::error_code::ErrorCode;
use crate::{
client::utils::{generate_unique_email, REGISTERED_USERS, REGISTERED_USERS_MUTEX},
client_api_client,
};
#[tokio::test]
async fn sign_up_success() {
let email = generate_unique_email();
let password = "Hello!123#";
let c = client_api_client();
c.sign_up(&email, password).await.unwrap();
}
#[tokio::test]
async fn sign_up_invalid_email() {
let invalid_email = "not_email_address";
let password = "Hello!123#";
let error = client_api_client()
.sign_up(invalid_email, password)
.await
.unwrap_err();
assert_eq!(error.code, ErrorCode::InvalidEmail);
assert_eq!(error.message, "invalid email: not_email_address");
}
#[tokio::test]
async fn sign_up_invalid_password() {
let email = generate_unique_email();
let password = "123";
let c = client_api_client();
let error = c.sign_up(&email, password).await.unwrap_err();
assert_eq!(error.code, ErrorCode::InvalidPassword);
assert_eq!(error.message, "invalid password: 123")
}
#[tokio::test]
async fn sign_up_but_existing_user() {
let _guard = REGISTERED_USERS_MUTEX.lock().await;
let c = client_api_client();
let user = &REGISTERED_USERS[0];
c.sign_up(&user.email, &user.password).await.unwrap();
}
#[tokio::test]
async fn sign_up_oauth_not_available() {
let c = client_api_client();
assert_eq!(
// Change Zoom to any other valid OAuth provider
// to manually open the browser and login
c.oauth_login(OAuthProvider::Zoom).await.err().unwrap().code,
ErrorCode::InvalidOAuthProvider
);
}