2021-07-06 06:14:47 +00:00
|
|
|
use flowy_test::prelude::*;
|
|
|
|
use flowy_user::prelude::*;
|
|
|
|
|
|
|
|
#[test]
|
2021-07-06 13:20:53 +00:00
|
|
|
fn sign_in_with_invalid_email() {
|
|
|
|
let test_cases = vec!["", "annie@", "annie@gmail@"];
|
|
|
|
let password = "Appflowy!123".to_string();
|
2021-07-06 06:14:47 +00:00
|
|
|
|
2021-07-06 13:20:53 +00:00
|
|
|
for email in test_cases {
|
|
|
|
let params = UserSignInParams {
|
|
|
|
email: email.to_string(),
|
|
|
|
password: password.clone(),
|
|
|
|
};
|
|
|
|
|
|
|
|
let _ = EventTester::new(SignIn)
|
|
|
|
.payload(params)
|
|
|
|
.assert_status_code(StatusCode::Err)
|
|
|
|
.sync_send();
|
|
|
|
}
|
2021-07-06 06:14:47 +00:00
|
|
|
}
|
|
|
|
|
2021-07-06 11:56:56 +00:00
|
|
|
#[test]
|
|
|
|
fn sign_in_with_invalid_password() {
|
2021-07-06 13:20:53 +00:00
|
|
|
let test_cases = vec!["".to_string(), "123456".to_owned(), "1234".repeat(100)];
|
|
|
|
let email = "annie@appflowy.io".to_string();
|
2021-07-06 11:56:56 +00:00
|
|
|
|
2021-07-06 13:20:53 +00:00
|
|
|
for password in test_cases {
|
|
|
|
let params = UserSignInParams {
|
|
|
|
email: email.clone(),
|
|
|
|
password,
|
|
|
|
};
|
|
|
|
|
|
|
|
let _ = EventTester::new(SignIn)
|
|
|
|
.payload(params)
|
|
|
|
.assert_status_code(StatusCode::Err)
|
|
|
|
.sync_send();
|
|
|
|
}
|
2021-07-06 11:56:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-06 06:14:47 +00:00
|
|
|
#[test]
|
2021-07-06 13:20:53 +00:00
|
|
|
fn sign_in_success() {
|
2021-07-06 06:14:47 +00:00
|
|
|
let params = UserSignInParams {
|
2021-07-06 13:20:53 +00:00
|
|
|
email: "annie@appflowy.io".to_string(),
|
2021-07-06 06:14:47 +00:00
|
|
|
password: "HelloWorld!123".to_string(),
|
|
|
|
};
|
|
|
|
|
|
|
|
let result = EventTester::new(SignIn)
|
|
|
|
.payload(params)
|
2021-07-06 13:20:53 +00:00
|
|
|
.assert_status_code(StatusCode::Ok)
|
|
|
|
.sync_send()
|
|
|
|
.parse::<UserSignInResult>();
|
2021-07-06 06:14:47 +00:00
|
|
|
dbg!(&result);
|
|
|
|
}
|