mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 14:59:49 -04:00
Show if letters are sent using a test key
It’s inaccurate to have an estimated delivery date for letters sent using a test key. We shouldn’t reassure people that: - the letter won’t be printed - (in the case of precompiled letters) that the letter has passed validation
This commit is contained in:
@@ -125,7 +125,10 @@ def view_notification(service_id, notification_id):
|
|||||||
can_receive_inbound=(current_service.has_permission('inbound_sms')),
|
can_receive_inbound=(current_service.has_permission('inbound_sms')),
|
||||||
is_precompiled_letter=notification['template']['is_precompiled_letter'],
|
is_precompiled_letter=notification['template']['is_precompiled_letter'],
|
||||||
letter_print_day=letter_print_day,
|
letter_print_day=letter_print_day,
|
||||||
show_cancel_button=show_cancel_button
|
show_cancel_button=show_cancel_button,
|
||||||
|
sent_with_test_key=(
|
||||||
|
notification.get('key_type') == KEY_TYPE_TEST
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% if is_precompiled_letter %}
|
{% if is_precompiled_letter %}
|
||||||
Provided as PDF
|
Provided as PDF
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if help %}
|
{% if help %}
|
||||||
‘{{ template.name }}’
|
‘{{ template.name }}’
|
||||||
@@ -51,15 +51,31 @@
|
|||||||
fixed the problem
|
fixed the problem
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
{% if sent_with_test_key %}
|
||||||
{{ letter_print_day }}
|
<p>
|
||||||
</p>
|
Postage: {{ postage }} class
|
||||||
<p>
|
</p>
|
||||||
Postage: {{ postage }} class
|
{% if is_precompiled_letter %}
|
||||||
</p>
|
<p>
|
||||||
<p>
|
This letter has passed our checks, but it won’t be printed
|
||||||
Estimated delivery date: {{ estimated_letter_delivery_date|string|format_date_short }}
|
because you used a test key
|
||||||
</p>
|
</p>
|
||||||
|
{% else %}
|
||||||
|
<p>
|
||||||
|
This letter won’t be printed because you used a test key
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<p>
|
||||||
|
{{ letter_print_day }}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Postage: {{ postage }} class
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Estimated delivery date: {{ estimated_letter_delivery_date|string|format_date_short }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,76 @@ def test_notification_page_shows_page_for_letter_notification(
|
|||||||
assert mock_page_count.call_args_list[0][1]['values'] == {'name': 'Jo'}
|
assert mock_page_count.call_args_list[0][1]['values'] == {'name': 'Jo'}
|
||||||
|
|
||||||
|
|
||||||
|
@freeze_time("2016-01-01 01:01")
|
||||||
|
@pytest.mark.parametrize('is_precompiled_letter, expected_p1, expected_p2, expected_p3', (
|
||||||
|
(
|
||||||
|
True,
|
||||||
|
'Provided as PDF on 1 January at 1:01am',
|
||||||
|
'Postage: second class',
|
||||||
|
'This letter has passed our checks, but it won’t be printed because you used a test key',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
False,
|
||||||
|
'‘sample template’ was sent on 1 January at 1:01am',
|
||||||
|
'Postage: second class',
|
||||||
|
'This letter won’t be printed because you used a test key',
|
||||||
|
),
|
||||||
|
))
|
||||||
|
def test_notification_page_shows_page_for_letter_sent_with_test_key(
|
||||||
|
client_request,
|
||||||
|
mocker,
|
||||||
|
fake_uuid,
|
||||||
|
is_precompiled_letter,
|
||||||
|
expected_p1,
|
||||||
|
expected_p2,
|
||||||
|
expected_p3,
|
||||||
|
):
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.notifications.view_letter_notification_as_preview',
|
||||||
|
return_value=b'foo'
|
||||||
|
)
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.notifications.pdf_page_count',
|
||||||
|
return_value=1
|
||||||
|
)
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.notifications.get_page_count_for_letter',
|
||||||
|
return_value=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
notification = mock_get_notification(
|
||||||
|
mocker,
|
||||||
|
fake_uuid,
|
||||||
|
notification_status='created',
|
||||||
|
template_type='letter',
|
||||||
|
is_precompiled_letter=is_precompiled_letter,
|
||||||
|
postage='second',
|
||||||
|
key_type='test',
|
||||||
|
sent_one_off=False,
|
||||||
|
)
|
||||||
|
notification.created_at = datetime.utcnow()
|
||||||
|
|
||||||
|
page = client_request.get(
|
||||||
|
'main.view_notification',
|
||||||
|
service_id=SERVICE_ONE_ID,
|
||||||
|
notification_id=fake_uuid,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert normalize_spaces(page.select('main p:nth-of-type(1)')[0].text) == (
|
||||||
|
expected_p1
|
||||||
|
)
|
||||||
|
assert normalize_spaces(page.select('main p:nth-of-type(2)')[0].text) == (
|
||||||
|
expected_p2
|
||||||
|
)
|
||||||
|
assert normalize_spaces(page.select('main p:nth-of-type(3)')[0].text) == (
|
||||||
|
expected_p3
|
||||||
|
)
|
||||||
|
assert page.select('p.notification-status') == []
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('notification_status, expected_message', (
|
@pytest.mark.parametrize('notification_status, expected_message', (
|
||||||
(
|
(
|
||||||
'permanent-failure',
|
'permanent-failure',
|
||||||
|
|||||||
@@ -2693,7 +2693,8 @@ def mock_get_notification(
|
|||||||
template_name='sample template',
|
template_name='sample template',
|
||||||
is_precompiled_letter=False,
|
is_precompiled_letter=False,
|
||||||
key_type=None,
|
key_type=None,
|
||||||
postage=None
|
postage=None,
|
||||||
|
sent_one_off=True,
|
||||||
):
|
):
|
||||||
def _get_notification(
|
def _get_notification(
|
||||||
service_id,
|
service_id,
|
||||||
@@ -2708,11 +2709,12 @@ def mock_get_notification(
|
|||||||
)['notifications'][0]
|
)['notifications'][0]
|
||||||
|
|
||||||
noti['id'] = notification_id
|
noti['id'] = notification_id
|
||||||
noti['created_by'] = {
|
if sent_one_off:
|
||||||
'id': fake_uuid,
|
noti['created_by'] = {
|
||||||
'name': 'Test User',
|
'id': fake_uuid,
|
||||||
'email_address': 'test@user.gov.uk'
|
'name': 'Test User',
|
||||||
}
|
'email_address': 'test@user.gov.uk'
|
||||||
|
}
|
||||||
noti['personalisation'] = {'name': 'Jo'}
|
noti['personalisation'] = {'name': 'Jo'}
|
||||||
noti['template'] = template_json(
|
noti['template'] = template_json(
|
||||||
service_id,
|
service_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user