Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update e2e tests #710

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 34 additions & 13 deletions e2e_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def utils():

@pytest.fixture
def page(page, request) -> Page:
page.context.set_default_timeout(5000)
page.context.set_default_timeout(10000)
page.set_default_timeout(10000)
if "test_css_" not in request.node.name and callable(request.node.obj):

def route_intercept(route):
Expand All @@ -55,10 +56,19 @@ def create_user_page(
): # FIXME: browser_name specified until https://github.com/microsoft/playwright-pytest/issues/172 fixed
# so that multiple browser flags in cli are honoured
def _create_user_page(username, password) -> Page:
page.goto("/sign-in")
page.wait_for_timeout(10000)
page.set_default_timeout(10000)
page.goto("/sign-in", 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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove the comments

# 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 @@ -94,17 +104,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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this block ever get hit if you raise the exception above?

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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def test_search_to_record(aau_user_page: Page):

aau_user_page.get_by_role("textbox").first.fill("a")
aau_user_page.get_by_role("button", name="Search").click()
expect(aau_user_page).to_have_url("search_results_summary?query=a")
expect(aau_user_page).to_have_url(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this test is the one about nvaigating to a record i na search journey.

I think the tests in class TestSearchResultsSummary: (and possible the other test classes there) in e2e_tests/test_search.py would still be broken though, will those be done in a separate PR?

We just need to make sure that we cover the 2 ac in the ticket: https://national-archives.atlassian.net/jira/software/projects/AYR/boards/66?selectedIssue=AYR-1236&text=AYR-1236

The AC do have 2 actions and currently that file splits out these scenarios into 2 test classes with the second starting from the summary results page, but do whatever feels best to you.

"search_results_summary?query=a&search_area=everywhere"
)

aau_user_page.get_by_role("cell").first.get_by_role("link").first.click()
expect(aau_user_page).to_have_url(
Expand Down
Loading