Skip to main content

max / makenotwork

1.5 KB · 45 lines History Blame Raw
1 //! Stripe disconnect workflow tests.
2
3 use crate::harness::TestHarness;
4
5 #[tokio::test]
6 async fn stripe_disconnect_requires_auth() {
7 let mut h = TestHarness::new().await;
8
9 let resp = h.client.delete("/api/users/me/stripe").await;
10 assert!(
11 resp.status.is_client_error() || resp.status.is_redirection(),
12 "Unauthenticated stripe disconnect should be rejected: {} {}",
13 resp.status, resp.text
14 );
15 }
16
17 #[tokio::test]
18 async fn stripe_disconnect_succeeds() {
19 let mut h = TestHarness::new().await;
20 let _user_id = h.signup("stripedisc", "stripedisc@test.com", "password123").await;
21
22 // User has no Stripe account connected, but disconnect should still succeed gracefully
23 let resp = h.client.delete("/api/users/me/stripe").await;
24 assert!(
25 resp.status.is_success() || resp.status == 204,
26 "Stripe disconnect should succeed: {} {}",
27 resp.status, resp.text
28 );
29 }
30
31 #[tokio::test]
32 async fn stripe_disconnect_idempotent() {
33 let mut h = TestHarness::new().await;
34 let _user_id = h.signup("stripetwice", "stripetwice@test.com", "password123").await;
35
36 // Disconnect twice — second call should also succeed
37 h.client.delete("/api/users/me/stripe").await;
38 let resp = h.client.delete("/api/users/me/stripe").await;
39 assert!(
40 resp.status.is_success() || resp.status == 204,
41 "Second stripe disconnect should also succeed: {} {}",
42 resp.status, resp.text
43 );
44 }
45