Skip to main content

max / makenotwork

1.5 KB · 52 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,
14 resp.text
15 );
16 }
17
18 #[tokio::test]
19 async fn stripe_disconnect_succeeds() {
20 let mut h = TestHarness::new().await;
21 let _user_id = h
22 .signup("stripedisc", "stripedisc@test.com", "password123")
23 .await;
24
25 // User has no Stripe account connected, but disconnect should still succeed gracefully
26 let resp = h.client.delete("/api/users/me/stripe").await;
27 assert!(
28 resp.status.is_success() || resp.status == 204,
29 "Stripe disconnect should succeed: {} {}",
30 resp.status,
31 resp.text
32 );
33 }
34
35 #[tokio::test]
36 async fn stripe_disconnect_idempotent() {
37 let mut h = TestHarness::new().await;
38 let _user_id = h
39 .signup("stripetwice", "stripetwice@test.com", "password123")
40 .await;
41
42 // Disconnect twice, second call should also succeed
43 h.client.delete("/api/users/me/stripe").await;
44 let resp = h.client.delete("/api/users/me/stripe").await;
45 assert!(
46 resp.status.is_success() || resp.status == 204,
47 "Second stripe disconnect should also succeed: {} {}",
48 resp.status,
49 resp.text
50 );
51 }
52