Skip to content

Commit

Permalink
add timeout err catch
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbowen committed Dec 23, 2024
1 parent dfe6e33 commit 6cfaee9
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions e2e_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,17 @@ def create_user_page(
# so that multiple browser flags in cli are honoured
def _create_user_page(username, password) -> Page:
page.goto("/sign-in", timeout=10000)
page.wait_for_timeout(10000)
page.get_by_label("Email address").fill(username)
page.get_by_label("Password").fill(password)
page.get_by_role("button", name="Sign in").click()

# keycloak local
# page.get_by_label("Username or email").click()
# page.get_by_label("Username or email").fill(username)
# page.get_by_label("Password", exact=True).click()
# page.get_by_label("Password", exact=True).fill(password)
# page.get_by_role("button", name="Sign In").click()
return page

return _create_user_page
Expand Down Expand Up @@ -95,17 +103,28 @@ def _create_keycloak_user(groups, user_type):
user_pass = uuid.uuid4().hex
user_first_name = "Test"
user_last_name = "Name"
user_id = keycloak_admin.create_user(
{
"firstName": user_first_name,
"lastName": user_last_name,
"username": user_email,
"email": user_email,
"enabled": True,
"groups": groups,
"credentials": [{"value": user_pass, "type": "password"}],
}
)
user_id = None # Initialize user_id to avoid UnboundLocalError

try:
user_id = keycloak_admin.create_user(
{
"firstName": user_first_name,
"lastName": user_last_name,
"username": user_email,
"email": user_email,
"enabled": True,
"groups": groups,
"credentials": [{"value": user_pass, "type": "password"}],
}
)
except Exception as e:
print(f"Error creating user: {e}")
raise # Re-raise the exception to fail the test

if not user_id:
raise ValueError("User creation failed; no user ID returned.")

print(f"Created user with ID: {user_id}, email: {user_email}")
return user_id, user_email, user_pass

return _create_keycloak_user
Expand Down

0 comments on commit 6cfaee9

Please sign in to comment.