notify-536: accurately reflect delivery receipts in UI (#551)

This commit is contained in:
Kenneth Kehl
2023-06-27 08:20:58 -07:00
committed by GitHub
parent 87bd216609
commit d2d7a75a5f
11 changed files with 43 additions and 19 deletions

View File

@@ -275,7 +275,7 @@ def get_status_filters(service, message_type, statistics):
filters = [ filters = [
# key, label, option # key, label, option
('requested', 'total', 'sending,delivered,failed'), ('requested', 'total', 'sending,delivered,failed'),
('sending', 'sending', 'sending'), ('sending', 'pending', 'pending'),
('delivered', 'delivered', 'delivered'), ('delivered', 'delivered', 'delivered'),
('failed', 'failed', 'failed'), ('failed', 'failed', 'failed'),
] ]
@@ -320,10 +320,10 @@ def _get_job_counts(job):
], ],
[ [
Markup( Markup(
f'''sending<span class="usa-sr-only"> f'''pending<span class="usa-sr-only">
{message_count_noun(job.notifications_sending, job_type)}</span>''' {message_count_noun(job.notifications_sending, job_type)}</span>'''
), ),
'sending', 'pending',
job.notifications_sending job.notifications_sending
], ],
[ [

View File

@@ -5,9 +5,12 @@
{% if notifications_deleted %} {% if notifications_deleted %}
<div class="govuk-grid-row bottom-gutter-1-2"> <div class="govuk-grid-row bottom-gutter-1-2">
{% for label, query_param, url, count in counts %} {% for label, query_param, url, count in counts %}
<div class="govuk-grid-column-one-quarter"> {% if query_param == 'pending' %}
{{ big_number(count, label, smaller=True) }} <div class="govuk-grid-column-one-quarter">{{ big_number(count, query_param, smaller=True) }}</div>
</div> {% else %}
<div class="govuk-grid-column-one-quarter">{{ big_number(count, label, smaller=True) }}</div>
{% endif %}
{% endfor %} {% endfor %}
</div> </div>
{% else %} {% else %}

View File

@@ -1,3 +1,4 @@
<div class="ajax-block-container"> <div class="ajax-block-container">
{% set field_status = notification.status|format_notification_status_as_field_status(notification.notification_type) %} {% set field_status = notification.status|format_notification_status_as_field_status(notification.notification_type) %}
{% set status_url = notification.status|format_notification_status_as_url(notification.notification_type) %} {% set status_url = notification.status|format_notification_status_as_url(notification.notification_type) %}
@@ -5,9 +6,18 @@
{% if status_url %} {% if status_url %}
<a class="govuk-link govuk-link--destructive" href="{{ status_url }}"> <a class="govuk-link govuk-link--destructive" href="{{ status_url }}">
{% endif %} {% endif %}
{% if notification.status != 'sending' %}
{{ notification.status|format_notification_status( {{ notification.status|format_notification_status(
notification.template.template_type notification.template.template_type
) }} ) }}
{% endif %}
{% if notification.status == 'sending' %}
<p class="notification-status {{ field_status }}">
Pending. Messages will remain in pending state until carrier status is received, typically 5 minutes.
</p>
{% endif %}
{% if status_url %} {% if status_url %}
</a> </a>
{% endif %} {% endif %}
@@ -15,4 +25,5 @@
(test) (test)
{% endif %} {% endif %}
</p> </p>
</div> </div>

View File

@@ -1,5 +1,4 @@
{% from "components/pill.html" import pill %} {% from "components/pill.html" import pill %}
<div class='bottom-gutter ajax-block-container'> <div class='bottom-gutter ajax-block-container'>
{{ pill( {{ pill(
status_filters, status_filters,

View File

@@ -50,7 +50,7 @@
{{ big_number( {{ big_number(
item.notifications_sending, item.notifications_sending,
smallest=True, smallest=True,
label='sending', label='pending',
) }} ) }}
</div> </div>
<div class="govuk-grid-column-one-third"> <div class="govuk-grid-column-one-third">

View File

@@ -17,6 +17,6 @@
{{ ajax_block(partials, updates_url, 'counts', finished=job.processing_finished) }} {{ ajax_block(partials, updates_url, 'counts', finished=job.processing_finished) }}
{{ ajax_block(partials, updates_url, 'notifications', finished=job.processing_finished) }} {{ ajax_block(partials, updates_url, 'notifications', finished=job.processing_finished) }}
<div>&nbsp;</div> <div> </div>
{% endblock %} {% endblock %}

View File

@@ -25,6 +25,11 @@
'counts' 'counts'
) }} ) }}
<p class="notification-status {{ field_status }}">
Messages will remain in pending state until carrier status is received, typically 5 minutes.
</p>
{% call form_wrapper( {% call form_wrapper(
action=url_for('.view_notifications', service_id=current_service.id, message_type=message_type), action=url_for('.view_notifications', service_id=current_service.id, message_type=message_type),
class="usa-search margin-bottom-2" class="usa-search margin-bottom-2"
@@ -50,6 +55,10 @@
{% endcall %} {% endcall %}
{% call form_wrapper(id="search-form") %} {% call form_wrapper(id="search-form") %}
<input type="hidden" name="to" {% if search_form.to.data %}value="{{ search_form.to.data }}{% endif %}"> <input type="hidden" name="to" {% if search_form.to.data %}value="{{ search_form.to.data }}{% endif %}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">

View File

@@ -520,7 +520,7 @@ def test_get_status_filters_calculates_stats(client_request):
assert {label: count for label, _option, _link, count in ret} == { assert {label: count for label, _option, _link, count in ret} == {
'total': 6, 'total': 6,
'sending': 3, 'pending': 3,
'failed': 2, 'failed': 2,
'delivered': 1 'delivered': 1
} }
@@ -530,7 +530,7 @@ def test_get_status_filters_in_right_order(client_request):
ret = get_status_filters(Service({'id': 'foo'}), 'sms', STATISTICS) ret = get_status_filters(Service({'id': 'foo'}), 'sms', STATISTICS)
assert [label for label, _option, _link, _count in ret] == [ assert [label for label, _option, _link, _count in ret] == [
'total', 'sending', 'delivered', 'failed' 'total', 'pending', 'delivered', 'failed'
] ]

View File

@@ -182,7 +182,7 @@ def test_should_show_job_in_progress(
normalize_spaces(link.text) normalize_spaces(link.text)
for link in page.select('.pill a:not(.pill-item--selected)') for link in page.select('.pill a:not(.pill-item--selected)')
] == [ ] == [
'10 sending text messages', '0 delivered text messages', '0 failed text messages' '10 pending text messages', '0 delivered text messages', '0 failed text messages'
] ]
assert page.select_one('p.hint').text.strip() == 'Report is 50% complete…' assert page.select_one('p.hint').text.strip() == 'Report is 50% complete…'
@@ -207,7 +207,7 @@ def test_should_show_job_without_notifications(
normalize_spaces(link.text) normalize_spaces(link.text)
for link in page.select('.pill a:not(.pill-item--selected)') for link in page.select('.pill a:not(.pill-item--selected)')
] == [ ] == [
'10 sending text messages', '0 delivered text messages', '0 failed text messages' '10 pending text messages', '0 delivered text messages', '0 failed text messages'
] ]
assert page.select_one('p.hint').text.strip() == 'Report is 50% complete…' assert page.select_one('p.hint').text.strip() == 'Report is 50% complete…'
assert page.select_one('tbody').text.strip() == 'No messages to show yet…' assert page.select_one('tbody').text.strip() == 'No messages to show yet…'
@@ -307,7 +307,7 @@ def test_should_show_old_job(
for column in page.select('main .govuk-grid-column-one-quarter') for column in page.select('main .govuk-grid-column-one-quarter')
] == [ ] == [
'1 total text messages', '1 total text messages',
'1 sending text message', '1 pending',
'0 delivered text messages', '0 delivered text messages',
'0 failed text messages', '0 failed text messages',
] ]
@@ -395,7 +395,7 @@ def test_should_show_updates_for_one_job_as_json(
) )
content = json.loads(response.get_data(as_text=True)) content = json.loads(response.get_data(as_text=True))
assert 'sending' in content['counts'] assert 'pending' in content['counts']
assert 'delivered' in content['counts'] assert 'delivered' in content['counts']
assert 'failed' in content['counts'] assert 'failed' in content['counts']
assert 'Recipient' in content['notifications'] assert 'Recipient' in content['notifications']
@@ -432,7 +432,7 @@ def test_should_show_updates_for_scheduled_job_as_json(
) )
content = response.json content = response.json
assert 'sending' in content['counts'] assert 'pending' in content['counts']
assert 'delivered' in content['counts'] assert 'delivered' in content['counts']
assert 'failed' in content['counts'] assert 'failed' in content['counts']
assert 'Recipient' in content['notifications'] assert 'Recipient' in content['notifications']

View File

@@ -15,7 +15,8 @@ from tests.conftest import (
@pytest.mark.parametrize('key_type, notification_status, expected_status', [ @pytest.mark.parametrize('key_type, notification_status, expected_status', [
(None, 'created', 'Sending'), (None, 'created', 'Sending'),
(None, 'sending', 'Sending'), (None, 'sending',
"Pending. Messages will remain in pending state until carrier status is received, typically 5 minutes."),
(None, 'delivered', 'Delivered'), (None, 'delivered', 'Delivered'),
(None, 'failed', 'Failed'), (None, 'failed', 'Failed'),
(None, 'temporary-failure', 'Phone not accepting messages right now'), (None, 'temporary-failure', 'Phone not accepting messages right now'),
@@ -23,7 +24,8 @@ from tests.conftest import (
(None, 'technical-failure', 'Technical failure'), (None, 'technical-failure', 'Technical failure'),
('team', 'delivered', 'Delivered'), ('team', 'delivered', 'Delivered'),
('live', 'delivered', 'Delivered'), ('live', 'delivered', 'Delivered'),
('test', 'sending', 'Sending (test)'), ('test', 'sending',
"Pending. Messages will remain in pending state until carrier status is received, typically 5 minutes. (test)"),
('test', 'delivered', 'Delivered (test)'), ('test', 'delivered', 'Delivered (test)'),
('test', 'permanent-failure', 'Not delivered (test)'), ('test', 'permanent-failure', 'Not delivered (test)'),
]) ])

View File

@@ -49,7 +49,7 @@ def test_get_upload_hub_page(
assert normalize_spaces(uploads[0].text.strip()) == ( assert normalize_spaces(uploads[0].text.strip()) == (
'some.csv ' 'some.csv '
'Sent 1 January 2016 at 11:09am ' 'Sent 1 January 2016 at 11:09am '
'0 sending 8 delivered 2 failed' '0 pending 8 delivered 2 failed'
) )
assert uploads[0].select_one('a.file-list-filename-large')['href'] == ( assert uploads[0].select_one('a.file-list-filename-large')['href'] == (
'/services/{}/jobs/job_id_1'.format(SERVICE_ONE_ID) '/services/{}/jobs/job_id_1'.format(SERVICE_ONE_ID)