HX-Redirect to handle redirections with htmx
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::helpers::{TestApp, assert_is_redirect_to};
|
||||
|
||||
#[tokio::test]
|
||||
async fn an_error_flash_message_is_set_on_failure() {
|
||||
async fn an_error_html_fragment_is_returned_on_failure() {
|
||||
let app = TestApp::spawn().await;
|
||||
|
||||
let login_body = serde_json::json!({
|
||||
@@ -11,11 +11,10 @@ async fn an_error_flash_message_is_set_on_failure() {
|
||||
|
||||
let response = app.post_login(&login_body).await;
|
||||
|
||||
assert_eq!(response.status().as_u16(), 303);
|
||||
assert_is_redirect_to(&response, "/login");
|
||||
assert_eq!(response.status().as_u16(), 200);
|
||||
|
||||
let login_page_html = app.get_login_html().await;
|
||||
assert!(login_page_html.contains("Authentication failed"));
|
||||
let response_html = response.text().await.unwrap();
|
||||
assert!(response_html.contains("Invalid credentials"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -31,5 +30,6 @@ async fn login_redirects_to_admin_dashboard_after_login_success() {
|
||||
assert_is_redirect_to(&response, "/admin/dashboard");
|
||||
|
||||
let html_page = app.get_admin_dashboard_html().await;
|
||||
assert!(html_page.contains(&format!("Welcome {}", app.test_user.username)));
|
||||
assert!(html_page.contains("Connected as"));
|
||||
assert!(html_page.contains(&app.test_user.username));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user