Test suite refactoring to match new htmx HTML swapping in pages
This commit is contained in:
@@ -1,15 +1,5 @@
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::helpers::{TestApp, assert_is_redirect_to};
|
||||
|
||||
#[tokio::test]
|
||||
async fn you_must_be_logged_in_to_see_the_change_password_form() {
|
||||
let app = TestApp::spawn().await;
|
||||
|
||||
let response = app.get_change_password().await;
|
||||
|
||||
assert_is_redirect_to(&response, "/login");
|
||||
}
|
||||
use uuid::Uuid;
|
||||
|
||||
#[tokio::test]
|
||||
async fn you_must_be_logged_in_to_change_your_password() {
|
||||
@@ -46,10 +36,10 @@ async fn new_password_fields_must_match() {
|
||||
"new_password_check": another_new_password,
|
||||
}))
|
||||
.await;
|
||||
assert_is_redirect_to(&response, "/admin/password");
|
||||
assert!(response.status().is_success());
|
||||
|
||||
let html_page = app.get_change_password_html().await;
|
||||
assert!(html_page.contains("You entered two different passwords"));
|
||||
let html_fragment = response.text().await.unwrap();
|
||||
assert!(html_fragment.contains("You entered two different passwords"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -70,10 +60,10 @@ async fn current_password_is_invalid() {
|
||||
"new_password_check": new_password,
|
||||
}))
|
||||
.await;
|
||||
assert_is_redirect_to(&response, "/admin/password");
|
||||
assert!(response.status().is_success());
|
||||
|
||||
let html_page = app.get_change_password_html().await;
|
||||
assert!(html_page.contains("The current password is incorrect"));
|
||||
let html_fragment = response.text().await.unwrap();
|
||||
assert!(html_fragment.contains("The current password is incorrect"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -95,17 +85,14 @@ async fn changing_password_works() {
|
||||
"new_password_check": new_password,
|
||||
}))
|
||||
.await;
|
||||
assert_is_redirect_to(&response, "/admin/password");
|
||||
assert!(response.status().is_success());
|
||||
|
||||
let html_page = app.get_change_password_html().await;
|
||||
assert!(html_page.contains("Your password has been changed"));
|
||||
let html_page_fragment = response.text().await.unwrap();
|
||||
assert!(html_page_fragment.contains("Your password has been changed"));
|
||||
|
||||
let response = app.post_logout().await;
|
||||
assert_is_redirect_to(&response, "/login");
|
||||
|
||||
let html_page = app.get_login_html().await;
|
||||
assert!(html_page.contains("You have successfully logged out"));
|
||||
|
||||
let login_body = &serde_json::json!({
|
||||
"username": app.test_user.username,
|
||||
"password": new_password,
|
||||
|
||||
Reference in New Issue
Block a user