More tests, not found page and dashboard fixes
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:
@@ -25,9 +25,32 @@ async fn logout_clears_session_state(connection_pool: PgPool) {
|
||||
assert!(html_page.contains("Connected as"));
|
||||
assert!(html_page.contains(&app.test_user.username));
|
||||
|
||||
let response = app.post_logout().await;
|
||||
let response = app.logout().await;
|
||||
assert_is_redirect_to(&response, "/login");
|
||||
|
||||
let response = app.get_admin_dashboard().await;
|
||||
assert_is_redirect_to(&response, "/login");
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
async fn subscribers_are_visible_on_the_dashboard(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
app.admin_login().await;
|
||||
|
||||
let response = app.get_admin_dashboard_html().await;
|
||||
assert!(response.contains("No data available"));
|
||||
|
||||
app.create_confirmed_subscriber().await;
|
||||
let subscriber = sqlx::query!("SELECT id, email FROM subscriptions")
|
||||
.fetch_one(&app.connection_pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let response = app.get_admin_dashboard_html().await;
|
||||
assert!(response.contains(&subscriber.email));
|
||||
|
||||
app.delete_subscriber(subscriber.id).await;
|
||||
let response = app.get_admin_dashboard_html().await;
|
||||
assert!(response.contains("No data available"));
|
||||
assert!(!response.contains(&subscriber.email));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user