diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py index 81f72343c..1ac400eaf 100644 --- a/app/main/views/notifications.py +++ b/app/main/views/notifications.py @@ -82,6 +82,8 @@ def view_notification(service_id, notification_id): created_at=notification['created_at'], help=get_help_argument(), estimated_letter_delivery_date=get_letter_timings(notification['created_at']).earliest_delivery, + notification_id=notification['id'], + can_receive_inbound=('inbound_sms' in current_service['permissions']), ) diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html index 90e6ef54a..7c1592cfc 100644 --- a/app/templates/views/notifications/notification.html +++ b/app/templates/views/notifications/notification.html @@ -42,4 +42,10 @@ {{ ajax_block(partials, updates_url, 'status', finished=finished) }} {% endif %} + {% if current_user.has_permissions(['send_texts'], admin_override=True) and template.template_type == 'sms' and can_receive_inbound %} +
+ {% endif %} + {% endblock %} diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index c3edc957f..0849a3f19 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -161,3 +161,45 @@ def test_should_show_image_of_letter_notification( assert response.get_data(as_text=True) == 'foo' assert isinstance(mocked_preview.call_args[0][0], LetterImageTemplate) assert mocked_preview.call_args[0][1] == 'png' + + +@pytest.mark.parametrize('service_permissions, template_type, link_expected', [ + ([], '', False), + (['inbound_sms'], 'email', False), + (['inbound_sms'], 'letter', False), + (['inbound_sms'], 'sms', True), +]) +def test_notification_page_has_link_to_send_another_for_sms( + client_request, + mocker, + fake_uuid, + service_one, + service_permissions, + template_type, + link_expected, +): + + service_one['permissions'] = service_permissions + mock_get_notification(mocker, fake_uuid, template_type=template_type) + + page = client_request.get( + 'main.view_notification', + service_id=SERVICE_ONE_ID, + notification_id=fake_uuid, + ) + + last_paragraph = page.select('main p')[-1] + + if link_expected: + assert normalize_spaces(last_paragraph.text) == ( + 'See all text messages sent to this phone number' + ) + assert last_paragraph.select_one('a')['href'] == url_for( + '.conversation', + service_id=SERVICE_ONE_ID, + notification_id=fake_uuid, + _anchor='n{}'.format(fake_uuid), + ) + else: + # covers ‘Delivered’, ‘Expected delivery date’ + assert 'deliver' in normalize_spaces(last_paragraph.text).lower()