From 202c9aea624b079a10c8e9a609ac9cae3ddd65bd Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 13 Jul 2017 07:10:45 +0100 Subject: [PATCH] Hide status for individual letters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The status for each letter in a job will be the same for every single letter (at least until we start dealing with returns). It’s redundant to show this information over and over again. This commit removes it. --- app/templates/components/table.html | 40 ++++++++++--------- .../partials/jobs/notifications.html | 4 +- tests/app/main/views/test_jobs.py | 37 +++++++++++++++++ 3 files changed, 62 insertions(+), 19 deletions(-) diff --git a/app/templates/components/table.html b/app/templates/components/table.html index 5ad942fe6..57a5d995e 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -119,25 +119,29 @@ {% macro notification_status_field(notification) %} - {% call field(status=notification.status|format_notification_status_as_field_status, align='right') %} - {% if notification.status in ['created', 'sending', 'delivered'] %}{% endif %} - {% if notification.status|format_notification_status_as_url %} - - {% endif %} - {{ notification.status|format_notification_status( - notification.template.template_type - ) }} - {% if notification.status|format_notification_status_as_url %} - - {% endif %} - - {{ notification.status|format_notification_status_as_time( - notification.created_at|format_datetime_short, - (notification.updated_at or notification.created_at)|format_datetime_short + {% if not notification %} + {% call field(align='right') %}{% endcall %} + {% else %} + {% call field(status=notification.status|format_notification_status_as_field_status, align='right') %} + {% if notification.status in ['created', 'sending', 'delivered'] %}{% endif %} + {% if notification.status|format_notification_status_as_url %} + + {% endif %} + {{ notification.status|format_notification_status( + notification.template.template_type ) }} - - {% if notification.status in ['created', 'sending', 'delivered'] %}{% endif %} - {% endcall %} + {% if notification.status|format_notification_status_as_url %} + + {% endif %} + + {{ notification.status|format_notification_status_as_time( + notification.created_at|format_datetime_short, + (notification.updated_at or notification.created_at)|format_datetime_short + ) }} + + {% if notification.status in ['created', 'sending', 'delivered'] %}{% endif %} + {% endcall %} + {% endif %} {% endmacro %} diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index c630afda7..e816c5555 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -53,7 +53,9 @@ {{ item.preview_of_content }}

{% endcall %} - {{ notification_status_field(item) }} + {{ notification_status_field( + '' if template.template_type == 'letter' else item + ) }} {% endcall %} {% if more_than_one_page %} diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 3a4a65b82..109de4e2f 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -158,6 +158,43 @@ def test_should_show_job_in_progress( assert page.find('p', {'class': 'hint'}).text.strip() == 'Report is 50% complete…' +@freeze_time("2016-01-01 11:09:00.061258") +def test_should_show_letter_job( + client_request, + mock_get_service_letter_template, + mock_get_job, + mock_get_notifications, + fake_uuid, +): + + page = client_request.get( + 'main.view_job', + service_id=SERVICE_ONE_ID, + job_id=fake_uuid, + ) + + assert normalize_spaces(page.h1.text) == 'thisisatest.csv' + assert normalize_spaces(page.select('tbody tr')[0].text) == ( + '07123456789 template content' + ) + + mock_get_notifications.assert_called_with( + SERVICE_ONE_ID, + fake_uuid, + status=[ + 'created', + 'pending', + 'sending', + 'delivered', + 'sent', + 'failed', + 'temporary-failure', + 'permanent-failure', + 'technical-failure', + ], + ) + + @freeze_time("2016-01-01T00:00:00.061258") def test_should_show_scheduled_job( logged_in_client,