More tests, not found page and dashboard fixes
Some checks failed
Rust / Test (push) Has been cancelled
Rust / Rustfmt (push) Has been cancelled
Rust / Clippy (push) Has been cancelled
Rust / Code coverage (push) Has been cancelled

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:
Alphonse Paix
2025-09-26 20:31:30 +02:00
parent 0f6b479af9
commit f9ae3f42a6
10 changed files with 233 additions and 48 deletions

View File

@@ -160,6 +160,17 @@ impl TestApp {
.unwrap();
}
pub async fn delete_subscriber(&self, subscriber_id: Uuid) {
self.api_client
.delete(format!(
"{}/admin/subscribers/{}",
self.address, subscriber_id
))
.send()
.await
.expect("Could not delete subscriber");
}
pub async fn dispatch_all_pending_emails(&self) {
loop {
if let ExecutionOutcome::EmptyQueue =
@@ -228,6 +239,30 @@ impl TestApp {
self.get_admin_dashboard().await.text().await.unwrap()
}
pub async fn get_posts(&self) -> reqwest::Response {
self.api_client
.get(format!("{}/posts", &self.address))
.send()
.await
.expect("Failed to execute request")
}
pub async fn get_posts_html(&self) -> String {
self.get_posts().await.text().await.unwrap()
}
pub async fn get_post(&self, post_id: Uuid) -> reqwest::Response {
self.api_client
.get(format!("{}/posts/{}", &self.address, post_id))
.send()
.await
.expect("Failed to execute request")
}
pub async fn get_post_html(&self, post_id: Uuid) -> String {
self.get_post(post_id).await.text().await.unwrap()
}
pub async fn post_subscriptions(&self, body: String) -> reqwest::Response {
self.api_client
.post(format!("{}/subscriptions", self.address))
@@ -270,9 +305,9 @@ impl TestApp {
self.post_login(&login_body).await;
}
pub async fn post_logout(&self) -> reqwest::Response {
pub async fn logout(&self) -> reqwest::Response {
self.api_client
.post(format!("{}/admin/logout", self.address))
.get(format!("{}/admin/logout", self.address))
.send()
.await
.expect("Failed to execute request")
@@ -302,6 +337,14 @@ impl TestApp {
.expect("Failed to execute request")
}
pub async fn delete_post(&self, post_id: Uuid) {
self.api_client
.delete(format!("{}/admin/posts/{}", self.address, post_id))
.send()
.await
.expect("Could not delete post");
}
pub async fn post_unsubscribe<Body>(&self, body: &Body) -> reqwest::Response
where
Body: serde::Serialize,