Merge branch 'main' of https://github.com/GSA/notifications-admin into 2133-small-a11y-updates

This commit is contained in:
Jonathan Bobel
2024-12-17 11:34:30 -05:00
23 changed files with 1147 additions and 1014 deletions

View File

@@ -20,21 +20,14 @@ def test_non_logged_in_user_can_see_homepage(
"Reach people where they are with government-powered text messages"
)
assert (
page.select_one(
"a.usa-button.login-button.login-button--primary.margin-right-2"
).text
== "Sign in with \n"
# Assert the entire HTML of the button to include the image
button = page.select_one(
"a.usa-button.login-button.login-button--primary.margin-right-2"
)
assert page.select_one("meta[name=description]") is not None
# This area is hidden for the pilot
# assert normalize_spaces(page.select_one('#whos-using-notify').text) == (
# 'Whos using Notify.gov ' # Hiding this next area for the pilot
# # Hiding this next area for the pilot
# # 'See the list of services and organizations. '
# 'There are 111 Organizations and 9,999 Services using Notify.'
# )
assert "Sign in with" in button.text.strip() # Assert button text
assert button.find("img")["alt"] == "Login.gov logo" # Assert image presence
assert page.select_one("meta[name=description]") is not None
assert page.select_one("#whos-using-notify a") is None
@@ -125,7 +118,7 @@ def test_static_pages(client_request, mock_get_organization_by_domain, view, moc
"write_for_action",
"multiple_languages",
"benchmark_performance",
"guidance_index"
"guidance_index",
]
return (
not current_app.config["FEATURE_BEST_PRACTICES_ENABLED"]

View File

@@ -350,9 +350,13 @@ def test_should_show_templates_folder_page(
assert normalize_spaces(page.select_one("h1").text) == expected_title_tag
# remove this line if you don't want the breadcrumb on the first page
assert len(page.select("nav#breadcrumb-template-folders a")) == len(expected_parent_link_args)
assert len(page.select("nav#breadcrumb-template-folders a")) == len(
expected_parent_link_args
)
for index, parent_link in enumerate(page.select("nav#breadcrumb-template-folders a")):
for index, parent_link in enumerate(
page.select("nav#breadcrumb-template-folders a")
):
assert parent_link["href"] == url_for(
"main.choose_template",
service_id=SERVICE_ONE_ID,

View File

@@ -69,7 +69,9 @@ def test_should_show_empty_page_when_no_templates(
service_id=service_one["id"],
)
assert normalize_spaces(page.select_one("h1").text) == ("Select or create a template")
assert normalize_spaces(page.select_one("h1").text) == (
"Select or create a template"
)
assert normalize_spaces(page.select_one("main p").text) == (expected_message)
assert page.select_one("#add_new_folder_form")
assert page.select_one("#add_new_template_form")
@@ -87,7 +89,9 @@ def test_should_show_add_template_form_if_service_has_folder_permission(
service_id=service_one["id"],
)
assert normalize_spaces(page.select_one("h1").text) == ("Select or create a template")
assert normalize_spaces(page.select_one("h1").text) == (
"Select or create a template"
)
assert normalize_spaces(page.select_one("main p").text) == (
"Every message starts with a template. You can change it later. "
"You need a template before you can send messages."

View File

@@ -125,6 +125,7 @@ EXCLUDED_ENDPOINTS = tuple(
"integration_testing",
"invite_org_user",
"invite_user",
"join_notify",
"link_service_to_organization",
"live_services",
"live_services_csv",

View File

@@ -26,149 +26,24 @@ def test_landing_page(end_to_end_context):
name="Reach people where they are with government-powered text messages",
)
sign_in_button = page.get_by_role("link", name="Sign in with")
benefits_studio_email = page.get_by_role("link", name="tts-benefits-studio@gsa.gov")
# Check to make sure the elements are visible.
expect(main_header).to_be_visible()
expect(sign_in_button).to_be_visible()
expect(benefits_studio_email).to_be_visible()
# Check to make sure the sign-in button and email links are correct.
href_value = sign_in_button.get_attribute("href")
assert href_value is not None, "The sign-in button does not have an href attribute"
expect(benefits_studio_email).to_have_attribute(
"href", "mailto:tts-benefits-studio@gsa.gov"
)
# Retrieve all other main content headers and check that they're
# visible.
content_headers = [
"Control your content",
"See how your messages perform",
"No technical integration needed",
"About the product",
"Government texting made easy",
"Key features",
"Who can use Notify.gov",
]
for content_header in content_headers:
expect(
page.get_by_role("heading", name=re.compile(content_header))
).to_be_visible()
# def test_sign_in_and_mfa_pages(end_to_end_context):
# # Open a new page and go to the staging site.
# page = end_to_end_context.new_page()
# page.goto(f"{E2E_TEST_URI}/")
# print(f"test_sign_in_and_mfa_pages initial {page}")
#
# sign_in_button = page.get_by_role("link", name="Sign in")
#
# # Test trying to sign in.
# sign_in_button.click()
#
# # Check to make sure that we've arrived at the next page.
# page.wait_for_load_state("domcontentloaded")
#
# # Check the page title exists and matches what we expect.
# expect(page).to_have_title(re.compile("Sign in"))
#
# # Check for the sign in heading.
# sign_in_heading = page.get_by_role("heading", name="Sign in")
# expect(sign_in_heading).to_be_visible()
#
# # Check for the sign in form elements.
# # NOTE: Playwright cannot find input elements by role and recommends using
# # get_by_label() instead; however, hidden form elements do not have
# # labels associated with them, hence the XPath!
# # See https://playwright.dev/python/docs/api/class-page#page-get-by-label
# # and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath
# # for more information.
# email_address_input = page.get_by_label("Email address")
# password_input = page.get_by_label("Password")
# csrf_token = page.locator('xpath=//input[@name="csrf_token"]')
# continue_button = page.get_by_role("button", name=re.compile("Continue"))
# forgot_password_link = page.get_by_role("link", name="Forgot your password?")
#
# # Make sure form elements are visible and not visible as expected.
# expect(email_address_input).to_be_visible()
# expect(password_input).to_be_visible()
# expect(continue_button).to_be_visible()
# expect(forgot_password_link).to_be_visible()
#
# expect(csrf_token).to_be_hidden()
#
# # Make sure form elements are configured correctly with the right
# # attributes.
# expect(email_address_input).to_have_attribute("type", "email")
# expect(password_input).to_have_attribute("type", "password")
# expect(csrf_token).to_have_attribute("type", "hidden")
# expect(continue_button).to_have_attribute("type", "submit")
# expect(forgot_password_link).to_have_attribute("href", "/forgot-password")
#
# # Sign in to the site.
# email_address_input.fill(os.getenv("NOTIFY_E2E_TEST_EMAIL"))
# password_input.fill(os.getenv("NOTIFY_E2E_TEST_PASSWORD"))
# print(f"email and password {os.getenv('NOTIFY_E2E_TEST_EMAIL')} {os.getenv('NOTIFY_E2E_TEST_PASSWORD')}")
# continue_button.click()
#
# # Wait for the next page to fully load.
# page.wait_for_load_state("domcontentloaded")
#
# # Check the page title exists and matches what we expect.
# print(f"test_sign_in_and_mfa_pages finally is {page}")
# expect(page).to_have_title(re.compile("Check your phone"))
#
# # Check for the sign in heading.
# sign_in_heading = page.get_by_role("heading", name="Check your phone")
# expect(sign_in_heading).to_be_visible()
#
# # Check for the sign in form elements.
# # NOTE: Playwright cannot find input elements by role and recommends using
# # get_by_label() instead; however, hidden form elements do not have
# # labels associated with them, hence the XPath!
# # See https://playwright.dev/python/docs/api/class-page#page-get-by-label
# # and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath
# # for more information.
# mfa_input = page.get_by_label("Text message code")
# csrf_token = page.locator('xpath=//input[@name="csrf_token"]')
# continue_button = page.get_by_role("button", name=re.compile("Continue"))
# not_received_message_link = page.get_by_role(
# "link", name="Not received a text message?"
# )
#
# # Make sure form elements are visible and not visible as expected.
# expect(mfa_input).to_be_visible()
# expect(continue_button).to_be_visible()
# expect(not_received_message_link).to_be_visible()
#
# expect(csrf_token).to_be_hidden()
#
# # Make sure form elements are configured correctly with the right
# # attributes.
# expect(mfa_input).to_have_attribute("type", "tel")
# expect(mfa_input).to_have_attribute("pattern", "[0-9]*")
# expect(csrf_token).to_have_attribute("type", "hidden")
# expect(continue_button).to_have_attribute("type", "submit")
# expect(not_received_message_link).to_have_attribute("href", "/text-not-received")
#
# # Enter MFA code and continue.
# # TODO: Revisit this at a later point in time.
# # totp = pyotp.TOTP(
# # os.getenv('MFA_TOTP_SECRET'),
# # digits=int(os.getenv('MFA_TOTP_LENGTH'))
# # )
#
# # mfa_input.fill('totp.now()')
# # continue_button.click()
#
# # # Check to make sure that we've arrived at the next page.
# # page.wait_for_load_state('domcontentloaded')
#
# # # Check that no MFA code error happened.
# # code_not_found_error = page.get_by_text('Code not found')
# # expect(code_not_found_error).to_have_count(0)
#
# # # Check the page title exists and matches what we expect.
# # # This could be either the Dashboard of a service if there is only
# # # one, or choosing a service if there are multiple.
# # expect(page).to_have_title(re.compile('Dashboard|Choose service'))