mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-29 04:09:07 -04:00
Merge branch 'main' into 2104-join-notify
This commit is contained in:
@@ -269,7 +269,7 @@ def test_invite_goes_in_session(
|
||||
("user", "landing_page_title"),
|
||||
[
|
||||
(create_active_user_with_permissions(), "Dashboard"),
|
||||
(create_active_caseworking_user(), "Templates"),
|
||||
(create_active_caseworking_user(), "Select or create a template"),
|
||||
],
|
||||
)
|
||||
def test_accepting_invite_removes_invite_from_session(
|
||||
|
||||
@@ -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) == (
|
||||
# 'Who’s 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"]
|
||||
|
||||
@@ -1253,7 +1253,7 @@ def test_send_one_off_has_correct_page_title(
|
||||
step_index=0,
|
||||
_follow_redirects=True,
|
||||
)
|
||||
assert page.h1.text.strip() == "Send ‘Two week reminder’"
|
||||
assert page.h1.text.strip() == "Select recipients"
|
||||
|
||||
assert len(page.select(".banner-tour")) == 0
|
||||
|
||||
@@ -2712,7 +2712,7 @@ def test_preview_notification_shows_preview(
|
||||
template_id=fake_uuid,
|
||||
_expected_status=200,
|
||||
)
|
||||
assert page.h1.text.strip() == "Preview"
|
||||
assert page.h1.text.strip() == "Preview for sending"
|
||||
assert (page.find_all("a", {"class": "usa-back-link"})[0]["href"]) == url_for(
|
||||
"main.check_notification",
|
||||
service_id=service_one["id"],
|
||||
|
||||
@@ -41,8 +41,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
(
|
||||
"expected_title_tag",
|
||||
"expected_page_title",
|
||||
"expected_title_tag",
|
||||
"expected_parent_link_args",
|
||||
"extra_args",
|
||||
"expected_nav_links",
|
||||
@@ -53,8 +53,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
),
|
||||
[
|
||||
(
|
||||
"Templates – service one – Notify.gov",
|
||||
"Templates",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[],
|
||||
{},
|
||||
["Email", "Text message"],
|
||||
@@ -92,8 +92,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
None,
|
||||
),
|
||||
(
|
||||
"Templates – service one – Notify.gov",
|
||||
"Templates",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[],
|
||||
{"template_type": "all"},
|
||||
["Email", "Text message"],
|
||||
@@ -131,8 +131,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
None,
|
||||
),
|
||||
(
|
||||
"Templates – service one – Notify.gov",
|
||||
"Templates",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[],
|
||||
{"template_type": "sms"},
|
||||
["All", "Email"],
|
||||
@@ -159,8 +159,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
None,
|
||||
),
|
||||
(
|
||||
"folder_one – Templates – service one – Notify.gov",
|
||||
"Templates folder_one",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[{"template_type": "all"}],
|
||||
{"template_folder_id": PARENT_FOLDER_ID},
|
||||
["Email", "Text message"],
|
||||
@@ -182,8 +182,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
None,
|
||||
),
|
||||
(
|
||||
"folder_one – Templates – service one – Notify.gov",
|
||||
"Templates folder_one",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[{"template_type": "sms"}],
|
||||
{"template_type": "sms", "template_folder_id": PARENT_FOLDER_ID},
|
||||
["All", "Email"],
|
||||
@@ -199,8 +199,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
None,
|
||||
),
|
||||
(
|
||||
"folder_one – Templates – service one – Notify.gov",
|
||||
"Templates folder_one",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[{"template_type": "email"}],
|
||||
{"template_type": "email", "template_folder_id": PARENT_FOLDER_ID},
|
||||
["All", "Text message"],
|
||||
@@ -210,8 +210,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
"There are no email templates in this folder",
|
||||
),
|
||||
(
|
||||
"folder_one_one – folder_one – Templates – service one – Notify.gov",
|
||||
"Templates folder_one folder_one_one",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[
|
||||
{"template_type": "all"},
|
||||
{"template_type": "all", "template_folder_id": PARENT_FOLDER_ID},
|
||||
@@ -229,8 +229,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
None,
|
||||
),
|
||||
(
|
||||
"folder_one_one_one – folder_one_one – folder_one – Templates – service one – Notify.gov",
|
||||
"Templates folder_one folder_one_one folder_one_one_one",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[
|
||||
{"template_type": "all"},
|
||||
{"template_type": "all", "template_folder_id": PARENT_FOLDER_ID},
|
||||
@@ -250,8 +250,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
None,
|
||||
),
|
||||
(
|
||||
"folder_one_one_one – folder_one_one – folder_one – Templates – service one – Notify.gov",
|
||||
"Templates folder_one folder_one_one folder_one_one_one",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[
|
||||
{"template_type": "email"},
|
||||
{"template_type": "email", "template_folder_id": PARENT_FOLDER_ID},
|
||||
@@ -268,8 +268,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
"There are no email templates in this folder",
|
||||
),
|
||||
(
|
||||
"folder_two – Templates – service one – Notify.gov",
|
||||
"Templates folder_two",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[{"template_type": "all"}],
|
||||
{"template_folder_id": FOLDER_TWO_ID},
|
||||
["Email", "Text message"],
|
||||
@@ -279,8 +279,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
"This folder is empty",
|
||||
),
|
||||
(
|
||||
"folder_two – Templates – service one – Notify.gov",
|
||||
"Templates folder_two",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[{"template_type": "sms"}],
|
||||
{"template_folder_id": FOLDER_TWO_ID, "template_type": "sms"},
|
||||
["All", "Email"],
|
||||
@@ -290,8 +290,8 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
"This folder is empty",
|
||||
),
|
||||
(
|
||||
"folder_two – Templates – service one – Notify.gov",
|
||||
"Templates folder_two",
|
||||
"Select or create a template – service one – Notify.gov",
|
||||
"Select or create a template",
|
||||
[{"template_type": "all"}],
|
||||
{"template_folder_id": FOLDER_TWO_ID, "template_type": "all"},
|
||||
["Email", "Text message"],
|
||||
@@ -346,12 +346,17 @@ def test_should_show_templates_folder_page(
|
||||
**extra_args,
|
||||
)
|
||||
|
||||
assert normalize_spaces(page.select_one("title").text) == expected_title_tag
|
||||
assert normalize_spaces(page.select_one("h1").text) == expected_page_title
|
||||
assert normalize_spaces(page.select_one("title").text) == expected_page_title
|
||||
assert normalize_spaces(page.select_one("h1").text) == expected_title_tag
|
||||
|
||||
assert len(page.select("h1 a")) == len(expected_parent_link_args)
|
||||
# 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
|
||||
)
|
||||
|
||||
for index, parent_link in enumerate(page.select("h1 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,
|
||||
@@ -529,7 +534,7 @@ def test_get_manage_folder_page(
|
||||
_test_page_title=False,
|
||||
)
|
||||
assert normalize_spaces(page.select_one("title").text) == (
|
||||
"folder_two – Templates – service one – Notify.gov"
|
||||
"Select or create a template – service one – Notify.gov"
|
||||
)
|
||||
assert page.select_one("input[name=name]")["value"] == "folder_two"
|
||||
delete_link = page.find("a", string="Delete this folder")
|
||||
@@ -571,7 +576,7 @@ def test_get_manage_folder_viewing_permissions_for_users(
|
||||
_test_page_title=False,
|
||||
)
|
||||
assert normalize_spaces(page.select_one("title").text) == (
|
||||
"folder_two – Templates – service one – Notify.gov"
|
||||
"Select or create a template – service one – Notify.gov"
|
||||
)
|
||||
form_labels = page.select("legend.usa-legend")
|
||||
assert (
|
||||
@@ -634,7 +639,7 @@ def test_get_manage_folder_viewing_permissions_for_users_not_visible_when_no_man
|
||||
_test_page_title=False,
|
||||
)
|
||||
assert normalize_spaces(page.select_one("title").text) == (
|
||||
"folder_two – Templates – service one – Notify.gov"
|
||||
"Select or create a template – service one – Notify.gov"
|
||||
)
|
||||
form_labels = page.select("legend[class=form-label]")
|
||||
assert len(form_labels) == 0
|
||||
@@ -671,7 +676,7 @@ def test_get_manage_folder_viewing_permissions_for_users_not_visible_for_service
|
||||
_test_page_title=False,
|
||||
)
|
||||
assert normalize_spaces(page.select_one("title").text) == (
|
||||
"folder_two – Templates – service one – Notify.gov"
|
||||
"Select or create a template – service one – Notify.gov"
|
||||
)
|
||||
form_labels = page.select("legend[class=form-label]")
|
||||
assert len(form_labels) == 0
|
||||
|
||||
@@ -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) == ("Templates")
|
||||
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) == ("Templates")
|
||||
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."
|
||||
@@ -110,7 +114,7 @@ def test_should_show_add_template_form_if_service_has_folder_permission(
|
||||
[
|
||||
(
|
||||
create_active_user_view_permissions(),
|
||||
"Templates",
|
||||
"Select or create a template",
|
||||
{},
|
||||
["Email", "Text message"],
|
||||
[
|
||||
@@ -122,21 +126,21 @@ def test_should_show_add_template_form_if_service_has_folder_permission(
|
||||
),
|
||||
(
|
||||
create_active_user_view_permissions(),
|
||||
"Templates",
|
||||
"Select or create a template",
|
||||
{"template_type": "sms"},
|
||||
["All", "Email"],
|
||||
["sms_template_one", "sms_template_two"],
|
||||
),
|
||||
(
|
||||
create_active_user_view_permissions(),
|
||||
"Templates",
|
||||
"Select or create a template",
|
||||
{"template_type": "email"},
|
||||
["All", "Text message"],
|
||||
["email_template_one", "email_template_two"],
|
||||
),
|
||||
(
|
||||
create_active_caseworking_user(),
|
||||
"Templates",
|
||||
"Select or create a template",
|
||||
{},
|
||||
["Email", "Text message"],
|
||||
[
|
||||
@@ -148,7 +152,7 @@ def test_should_show_add_template_form_if_service_has_folder_permission(
|
||||
),
|
||||
(
|
||||
create_active_caseworking_user(),
|
||||
"Templates",
|
||||
"Select or create a template",
|
||||
{"template_type": "email"},
|
||||
["All", "Text message"],
|
||||
["email_template_one", "email_template_two"],
|
||||
@@ -581,9 +585,9 @@ def test_should_be_able_to_view_a_template_with_links(
|
||||
_test_page_title=False,
|
||||
)
|
||||
|
||||
assert normalize_spaces(page.select_one("h1").text) == ("Review your message")
|
||||
assert normalize_spaces(page.select_one("h1").text) == ("Confirm your template")
|
||||
assert normalize_spaces(page.select_one("title").text) == (
|
||||
"Two week reminder – Templates – service one – Notify.gov"
|
||||
"Confirm your template – service one – Notify.gov"
|
||||
)
|
||||
|
||||
assert [
|
||||
|
||||
@@ -62,6 +62,7 @@ EXCLUDED_ENDPOINTS = tuple(
|
||||
"conversation_reply",
|
||||
"conversation_reply_with_template",
|
||||
"conversation_updates",
|
||||
"contact",
|
||||
"copy_template",
|
||||
"count_content_length",
|
||||
"create_and_send_messages",
|
||||
|
||||
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user