feat: add test cases for inviting user
This commit is contained in:
parent
ce4b4c47a2
commit
deedaae34d
|
|
@ -408,20 +408,32 @@ impl Client {
|
|||
email: &str,
|
||||
password: &str,
|
||||
) -> Result<User, AppResponseError> {
|
||||
Ok(
|
||||
self
|
||||
.gotrue_client
|
||||
.admin_add_user(
|
||||
&self.access_token()?,
|
||||
&AdminUserParams {
|
||||
email: email.to_owned(),
|
||||
password: Some(password.to_owned()),
|
||||
email_confirm: true,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?,
|
||||
)
|
||||
let user = self
|
||||
.gotrue_client
|
||||
.admin_add_user(
|
||||
&self.access_token()?,
|
||||
&AdminUserParams {
|
||||
email: email.to_owned(),
|
||||
password: Some(password.to_owned()),
|
||||
email_confirm: true,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
Ok(user)
|
||||
}
|
||||
|
||||
// filter is postgre sql like filter
|
||||
#[instrument(level = "debug", skip_all, err)]
|
||||
pub async fn admin_list_users(
|
||||
&self,
|
||||
filter: Option<&str>,
|
||||
) -> Result<Vec<User>, AppResponseError> {
|
||||
let user = self
|
||||
.gotrue_client
|
||||
.admin_list_user(&self.access_token()?, filter)
|
||||
.await?;
|
||||
Ok(user.users)
|
||||
}
|
||||
|
||||
/// Only expose this method for testing
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use app_error::ErrorCode;
|
||||
use client_api_test_util::TestClient;
|
||||
use client_api_test_util::{admin_user_client, TestClient};
|
||||
use database_entity::dto::AFRole;
|
||||
use shared_entity::dto::workspace_dto::CreateWorkspaceMember;
|
||||
|
||||
|
|
@ -253,3 +253,34 @@ async fn get_user_workspace_info_after_open_workspace() {
|
|||
workspace_id_c1
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn add_workspace_member_not_exists() {
|
||||
let c1 = TestClient::new_user_without_ws_conn().await;
|
||||
let workspace_id_c1 = c1.workspace_id().await;
|
||||
let non_exist_email = format!("{}@appflowy.io", uuid::Uuid::new_v4());
|
||||
c1.api_client
|
||||
.add_workspace_members(
|
||||
&workspace_id_c1,
|
||||
vec![CreateWorkspaceMember {
|
||||
email: non_exist_email.clone(),
|
||||
role: AFRole::Member,
|
||||
}],
|
||||
)
|
||||
.await
|
||||
.expect("should be able to add member whose email not exists yet");
|
||||
|
||||
let admin_client = admin_user_client().await;
|
||||
let users = admin_client
|
||||
.admin_list_users(Some(&non_exist_email))
|
||||
.await
|
||||
.expect("should be able to list users");
|
||||
println!("---------non_exist_email: {}", non_exist_email);
|
||||
let non_exist_user = users
|
||||
.iter()
|
||||
.find(|u| u.email == non_exist_email)
|
||||
.expect("should find the user");
|
||||
|
||||
// since user does not exist and is just created, it should not be confirmed yet
|
||||
assert!(non_exist_user.confirmed_at.is_none());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue