Profile update tests

This commit is contained in:
Alphonse Paix
2025-10-07 23:07:16 +02:00
parent 0b402c6259
commit 3bfac6d012
4 changed files with 242 additions and 5 deletions

View File

@@ -375,6 +375,30 @@ impl TestApp {
.expect("Failed to execute request")
}
pub async fn edit_profile<Body>(&self, body: &Body) -> reqwest::Response
where
Body: serde::Serialize,
{
self.api_client
.put(format!("{}/users/edit", self.address))
.form(body)
.send()
.await
.expect("Failed to execute request")
}
pub async fn get_profile(&self, username: &str) -> reqwest::Response {
self.api_client
.get(format!("{}/users/{}", self.address, username))
.send()
.await
.expect("Failed to execute request")
}
pub async fn get_profile_html(&self, username: &str) -> String {
self.get_profile(username).await.text().await.unwrap()
}
pub async fn post_create_post<Body>(&self, body: &Body) -> reqwest::Response
where
Body: serde::Serialize,
@@ -426,6 +450,14 @@ impl TestApp {
.await
.expect("Failed to execute request")
}
pub async fn get_user_id(&self, username: &str) -> Uuid {
let record = sqlx::query!("SELECT user_id FROM users WHERE username = $1", username)
.fetch_one(&self.connection_pool)
.await
.unwrap();
record.user_id
}
}
pub fn assert_is_redirect_to(response: &reqwest::Response, location: &str) {