Test suite refactoring to match new htmx HTML swapping in pages
This commit is contained in:
@@ -6,7 +6,10 @@ use linkify::LinkFinder;
|
||||
use once_cell::sync::Lazy;
|
||||
use sqlx::{Connection, Executor, PgConnection, PgPool};
|
||||
use uuid::Uuid;
|
||||
use wiremock::MockServer;
|
||||
use wiremock::{
|
||||
Mock, MockBuilder, MockServer,
|
||||
matchers::{method, path},
|
||||
};
|
||||
use zero2prod::{
|
||||
configuration::{DatabaseSettings, get_configuration},
|
||||
email_client::EmailClient,
|
||||
@@ -149,17 +152,6 @@ impl TestApp {
|
||||
ConfirmationLinks { html, text }
|
||||
}
|
||||
|
||||
pub async fn get_login_html(&self) -> String {
|
||||
self.api_client
|
||||
.get(format!("{}/login", &self.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request")
|
||||
.text()
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub async fn get_admin_dashboard(&self) -> reqwest::Response {
|
||||
self.api_client
|
||||
.get(format!("{}/admin/dashboard", &self.address))
|
||||
@@ -172,29 +164,6 @@ impl TestApp {
|
||||
self.get_admin_dashboard().await.text().await.unwrap()
|
||||
}
|
||||
|
||||
pub async fn get_register_html(&self) -> String {
|
||||
self.api_client
|
||||
.get(format!("{}/register", &self.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request")
|
||||
.text()
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub async fn get_change_password(&self) -> reqwest::Response {
|
||||
self.api_client
|
||||
.get(format!("{}/admin/password", &self.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request")
|
||||
}
|
||||
|
||||
pub async fn get_change_password_html(&self) -> String {
|
||||
self.get_change_password().await.text().await.unwrap()
|
||||
}
|
||||
|
||||
pub async fn post_subscriptions(&self, body: String) -> reqwest::Response {
|
||||
self.api_client
|
||||
.post(format!("{}/subscriptions", self.address))
|
||||
@@ -205,18 +174,6 @@ impl TestApp {
|
||||
.expect("Failed to execute request")
|
||||
}
|
||||
|
||||
pub async fn get_newsletter_form(&self) -> reqwest::Response {
|
||||
self.api_client
|
||||
.get(format!("{}/admin/password", &self.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request")
|
||||
}
|
||||
|
||||
pub async fn get_newsletter_form_html(&self) -> String {
|
||||
self.get_newsletter_form().await.text().await.unwrap()
|
||||
}
|
||||
|
||||
pub async fn post_newsletters<Body>(&self, body: &Body) -> reqwest::Response
|
||||
where
|
||||
Body: serde::Serialize,
|
||||
@@ -291,6 +248,11 @@ async fn configure_database(config: &DatabaseSettings) -> PgPool {
|
||||
}
|
||||
|
||||
pub fn assert_is_redirect_to(response: &reqwest::Response, location: &str) {
|
||||
assert_eq!(response.status().as_u16(), 303);
|
||||
assert_eq!(response.headers().get("Location").unwrap(), location);
|
||||
dbg!(&response);
|
||||
assert_eq!(response.status().as_u16(), 200);
|
||||
assert_eq!(response.headers().get("hx-redirect").unwrap(), location);
|
||||
}
|
||||
|
||||
pub fn when_sending_an_email() -> MockBuilder {
|
||||
Mock::given(path("/email")).and(method("POST"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user