//! Preferences workflow tests: update notification preferences. use crate::harness::TestHarness; #[tokio::test] async fn preferences_requires_auth() { let mut h = TestHarness::new().await; let resp = h .client .put_form("/api/users/me/preferences", "notify_sale=on") .await; assert!( resp.status.is_client_error() || resp.status.is_redirection(), "Unauthenticated preferences update should be rejected: {} {}", resp.status, resp.text ); } #[tokio::test] async fn preferences_enable_all() { let mut h = TestHarness::new().await; let _user_id = h.signup("prefall", "prefall@test.com", "password123").await; let resp = h .client .put_form( "/api/users/me/preferences", "notify_sale=on¬ify_follower=on¬ify_release=on&login_notification_enabled=on", ) .await; assert!( resp.status.is_success(), "Enable all preferences should succeed: {} {}", resp.status, resp.text ); } #[tokio::test] async fn preferences_disable_all() { let mut h = TestHarness::new().await; let _user_id = h.signup("prefdis", "prefdis@test.com", "password123").await; // Omitting all fields = all false (HTML checkbox behavior) let resp = h .client .put_form("/api/users/me/preferences", "") .await; assert!( resp.status.is_success(), "Disable all preferences should succeed: {} {}", resp.status, resp.text ); } #[tokio::test] async fn preferences_partial_update() { let mut h = TestHarness::new().await; let _user_id = h.signup("prefpart", "prefpart@test.com", "password123").await; // Only enable sale notifications let resp = h .client .put_form("/api/users/me/preferences", "notify_sale=on") .await; assert!( resp.status.is_success(), "Partial preferences update should succeed: {} {}", resp.status, resp.text ); }