Link to conversation from notification page

If you’re using inbound SMS then I reckon it’s useful to be able to
naviagate from one message to the context in which that message sits
(ie the conversation).

This commit adds that link.

This is maybe a stopgap until we do something more like chat, where you
can reply on the same screen where you see the conversation, but maybe
it turns out we don’t want to do that – lets see how this works.
This commit is contained in:
Chris Hill-Scott
2017-10-16 10:30:59 +01:00
parent 05513c6fa7
commit 34371d030c
3 changed files with 50 additions and 0 deletions

View File

@@ -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']),
)

View File

@@ -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 %}
<p>
<a href="{{ url_for('.conversation', service_id=current_service.id, notification_id=notification_id, _anchor='n{}'.format(notification_id)) }}">See all text messages sent to this phone number</a>
</p>
{% endif %}
{% endblock %}

View File

@@ -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()