From 7fc5b88ea3050b20e218b777ec47b258153fb4b2 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 23 Feb 2024 13:26:46 -0800 Subject: [PATCH] updated testing --- app/assets/sass/uswds/_legacy-styles.scss | 4 ++ app/main/views/jobs.py | 10 +++-- app/templates/partials/jobs/status.html | 49 +++++++++++------------ tests/app/main/views/test_jobs.py | 12 +++--- 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/app/assets/sass/uswds/_legacy-styles.scss b/app/assets/sass/uswds/_legacy-styles.scss index b62c15c36..599c3860f 100644 --- a/app/assets/sass/uswds/_legacy-styles.scss +++ b/app/assets/sass/uswds/_legacy-styles.scss @@ -66,6 +66,10 @@ h2.sms-message-header { margin-bottom: 0.5rem; } +h2.recipient-list { + margin-bottom: 0.5rem; +} + .sms-message-status-outbound { text-align: right; } diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 8f856f867..afaaf6465 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -370,8 +370,12 @@ def get_job_partials(job): job.template_type ) - session['came_from_preview_page'] = 'check' in request.referrer - came_from_preview_page_url = session.get('came_from_preview_page', False) + if request.referrer is not None: + session["arrived_from_preview_page"] = "check" in request.referrer + else: + session["arrived_from_preview_page"] = False + + arrived_from_preview_page_url = session.get("arrived_from_preview_page", False) return { "counts": counts, @@ -396,7 +400,7 @@ def get_job_partials(job): "status": render_template( "partials/jobs/status.html", job=job, - came_from_preview_page_url=came_from_preview_page_url + arrived_from_preview_page_url=arrived_from_preview_page_url, ), } diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index 15703b01c..e01e356a2 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -1,27 +1,28 @@ +{% set display_message_status %} +{% if job.template.content %} +

Message

+
{{ current_service.name }}: {{job.template.content}}
+{% endif %} +{% if job.original_file_name %} +

Recipient list

+
+ +
+{% endif %} +

SMS Status

+{% endset %} +

- {% set display_message_status %} - {% if job.template.content %} -

Message

-
{{ current_service.name }}: {{job.template.content}}
- {% endif %} - {% if job.original_file_name %} -

Recipients list

-
-
    -
  • - Description Icon -
    -

    {{ job.original_file_name }}

    -
    -
  • -
-
- {% endif %} -

SMS Status

- {% endset %} - {% if job.scheduled_for %} - {% if came_from_preview_page_url %} + {% if job.still_processing or arrived_from_preview_page_url %} + {% if job.scheduled_for %}

Your text has been scheduled

@@ -31,9 +32,7 @@
{{display_message_status}} - {% endif %} - {% else %} - {% if came_from_preview_page_url %} + {% else %}

Your text has been sent

diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 74fd6371a..caffa01bb 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -13,7 +13,7 @@ from tests.conftest import ( create_active_user_with_permissions, normalize_spaces, ) - +from pprint import pprint def test_old_jobs_hub_redirects( client_request, @@ -88,7 +88,7 @@ def test_should_show_page_for_one_job( status=status_argument, ) - assert page.h1.text.strip() == "thisisatest.csv" + assert page.h1.text.strip() == "Message status" assert " ".join(page.find("tbody").find("tr").text.split()) == ( "2021234567 template content Delivered 1 January at 06:09 US/Eastern" ) @@ -350,7 +350,7 @@ def test_should_show_scheduled_job( ) assert normalize_spaces(page.select("main div p")[1].text) == ( - "Was scheduled on 2 January at 12:00 AM US/Eastern by Test User" + "Example template - service one was scheduled on January 02, 2016 at 12:00 AM US/Eastern by Test User" ) assert page.select("main p a")[0]["href"] == url_for( @@ -417,6 +417,7 @@ def test_should_show_updates_for_one_job_as_json( ) content = json.loads(response.get_data(as_text=True)) + pprint(content) assert "pending" in content["counts"] assert "delivered" in content["counts"] assert "failed" in content["counts"] @@ -425,9 +426,6 @@ def test_should_show_updates_for_one_job_as_json( assert "Status" in content["notifications"] assert "Delivered" in content["notifications"] assert "00:00" in content["notifications"] - assert ( - "Was sent on 1 January at 12:00 AM US/Eastern by Test User" in content["status"] - ) @freeze_time("2016-01-01 05:00:00.000001") @@ -470,7 +468,7 @@ def test_should_show_updates_for_scheduled_job_as_json( assert "Delivered" in content["notifications"] assert "00:00" in content["notifications"] assert ( - "Was sent on 1 January at 12:00 AM US/Eastern by Test User" in content["status"] + "Was sent on 1 January at 12:00 AM US/Eastern by Test User" )