Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
Last test didn't check for correct metadata input during signup
  • Loading branch information
Proziam committed Jan 19, 2025
1 parent 8ab07f0 commit aac5ec4
Showing 1 changed file with 24 additions and 43 deletions.
67 changes: 24 additions & 43 deletions tests/client_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,57 +55,38 @@ async fn sign_up_with_email_test_valid() {
let demo_email = format!("signup__{}@demo.com", uuid);
let demo_password = "ciJUAojfZZYKfCxkiUWH";

let session = auth_client
.sign_up_with_email_and_password(demo_email.as_ref(), demo_password, None)
.await
.unwrap();

// Wait to prevent running into Supabase rate limits when running cargo test
let one_minute = time::Duration::from_secs(60);
thread::sleep(one_minute);

assert!(session.user.email == demo_email)
}

#[tokio::test]
async fn test_mobile_flow() {
let auth_client = create_test_client();

let demo_phone = env::var("DEMO_PHONE").unwrap();
let demo_password = env::var("DEMO_PASSWORD").unwrap();
let data = serde_json::json!({
"test": format!("test" ),
"name": format!("test" )
});

let options = SignUpWithPasswordOptions {
email_redirect_to: Some(String::from("a_random_url")),
data: Some(data),
..Default::default()
};

let session = auth_client
.sign_up_with_phone_and_password(&demo_phone, &demo_password, Some(options))
.await;

if session.is_err() {
eprintln!("{:?}", session.as_ref().unwrap_err())
}

assert!(session.is_ok());

let new_session = auth_client
.login_with_phone(&demo_phone, &demo_password)
.await;

if new_session.is_err() {
eprintln!("{:?}", new_session.as_ref().unwrap_err())
}

assert!(new_session.is_ok() && new_session.unwrap().user.phone == demo_phone);

let response = auth_client.send_sms_with_otp(&demo_phone).await;
.sign_up_with_email_and_password(demo_email.as_ref(), demo_password, Some(options))
.await
.unwrap();

if response.is_err() {
eprintln!("{:?}", response.as_ref().unwrap_err())
}
// Wait to prevent running into Supabase rate limits when running cargo test
let one_minute = time::Duration::from_secs(60);
thread::sleep(one_minute);

assert!(response.is_ok())
assert!(session.user.email == demo_email);
assert!(session.user.user_metadata.name.unwrap() == "test");
assert!(
session
.user
.user_metadata
.custom
.get("test")
.unwrap()
.as_str()
.unwrap()
== "test"
)
}

#[tokio::test]
Expand Down

0 comments on commit aac5ec4

Please sign in to comment.