More tests, not found page and dashboard fixes
When post was deleted, website shows a 404 page insead of an 500 page. Also made the dashboard empty page message more explicit.
This commit is contained in:
@@ -22,11 +22,7 @@ async fn you_must_be_logged_in_to_change_your_password(connection_pool: PgPool)
|
||||
async fn new_password_fields_must_match(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
app.post_login(&serde_json::json!({
|
||||
"username": app.test_user.username,
|
||||
"password": app.test_user.password,
|
||||
}))
|
||||
.await;
|
||||
app.admin_login().await;
|
||||
|
||||
let new_password = Uuid::new_v4().to_string();
|
||||
let another_new_password = Uuid::new_v4().to_string();
|
||||
@@ -47,11 +43,7 @@ async fn new_password_fields_must_match(connection_pool: PgPool) {
|
||||
async fn current_password_is_invalid(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
app.post_login(&serde_json::json!({
|
||||
"username": app.test_user.username,
|
||||
"password": app.test_user.password,
|
||||
}))
|
||||
.await;
|
||||
app.admin_login().await;
|
||||
|
||||
let new_password = Uuid::new_v4().to_string();
|
||||
let response = app
|
||||
@@ -70,13 +62,7 @@ async fn current_password_is_invalid(connection_pool: PgPool) {
|
||||
#[sqlx::test]
|
||||
async fn changing_password_works(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
let login_body = &serde_json::json!({
|
||||
"username": app.test_user.username,
|
||||
"password": app.test_user.password,
|
||||
});
|
||||
let response = app.post_login(login_body).await;
|
||||
assert_is_redirect_to(&response, "/admin/dashboard");
|
||||
app.admin_login().await;
|
||||
|
||||
let new_password = Uuid::new_v4().to_string();
|
||||
let response = app
|
||||
@@ -91,7 +77,7 @@ async fn changing_password_works(connection_pool: PgPool) {
|
||||
let html_page_fragment = response.text().await.unwrap();
|
||||
assert!(html_page_fragment.contains("Your password has been changed"));
|
||||
|
||||
let response = app.post_logout().await;
|
||||
let response = app.logout().await;
|
||||
assert_is_redirect_to(&response, "/login");
|
||||
|
||||
let login_body = &serde_json::json!({
|
||||
|
||||
Reference in New Issue
Block a user