mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04:00
Merge branch 'main' of https://github.com/GSA/notifications-admin into 1216-login-gov-pre-sign-in-page
This commit is contained in:
@@ -160,8 +160,8 @@ def test_can_show_notifications(
|
||||
assert normalize_spaces(
|
||||
first_row.select_one(".table-field-right-aligned .align-with-message-body").text
|
||||
) in [
|
||||
"Delivered 1 January at 02:00 US/Eastern",
|
||||
"Delivered 1 January at 01:00 US/Eastern",
|
||||
"Delivered 01-01-2020 at 01:00 AM",
|
||||
"Delivered 01-01-2020 at 01:00 AM",
|
||||
]
|
||||
|
||||
assert page_title in page.h1.text.strip()
|
||||
@@ -656,36 +656,36 @@ def test_redacts_templates_that_should_be_redacted(
|
||||
@pytest.mark.parametrize(
|
||||
("message_type", "status", "expected_hint_status", "single_line"),
|
||||
[
|
||||
("email", "created", "Sending since 27 September at 08:30 US/Eastern", True),
|
||||
("email", "sending", "Sending since 27 September at 08:30 US/Eastern", True),
|
||||
("email", "created", "Sending since 09-27-2017 at 08:30 AM", True),
|
||||
("email", "sending", "Sending since 09-27-2017 at 08:30 AM", True),
|
||||
(
|
||||
"email",
|
||||
"temporary-failure",
|
||||
"Inbox not accepting messages right now 27 September at 08:30 US/Eastern",
|
||||
"Inbox not accepting messages right now 09-27-2017 at 08:30 AM",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"email",
|
||||
"permanent-failure",
|
||||
"Email address does not exist 27 September at 08:30 US/Eastern",
|
||||
"Email address does not exist 09-27-2017 at 08:30 AM",
|
||||
False,
|
||||
),
|
||||
("email", "delivered", "Delivered 27 September at 08:30 US/Eastern", True),
|
||||
("sms", "created", "Sending since 27 September at 08:30 US/Eastern", True),
|
||||
("sms", "sending", "Sending since 27 September at 08:30 US/Eastern", True),
|
||||
("email", "delivered", "Delivered 09-27-2017 at 08:30 AM", True),
|
||||
("sms", "created", "Sending since 09-27-2017 at 08:30 AM", True),
|
||||
("sms", "sending", "Sending since 09-27-2017 at 08:30 AM", True),
|
||||
(
|
||||
"sms",
|
||||
"temporary-failure",
|
||||
"Phone not accepting messages right now 27 September at 08:30 US/Eastern",
|
||||
"Phone not accepting messages right now 09-27-2017 at 08:30 AM",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"sms",
|
||||
"permanent-failure",
|
||||
"Not delivered 27 September at 08:30 US/Eastern",
|
||||
"Not delivered 09-27-2017 at 08:30 AM",
|
||||
False,
|
||||
),
|
||||
("sms", "delivered", "Delivered 27 September at 08:30 US/Eastern", True),
|
||||
("sms", "delivered", "Delivered 09-27-2017 at 08:30 AM", True),
|
||||
],
|
||||
)
|
||||
def test_sending_status_hint_displays_correctly_on_notifications_page(
|
||||
|
||||
@@ -391,7 +391,7 @@ def test_conversation_reply_redirects_with_phone_number_from_notification(
|
||||
)
|
||||
|
||||
for element, expected_text in [
|
||||
("h1", "Preview of ‘Two week reminder’"),
|
||||
("h1", "Select delivery time"),
|
||||
(".sms-message-recipient", "To: 2021234567"),
|
||||
(
|
||||
".sms-message-wrapper",
|
||||
|
||||
@@ -90,7 +90,6 @@ def test_hiding_pages_from_search_engines(
|
||||
[
|
||||
"privacy",
|
||||
"pricing",
|
||||
"terms",
|
||||
"roadmap",
|
||||
"features",
|
||||
"documentation",
|
||||
@@ -167,7 +166,6 @@ def test_guidance_pages_link_to_service_pages_when_signed_in(
|
||||
("information_risk_management", "security"),
|
||||
("old_integration_testing", "integration_testing"),
|
||||
("old_roadmap", "roadmap"),
|
||||
("old_terms", "terms"),
|
||||
("information_security", "using_notify"),
|
||||
("old_using_notify", "using_notify"),
|
||||
("delivery_and_failure", "message_status"),
|
||||
@@ -226,12 +224,12 @@ def test_old_using_notify_page(client_request):
|
||||
# )
|
||||
|
||||
|
||||
def test_terms_page_has_correct_content(client_request):
|
||||
terms_page = client_request.get("main.terms")
|
||||
assert normalize_spaces(terms_page.select("main p")[0].text) == (
|
||||
"These terms apply to your service’s use of Notify.gov. "
|
||||
"You must be the service manager to accept them."
|
||||
)
|
||||
# def test_terms_page_has_correct_content(client_request):
|
||||
# terms_page = client_request.get("main.terms")
|
||||
# assert normalize_spaces(terms_page.select("main p")[0].text) == (
|
||||
# "These terms apply to your service’s use of Notify.gov. "
|
||||
# "You must be the service manager to accept them."
|
||||
# )
|
||||
|
||||
|
||||
def test_css_is_served_from_correct_path(client_request):
|
||||
|
||||
@@ -90,7 +90,7 @@ def test_should_show_page_for_one_job(
|
||||
|
||||
assert page.h1.text.strip() == "thisisatest.csv"
|
||||
assert " ".join(page.find("tbody").find("tr").text.split()) == (
|
||||
"2021234567 template content Delivered 1 January at 06:09 US/Eastern"
|
||||
"2021234567 template content Delivered 01-01-2016 at 06:09 AM"
|
||||
)
|
||||
assert page.find("div", {"data-key": "notifications"})["data-resource"] == url_for(
|
||||
"main.view_job_updates",
|
||||
@@ -109,7 +109,7 @@ def test_should_show_page_for_one_job(
|
||||
assert page.find("span", {"id": "time-left"}).text == "Data available for 7 days"
|
||||
|
||||
assert normalize_spaces(page.select_one("tbody tr").text) == normalize_spaces(
|
||||
"2021234567 " "template content " "Delivered 1 January at 06:09 US/Eastern"
|
||||
"2021234567 " "template content " "Delivered 01-01-2016 at 06:09 AM"
|
||||
)
|
||||
assert page.select_one("tbody tr a")["href"] == url_for(
|
||||
"main.view_notification",
|
||||
@@ -424,8 +424,8 @@ def test_should_show_updates_for_one_job_as_json(
|
||||
assert "2021234567" in content["notifications"]
|
||||
assert "Status" in content["notifications"]
|
||||
assert "Delivered" in content["notifications"]
|
||||
assert "00:00" in content["notifications"]
|
||||
assert "Sent by Test User on 1 January at 00:00" in content["status"]
|
||||
assert "Sent by Test User on 01-01-2016 at 12:00 AM" in content["status"]
|
||||
assert "12:00" in content["notifications"]
|
||||
|
||||
|
||||
@freeze_time("2016-01-01 05:00:00.000001")
|
||||
@@ -466,8 +466,8 @@ def test_should_show_updates_for_scheduled_job_as_json(
|
||||
assert "2021234567" in content["notifications"]
|
||||
assert "Status" in content["notifications"]
|
||||
assert "Delivered" in content["notifications"]
|
||||
assert "00:00" in content["notifications"]
|
||||
assert "Sent by Test User on 1 June at 16:00" in content["status"]
|
||||
assert "Sent by Test User on 06-01-2016 at 04:00 PM" in content["status"]
|
||||
assert "12:00" in content["notifications"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -908,26 +908,22 @@ def test_upload_valid_csv_redirects_to_check_page(
|
||||
(
|
||||
"extra_args",
|
||||
"expected_link_in_first_row",
|
||||
"expected_recipient",
|
||||
"expected_message",
|
||||
),
|
||||
[
|
||||
(
|
||||
{},
|
||||
None,
|
||||
"To: 2028675301",
|
||||
"Test Service: A, Template <em>content</em> with & entity",
|
||||
),
|
||||
(
|
||||
{"row_index": 2},
|
||||
None,
|
||||
"To: 2028675301",
|
||||
"Test Service: A, Template <em>content</em> with & entity",
|
||||
),
|
||||
(
|
||||
{"row_index": 4},
|
||||
True,
|
||||
"To: 2028675303",
|
||||
"Test Service: C, Template <em>content</em> with & entity",
|
||||
),
|
||||
],
|
||||
@@ -946,7 +942,6 @@ def test_upload_valid_csv_shows_preview_and_table(
|
||||
fake_uuid,
|
||||
extra_args,
|
||||
expected_link_in_first_row,
|
||||
expected_recipient,
|
||||
expected_message,
|
||||
):
|
||||
with client_request.session_transaction() as session:
|
||||
@@ -962,40 +957,20 @@ def test_upload_valid_csv_shows_preview_and_table(
|
||||
""",
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
"main.check_messages",
|
||||
page = client_request.post(
|
||||
"main.preview_job",
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
upload_id=fake_uuid,
|
||||
**extra_args,
|
||||
_expected_status=200,
|
||||
)
|
||||
|
||||
mock_s3_set_metadata.assert_called_once_with(
|
||||
SERVICE_ONE_ID,
|
||||
fake_uuid,
|
||||
notification_count=3,
|
||||
template_id=fake_uuid,
|
||||
valid=True,
|
||||
original_file_name="example.csv",
|
||||
)
|
||||
|
||||
assert page.h1.text.strip() == "Preview of Two week reminder"
|
||||
assert page.select_one(".sms-message-recipient").text.strip() == expected_recipient
|
||||
assert page.h1.text.strip() == "Preview"
|
||||
assert page.select("h2")[1].text.strip() == "Recipients list"
|
||||
assert page.h2.text.strip() == "Message"
|
||||
assert page.select_one(".sms-message-wrapper").text.strip() == expected_message
|
||||
|
||||
assert page.select_one(".table-field-index").text.strip() == "2"
|
||||
|
||||
if expected_link_in_first_row:
|
||||
assert page.select_one(".table-field-index a")["href"] == url_for(
|
||||
"main.check_messages",
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
upload_id=fake_uuid,
|
||||
row_index=2,
|
||||
original_file_name="example.csv",
|
||||
)
|
||||
else:
|
||||
assert not page.select_one(".table-field-index").select_one("a")
|
||||
assert not page.select_one(".table-field-index")
|
||||
|
||||
for row_index, row in enumerate(
|
||||
[
|
||||
@@ -1043,7 +1018,7 @@ def test_upload_valid_csv_shows_preview_and_table(
|
||||
for index, cell in enumerate(row):
|
||||
row = page.select("table tbody tr")[row_index]
|
||||
assert "id" not in row
|
||||
assert normalize_spaces(str(row.select("td")[index + 1])) == cell
|
||||
assert normalize_spaces(str(row.select("td")[index])) == cell
|
||||
|
||||
|
||||
def test_show_all_columns_if_there_are_duplicate_recipient_columns(
|
||||
@@ -1674,7 +1649,7 @@ def test_send_one_off_email_to_self_without_placeholders_redirects_to_check_page
|
||||
_follow_redirects=True,
|
||||
)
|
||||
|
||||
assert page.select("h1")[0].text.strip() == "Preview of ‘Two week reminder’"
|
||||
assert page.select("h1")[0].text.strip() == "Select delivery time"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -1901,10 +1876,9 @@ def test_upload_csvfile_with_valid_phone_shows_all_numbers(
|
||||
original_file_name="example.csv",
|
||||
)
|
||||
|
||||
assert "202 867 0701" in page.text
|
||||
assert "202 867 0749" in page.text
|
||||
assert "Select delivery time" in page.text
|
||||
assert "202 867 0749" not in page.text
|
||||
assert "202 867 0750" not in page.text
|
||||
assert "Only showing the first 50 rows" in page.text
|
||||
|
||||
mock_get_notification_count.assert_called_with(service_one["id"])
|
||||
|
||||
@@ -1988,7 +1962,7 @@ def test_test_message_can_only_be_sent_now(
|
||||
assert 'name="scheduled_for"' not in content
|
||||
|
||||
|
||||
def test_send_button_is_correctly_labelled(
|
||||
def test_preview_button_is_correctly_labelled(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_live_service,
|
||||
@@ -2013,9 +1987,7 @@ def test_send_button_is_correctly_labelled(
|
||||
template_id=fake_uuid,
|
||||
)
|
||||
|
||||
assert normalize_spaces(page.select_one("main [type=submit]").text) == (
|
||||
"Send 1,000 text messages"
|
||||
)
|
||||
assert normalize_spaces(page.select_one("main [type=submit]").text) == ("Preview")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("when", ["", "2016-08-25T13:04:21.767198"])
|
||||
@@ -2043,6 +2015,8 @@ def test_create_job_should_call_api(
|
||||
"valid": True,
|
||||
}
|
||||
}
|
||||
with client_request.session_transaction() as session:
|
||||
session["scheduled_for"] = when
|
||||
|
||||
page = client_request.post(
|
||||
"main.start_job",
|
||||
@@ -2593,7 +2567,7 @@ def test_check_notification_redirects_if_session_not_populated(
|
||||
)
|
||||
|
||||
|
||||
def test_check_notification_shows_preview(
|
||||
def test_check_notification_shows_scheduler(
|
||||
client_request, service_one, fake_uuid, mock_get_service_template
|
||||
):
|
||||
with client_request.session_transaction() as session:
|
||||
@@ -2604,7 +2578,7 @@ def test_check_notification_shows_preview(
|
||||
"main.check_notification", service_id=service_one["id"], template_id=fake_uuid
|
||||
)
|
||||
|
||||
assert page.h1.text.strip() == "Preview of ‘Two week reminder’"
|
||||
assert page.h1.text.strip() == "Select delivery time"
|
||||
assert (page.find_all("a", {"class": "usa-back-link"})[0]["href"]) == url_for(
|
||||
"main.send_one_off_step",
|
||||
service_id=service_one["id"],
|
||||
@@ -2615,6 +2589,41 @@ def test_check_notification_shows_preview(
|
||||
# assert tour not visible
|
||||
assert not page.select(".banner-tour")
|
||||
|
||||
# post to send_notification with help=0 to ensure no back link is then shown
|
||||
assert page.form.attrs["action"] == url_for(
|
||||
"main.preview_notification",
|
||||
service_id=service_one["id"],
|
||||
template_id=fake_uuid,
|
||||
)
|
||||
|
||||
assert normalize_spaces(page.select_one("main [type=submit]").text) == ("Preview")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("when", ["", "2016-08-25T13:04:21.767198"])
|
||||
def test_preview_notification_shows_preview(
|
||||
client_request,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
mock_get_service_template,
|
||||
when,
|
||||
):
|
||||
with client_request.session_transaction() as session:
|
||||
session["recipient"] = "15555555555"
|
||||
session["placeholders"] = {}
|
||||
|
||||
page = client_request.post(
|
||||
"main.preview_notification", service_id=service_one["id"], template_id=fake_uuid,
|
||||
_expected_status=200
|
||||
)
|
||||
assert page.h1.text.strip() == "Preview"
|
||||
assert (page.find_all("a", {"class": "usa-back-link"})[0]["href"]) == url_for(
|
||||
"main.check_notification",
|
||||
service_id=service_one["id"],
|
||||
template_id=fake_uuid,
|
||||
)
|
||||
# assert tour not visible
|
||||
assert not page.select(".banner-tour")
|
||||
|
||||
# post to send_notification with help=0 to ensure no back link is then shown
|
||||
assert page.form.attrs["action"] == url_for(
|
||||
"main.send_notification",
|
||||
@@ -2872,7 +2881,6 @@ def test_send_notification_shows_email_error_in_trial_mode(
|
||||
@pytest.mark.parametrize(
|
||||
("endpoint", "extra_args"),
|
||||
[
|
||||
("main.check_messages", {"template_id": uuid4(), "upload_id": uuid4()}),
|
||||
("main.send_one_off_step", {"template_id": uuid4(), "step_index": 0}),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -544,10 +544,9 @@ def test_should_200_for_check_tour_notification(
|
||||
|
||||
# post to send_notification keeps help argument
|
||||
assert page.form.attrs["action"] == url_for(
|
||||
"main.send_notification",
|
||||
"main.preview_notification",
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
help="3",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -128,7 +128,6 @@ EXCLUDED_ENDPOINTS = tuple(
|
||||
"old_integration_testing",
|
||||
"old_roadmap",
|
||||
"old_service_dashboard",
|
||||
"old_terms",
|
||||
"old_using_notify",
|
||||
"organization_billing",
|
||||
"organization_dashboard",
|
||||
@@ -140,6 +139,8 @@ EXCLUDED_ENDPOINTS = tuple(
|
||||
"platform_admin_list_complaints",
|
||||
"platform_admin_reports",
|
||||
"platform_admin_splash_page",
|
||||
"preview_job",
|
||||
"preview_notification",
|
||||
"pricing",
|
||||
"privacy",
|
||||
"received_text_messages_callback",
|
||||
@@ -205,7 +206,6 @@ EXCLUDED_ENDPOINTS = tuple(
|
||||
"suspend_service",
|
||||
"template_history",
|
||||
"template_usage",
|
||||
"terms",
|
||||
"tour_step",
|
||||
"trial_mode",
|
||||
"trial_mode_new",
|
||||
|
||||
Reference in New Issue
Block a user