2021-07-11 07:33:19 +00:00
|
|
|
use crate::helper::*;
|
2021-07-14 13:12:52 +00:00
|
|
|
|
|
|
|
use flowy_user::{errors::UserErrorCode, event::UserEvent::*, prelude::*};
|
2021-07-11 13:54:55 +00:00
|
|
|
use serial_test::*;
|
2021-07-14 13:12:52 +00:00
|
|
|
|
2021-07-11 07:33:19 +00:00
|
|
|
#[test]
|
2021-07-11 09:38:03 +00:00
|
|
|
#[should_panic]
|
2021-07-11 13:54:55 +00:00
|
|
|
#[serial]
|
2021-07-11 09:38:03 +00:00
|
|
|
fn user_status_not_found_before_login() {
|
2021-07-14 00:23:35 +00:00
|
|
|
let _ = UserEventTester::new(SignOut).sync_send();
|
|
|
|
let _ = UserEventTester::new(GetStatus)
|
2021-07-11 09:38:03 +00:00
|
|
|
.sync_send()
|
|
|
|
.parse::<UserDetail>();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-07-11 13:54:55 +00:00
|
|
|
#[serial]
|
2021-07-11 09:38:03 +00:00
|
|
|
fn user_status_did_found_after_login() {
|
2021-07-14 00:23:35 +00:00
|
|
|
let _ = UserEventTester::new(SignOut).sync_send();
|
2021-07-11 09:38:03 +00:00
|
|
|
let request = SignInRequest {
|
|
|
|
email: valid_email(),
|
|
|
|
password: valid_password(),
|
|
|
|
};
|
|
|
|
|
2021-07-14 00:23:35 +00:00
|
|
|
let response = UserEventTester::new(SignIn)
|
2021-07-11 09:38:03 +00:00
|
|
|
.request(request)
|
|
|
|
.sync_send()
|
|
|
|
.parse::<UserDetail>();
|
|
|
|
dbg!(&response);
|
|
|
|
|
2021-07-14 00:23:35 +00:00
|
|
|
let _ = UserEventTester::new(GetStatus)
|
2021-07-11 09:38:03 +00:00
|
|
|
.sync_send()
|
|
|
|
.parse::<UserDetail>();
|
|
|
|
}
|
2021-07-14 13:12:52 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[serial]
|
|
|
|
fn user_update_with_invalid_email() {
|
|
|
|
let _ = UserEventTester::new(SignOut).sync_send();
|
|
|
|
let request = SignInRequest {
|
|
|
|
email: valid_email(),
|
|
|
|
password: valid_password(),
|
|
|
|
};
|
|
|
|
|
|
|
|
let _ = UserEventTester::new(SignIn)
|
|
|
|
.request(request)
|
|
|
|
.sync_send()
|
|
|
|
.parse::<UserDetail>();
|
|
|
|
|
|
|
|
let user_detail = UserEventTester::new(GetStatus)
|
|
|
|
.sync_send()
|
|
|
|
.parse::<UserDetail>();
|
|
|
|
|
|
|
|
for email in invalid_email_test_case() {
|
|
|
|
let request = UpdateUserRequest {
|
|
|
|
id: user_detail.id.clone(),
|
|
|
|
name: None,
|
|
|
|
email: Some(email),
|
|
|
|
workspace: None,
|
|
|
|
password: None,
|
|
|
|
};
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
UserEventTester::new(UpdateUser)
|
|
|
|
.request(request)
|
|
|
|
.sync_send()
|
|
|
|
.error()
|
|
|
|
.code,
|
|
|
|
UserErrorCode::EmailInvalid
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|